Hibernate 一对一与多对一之间的差异,唯一=真

Hibernate 一对一与多对一之间的差异,唯一=真,hibernate,mapping,hibernate-mapping,one-to-one,associative,Hibernate,Mapping,Hibernate Mapping,One To One,Associative,hbm文件中的两个标记如何在unique=true时一对一和多对一不同? 我刚刚了解到,要获得双向一对一映射,我需要在两个hbm文件上都使用一对一标记。我不能在两侧都使用unique=true的多对一来获得hibernate中的双向行为吗 在这里,我发现 <!-- In One-to-one we cannot specify the foreign key column that has to be filled up <one-to-one n

hbm文件中的两个标记如何在unique=true时一对一和多对一不同? 我刚刚了解到,要获得双向一对一映射,我需要在两个hbm文件上都使用一对一标记。我不能在两侧都使用unique=true的多对一来获得hibernate中的双向行为吗

在这里,我发现

<!-- In One-to-one we cannot specify the foreign key column 
         that has to be filled up
        <one-to-one name="person" class="PersonOTO_B" cascade="all"
        constrained="true"> </one-to-one>
    -->

    <many-to-one name="person" column="P_ID" unique="true"
        not-null="true" lazy="false" />
上述理由有效吗

问候 当应用程序启动时,如果不使用Hibernate生成SQL模式,那么Jayendra

unique=true没有任何意义。Hibernate不强制值的唯一性,这是一个纯数据库函数

如果使用Hibernate生成数据库架构,则它会对设置为Unique=true的任何属性放置唯一约束,但如果将Hibernate指向已存在的数据库,并且仅验证该数据库的架构,Hibernate将不会检查唯一约束是否存在

这适用于的其他属性是我头顶上的可插入、可更新和可空

如果你想知道如何在Hibernate中创建不同类型的关系,我写了一个方便的指南,你可以找到。只需将我拥有的注释示例翻译到您的.cfg文件中,或者只需使用注释,您就可以进行设置