spring data jpa 懒加载 处理

在做junit 测试的时候 老是出现 no session
在persistence.xml 里加入 最后一行

    
<persistence-unit name="myJPA" transaction-type="RESOURCE_LOCAL">
    <provider>org.hibernate.ejb.HibernatePersistence</provider>  
        <properties>
            <property name="hibernate.max_fetch_depth" value="3" />
            <property name="hibernate.hbm2ddl.auto" value="update" />    
            <property name="hibernate.show_sql" value="false" />
            <property name="hibernate.format_sql" value="true" />
            <property name="javax.persistence.validation.mode" value="none"/>
            <property name="hibernate.enable_lazy_load_no_trans" value="true"/>
        </properties>
</persistence-unit>

        


你可能感兴趣的:(java,spring,jpa,JUnit,懒加载)