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 an 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"));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With