开发者

cannot resolve property when criteria refers to a embedded property

开发者 https://www.devze.com 2023-01-12 15:48 出处:网络
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 \"

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

精彩评论

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