Hibernate Criteria query for inheritance type joined not working -


i have 3 classes following table per class strategy

@entity @table(name="parentclass") @inheritance(strategy=inheritancetype.joined)  public class parentobject {  @id  @generatedvalue(strategy=generationtype.identity)  @access(javax.persistence.accesstype.property)  protected int primary_key;   @manytomany(fetch=fetchtype.lazy, cascade=cascadetype.all)  @jointable(name="share_with_user", joincolumns={@joincolumn(name="primary_key")} , inversejoincolumns={@joincolumn(name="userseqid")})   @notfound(action=notfoundaction.ignore)  private set<user> sharedwithuser; }  @entity   @table public class user  {     @id     @generatedvalue(strategy=generationtype.identity)     private int userseqid;  -- other fields -- }  @entity   @indexed @table(name="childclass") @primarykeyjoincolumn(name="primary_key") public class childobject extends parentobject { -- other fields -- } 

now want retrieve childobject based on sharedwithuser containing userseqid

i tried writing criteria query looks this

criteria c = s.createcriteria(childobject.class); c.createalias("sharedwithuser", "share_user"); c.add(restrictions.eq("share_user.userseqid" , userid)) list<childobject> list = (list<childobject>) c.list(); 

i tried writing criteria query using alias

criteria c = s.createcriteria(childobject.class, "x"); c.createalias("x.sharedwithuser", "share_user"); c.add(restrictions.eq("share_user.userseqid" , userid)) list<childobject> list = (list<childobject>) c.list(); 

but result [] both cases

if move private set<user> sharedwithuser; parentobject childobject query works expected. question doing wrong. why not working if keep set of user entity in parent class since due inheritance can access it. appreciate.


Comments

Popular posts from this blog

javascript - Clear button on addentry page doesn't work -

c# - Selenium Authentication Popup preventing driver close or quit -

tensorflow when input_data MNIST_data , zlib.error: Error -3 while decompressing: invalid block type -