from User u where u.profile.profileB.fieldB=特定关键字

解决方案 »

  1.   

    u.profile.profileB
    其中的profile是User的list成员变量的名称么?
    profileB是子类的名称么?
      

  2.   

    考虑你的需求,profileB可以作为profile的一个component,profileB是profile中的属性例如
    private ProfileB profileB = null;
    setter getter...profile在User中例如:
    private Set profile = new HashSet();
    setter getter...
      

  3.   

    profile中没有profileB这样的属性,仅是为了查询加上的话好像不太合适。
    我刚试了一种方法,好像可以,不过写的比较复杂,效率好像也不会高。
    from User u where exists (from ProfileB pb where pb.fieldB = 特定关键字 and pb in u.Profiles.elements)
    Profiles就是User中的list成员变量
      

  4.   

    不好意思,没有看到profileB是派生类,当然profileB不是为了查询才加上去的,而是一种面向设计的细分.如果是派生类的话,可以在profileB的配置文件中加入polymorphism="explicit",这样查询的时候
    用 u.profileB.fieldB=特定关键字
      

  5.   

    当然了多态在hibernate3里面作用不大,可以将属性lazy