1.用的是注解方式
2.查询时使用hql left join fetch语句
3.当调用getChildren()方法时hibernate又生成sql查询一遍请问怎么样可以不让hibernate自动查子类

解决方案 »

  1.   

    <set name="aaSet" lazy="true" inverse="true"  
            cascade="all-delete-orphan">  
        <key column="A_ID" not-null="true" />  
        <one-to-many class="AA" />  
    </set>  
    cascade这个参数给改成false就行了,如果没有的话你就给填上
     cascade="false"
     
      

  2.   

    采用hql查询,或者使用cascade="false"配置
      

  3.   

    您好,
    项目是用注解方式配置的hibernate,
    现在是这样配置的,请问要怎么改
    @OneToMany(targetEntity=CatalogTree.class,cascade=CascadeType.REMOVE)
    @Fetch(FetchMode.JOIN)
    @JoinColumn(name="parentid",updatable=false)
    private Set<CatalogTree> children = new TreeSet<CatalogTree>(new Comparator<CatalogTree>() 
      

  4.   

    看这个,cascade属性不要写试试,让其保持默认cascade
    public abstract CascadeType[] cascade(Optional) The operations that must be cascaded to the target of the association. 
    Defaults to no operations being cascaded. 
    Default:
    {}