Posted on 2009-04-15 23:11
hanwei 阅读(66)
评论(0) 编辑 收藏
/**
*
* @author Administrator
* @hibernate.class table="T_Person"
*/
public class Person {
/**
* @hibernate.id
* generator-class="native"
*/
private int id;
/**
* @hibernate.property
*/
private String name;
/**
* @hibernate.property
*/
private String sex;
/**
* @hibernate.property
*/
private int age;
/**
* @hibernate.property
*/
private String address;
/**
* @hibernate.property
*/
private String duty;
/**
* @hibernate.property
*/
private String phone;
/**
* @hibernate.many-to-one
*/
private Organization org;
/**
* @hibernate.one-to-one property-ref="person"
*/
private User user;
***************************************************************************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="T_Person" name="com.bjsxt.oa.model.Person">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<property name="sex"/>
<property name="age"/>
<property name="address"/>
<property name="duty"/>
<property name="phone"/>
<many-to-one name="org"/>
<one-to-one name="user" property-ref="person"/>
</class>
</hibernate-mapping>
***************************************************************************************************
/**
*
* @author Administrator
* @hibernate.class table="T_User"
*/
public class User {
/**
* @hibernate.id
* generator-class="native"
*/
private int id;
/**
* @hibernate.property
* unique="true"
* not-null="true"
*/
private String username;
/**
* @hibernate.property
* not-null="true"
*/
private String password;
/**
* @hibernate.property
*/
private Date createTime;
/**
* @hibernate.property
*/
private Date expireTime;
/**
* @hibernate.many-to-one unique="true"
*/
private Person person;
********************************************************************************
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD 3.0//EN" "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class table="T_User" name="com.bjsxt.oa.model.User">
<id name="id">
<generator class="native"/>
</id>
<property name="username" not-null="true" unique="true"/>
<property name="password" not-null="true"/>
<property name="createTime"/>
<property name="expireTime"/>
<many-to-one unique="true" name="person"/>
</class>
</hibernate-mapping>
*******************************************************************************************