我有这些实体:
@Entity
@Table(name = "my_table")
public class MyTable implements Serializable {
@Id
@Column(name = "RECORD_ID")
private Long recordId;
@Column(name = "CNAME")
private String changeName;
@Transient
MyTableTwo tableTwo;
//getters and setters
}
MyTableTwo实体:
@Entity
@Table(name = "my_table_two")
public class MyTableTwo implements Serializable {
@Id
@Column(name = "REC_ID")
private Long recId;
@Column(name = "CNAME")
private String changeName;
@Column(name = "CVAL")
private String changeValue;
//getters and setters
}
我想得到my_table.record_id
。结果中有'my_table.cname','my_table_two.cval'。
如何在这两个实体上写一个查询?
我们可以用第一个实体和第二个实体的@transient实体字段编写连接查询吗?
我需要编写HQL
答案 0 :(得分:0)
你可以像
那样进行交叉连接select a,b from MyTable a,MyTableTwo b where a.prop1 = b.prop2