class A{
  
   private String id;   public getId...(){...}
   public setId...(){...}}class B{   private String id;
   
   private A a;   public getId....(){....}
   public setId....(){....}   public getA....(){.....}
   public setA....(){.....}}
问题:查询B的实体集合  hql="from B"
     查询条件等A的,所有B集合  hql="from B b where a.id=?"  这样写法是错误的有没有更简便的hql写法解决? jdbc就不用说了

解决方案 »

  1.   

    hql="from B b where b.a.id=?" 
      

  2.   

    映射文件 写好,还有报了什么错 最好 贴出来啊 
    hql="from B b where b.a.id=?"
      

  3.   

    String sql="from QcBatchAssignEntity qcb where qcb.id='"+qid+"'";
    QcBatchAssignEntity entity=(QcBatchAssignEntity)getHibernateTemplate().find(sql).get(0);
    hql="from QcRoleAssignEntity qc where qc.qcAssignEntity="+entity;
    List<QcRoleAssignEntity> list=getHibernateTemplate().find(hql);现在这样操作也不行,错误提示:
    org.springframework.dao.InvalidDataAccessResourceUsageException: could not execute query; nested exception is org.hibernate.exception.DataException: could not execute query
      

  4.   

    <many-to-one name="qcAssignEntity"
    class="com.flex.cc.qc.batchassign.entity.QcBatchAssignEntity"
    column="ASSIGN_ID" update="false" insert="true" 
    outer-join="true" lazy="false" >
    </many-to-one>这是xml配置,,请朋友们
    帮我看看
      

  5.   

    你得设级联 才能用hql="from B b where b.a.id=?"  
    这种方法查你的hql语句不对,配置也不对