0

我有这些实体:

  @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

4

1 回答 1

0

您可以像这样进行交叉连接

select a,b from MyTable a,MyTableTwo b where a.prop1 = b.prop2
于 2013-10-03T23:34:47.390 回答