Hibernate: FetchMode and org.hibernate.QueryException: duplicate association path: -


  • userfulltest has collection of associatedtestcontentelementresponses

  • each testcontentelementresponse in turn has collection of associatedresponseattributes

i want pull data in single fetch.

here code:

        session session = this.sessionfactory.getcurrentsession();         criteria c=session.createcriteria(userfulltest.class);         c.createalias("associatedtestcontentelementresponses", "tcer");         c.setfetchmode("tcer", fetchmode.join);          c.add(restrictions.ideq(uftid));         criteria cra=c.createcriteria("tcer.associatedresponseattributes");         cra.createalias("tcer.associatedresponseattributes", "ra");         cra.setfetchmode("ra", fetchmode.join);         list<userfulltest> uftlist = c.list(); 

i following exception:

org.hibernate.queryexception: duplicate association path: associatedtestcontentelementresponses.associatedresponseattributes

any tips appreciated

i should explain... if don't specify subcriteria fetchmode uses select mode. trying single fetch including sub criteria. know exact size of data pull know single fetch best practice here

the way creating criteria need changed follows.

    session session = this.sessionfactory.getcurrentsession();     criteria c=session.createcriteria(userfulltest.class).createcriteria("tcer.associatedresponseattributes");     c.createalias("associatedtestcontentelementresponses", "tcer");     c.setfetchmode("tcer", fetchmode.join);      c.add(restrictions.ideq(uftid));      c.createalias("tcer.associatedresponseattributes", "ra");     c.setfetchmode("ra", fetchmode.join);     list<userfulltest> uftlist = c.list(); 

Comments

Popular posts from this blog

php - mysql multiple keyword search in any order -

routing - AngularJS State management ->load multiple states in one page -

unity3d - Problems porting a GLSL shadertoy shader to unity -