开发者

cannot resolve property when criteria refers to a embedded property

I seem to be unable to create a query with a criterion which refers to a property inside a Embedded class. When i use "entity.embedded.property" it fails. If i create a开发者_如何学运维n alias of "entity.embedded.property" to itself the query works...Any tipes will be appreciated...


You could not directly access the properties of embedded object. You should create an alias for it instead. Like

Criteria crit = session.createCriteria(XYZ.class, "entity");
crit.setProjection(Projections.property("id"));
crit.createAlias("entity.embedded", "embeddedObj");
crit.add(Restrictions.eq("embeddedObj.property1", "propert1_value"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜