Imagine the path:
Code:
entity1.entity2.entity3.entity4.entity5.attribute;
That means that entity1 has an object entity2.
Entity2 has an object entity3
(so on...)
entity5 has attribute "attribute".
I want to create an criteria to search for that "attribute" on "entity5". How should my criteria be:
Code:
criteria.createAlias("entity2.entity3","entity2.entity3");
criteria.createAlias("entity2.entity3.entity4","entity2.entity3.entity4");
criteria.createAlias("entity2.entity3.entity4.entity5","entity2.entity3.entity4.entity5");
criteria.add( Restrictions.like("entity2.entity3.entity4.entity5.attribute","mySearchString") );
or this only this works? :
Code:
criteria.createAlias("entity2.entity3.entity4.entity5","entity2.entity3.entity4.entity5");
criteria.add( Restrictions.like("entity2.entity3.entity4.entity5.attribute","mySearchString") );
PS: can I create an alias for the root entity?
Code:
criteria.createAlias("entity1","entity1");
//all other createAlias
I´m asking this, because I´m trying to create a generic filter using Criteria.
Thanks all!