Created
July 24, 2012 01:54
-
-
Save pengju/3167466 to your computer and use it in GitHub Desktop.
hibernate中一对一关系,互存对方主键为外键的映射文件
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE hibernate-mapping PUBLIC | |
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | |
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | |
<hibernate-mapping package="com.kaishengit.pojo"> | |
<class name="Card" table="t_card"> | |
<id name="id" column="id"> | |
<generator class="native"></generator> | |
</id> | |
<property name="cardnum" column="cardnum"></property> | |
<!-- | |
name : 在类中一这一端的对象的属性名 | |
class : name的类型(要和package拼成一个类的完全限定名) | |
column : 外键 | |
--> | |
<many-to-one name="user" class="User" column="user_id" unique="true"></many-to-one> | |
</class> | |
</hibernate-mapping> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE hibernate-mapping PUBLIC | |
"-//Hibernate/Hibernate Mapping DTD 3.0//EN" | |
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> | |
<hibernate-mapping package="com.kaishengit.pojo"> | |
<class name="User" table="t_user"> | |
<id name="id" column="user_id"> | |
<generator class="native"></generator> | |
</id> | |
<property name="name" column="user_name"></property> | |
<property name="password" column="user_password"></property> | |
<many-to-one name="card" class="Card" column="card_id" unique="true"></many-to-one> | |
</class> | |
</hibernate-mapping> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment