我有这些实体:
@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