[英]Hibernate Criteria with EmbeddedId not generate correct sql query
I have the following mapping of my classes: 我的班级有以下映射:
@Entity
Class A{
@EmbeddedId
B id;
String notImportant;
}
@Entity
Class B {
C c;
}
Class C {
String name;
}
When i use the follow criteria: 当我使用以下条件时:
Criteria criteria = getCurrentSession().createCriteria(A.class);
criteria.createAlias("id.c", "c");
criteria.add(Restrictions.eq("c.name", "Whatever"));
criteria.list();
Hibernate:
/* criteria query */ select
this_.notImportant as DOAT2_77_0_
from
A this_
where
c.name=?
2017-04-15 21:03:02,211 ERROR [org.hibernate.util.JDBCExceptionReporter] - ORA-00904: "c"."name": identificador inválido
So i understand that the "c" identified would be defined by a Inner join... As the criteria use this identifier without declaration... 因此,我知道所标识的“ c”将由内部联接定义...由于条件使用此标识符而无需声明...
B
must be annotated with @Embeddable
; B
类必须使用@Embeddable
进行注释; B
has the getC
and setC
methods; B
是否具有getC
和setC
方法; If the error persist, please post your full code. 如果错误仍然存在,请发布完整代码。 :-)
:-)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.