Hibernate HQL多个新对象

时间:2016-10-24 12:49:53

标签: hibernate hql

我想用HQL查询做这样的事情:

SELECT new Table1(a.field1, a.field2, new Table2(b.field1, b.field2, b.field3)) 
FROM Table1 a INNER JOIN a.table2 as b where...

你知道我怎么做吗?

1 个答案:

答案 0 :(得分:1)

所以我找到了一个很好的解决方案:

Table1(afield1, afield2, afield3, bfield1, b.field2) {
   this.afield1 = afield1;
   this.afield2 = afield2;
   this.afield3 = afield3;
   this.table2 = new Table2(bfield1, b.field2);
}

使用Table1中的构造函数,如:

 #container {
  position: relative;

}
#image {
    height: 22%;
  position: relative;
   display: inline-block; 
  margin-top:3px;
  vertical-align: bottom;


}
#text {
  z-index: 100;
  position: absolute;
  color: white;
  font-size: 80px;
  font-weight: bold;
  font-family:nexa;
  left: 150px;
  top: -50px;
}
#textdx {
  position: absolute;
  color: #787d83;
  font-size: 80px;
  font-weight: bold;
  font-family:nexa;
  float:right;
  width:50%;
  right: 150px;
  top: -50px;
}