hibernate - Querying through JPA -
i have question in fetching data through jpa,
lets have entity , entity having onetoone relationship onetomany other related entities.
is there api in hibernate or jpa in if set few values entity class , related entity class , list of entity class matching values.
eg:
entity e = new entity(); e.setvar1("test1"); e.setvar2("test2"); siblingentity se = new siblingentity(); // onetoone entity class se.setvar1("var1"); e.setsiblingentity(se); childentity ce = new childentity(); // onetomany entity class ce.setvar1("value1"); e.getchildentities().add(ce);
now have root entity e sibling entity , child entity.
is there api give me following result? 1 mentioned below:
list elist = entitydao.getentitylist(e);
elist has contain list of entity class satisfies conditions mentioned above.
thanks
you want kind of query example, don't know framework capable jpa, jql can expressed quite straightforward assignments:
entitymanager.createquery( "select e entity e e.var1 = 'test1' , e.var2 = 'test2' , e.siblingentity.var1 = 'var1' , e.childentity.var1 = 'value1'").getresultlist();
should deliver want, if entity relations defined correctly.
searching qbe , jpa found following link:
perhaps according intentions.
Comments
Post a Comment