Hibernate多对一单向关联

1. *.hbm.xml中配置
        <many-to-one name="user" entity-name="User"  fetch="select" not-found="ignore" lazy="false">
            <column name="PRINCAIPAL_USER_OBJ_ID">
                <comment>负责人</comment>
            </column>
        </many-to-one>

2. entity-name对应User.hbm.xml定义的entity-name(如果USER映射中没有entity-name,那么上面关系中的entity-name换成class=“路径+类名”)
<class name="xxx.User" entity-name="User" table="USER">
    	<cache usage="nonstrict-read-write" include="all" />


3. 单向关联所以user.hbm.xml中不用配置

4. pojo类中加入属性 private User user = new User();
private User user = new User();

你可能感兴趣的:(java,xml,Hibernate)