QueryDSL和Embadded class->错误的sql

时间:2015-08-12 06:53:25

标签: querydsl


我正在尝试使用querydsl构建这样的SQL查询。

SELECT i.id,i.owner_id FROM Invoice i WHERE i.id=1 AND i.Owner_id=2

其中 i.id i.owner_id 是复合主键。

我有两个班级:

import javax.persistence.Embeddable;
import javax.persistence.Column;

@Embeddable
public class IDsClass
{
  ... public get and set ...

  @Column(name = "Id", nullable = false)
  private int ID;

  @Column(name = "Owner_Id", nullable = false)
  private int OwnerId;

  @Column( name="State")
  private int State;

}

import javax.persistence.*;
import core.IDsClass;

@Entity
@Table(name="invo__ice")

public class INVOICE extends BusinessEntity
{
    @EmbeddedId
    private IDsClass Key;

...get ans set ...
}

Querydsl代码看起来:

query.from(qryInvoice)
     .where(qryInvoice.Key.OwnerId.eq(20)
            .and(qryInvoice.Key.ID.eq(1)))
            .setUseLiterals(true);

当我获得sql字符串时,它就是这样:

from iNVOICE
where iNVOICE.Key.OwnerId = 20 
and iNVOICE.Key.ID = 1

所以,问题是:
1)有什么问题?
2)为什么anotation @Table(name =“invo__ice”)没有改变sql string中的表名?
感谢。

0 个答案:

没有答案