日期:2014-05-17 浏览次数:20910 次
<!-- User -->
<class name="com.daojie.model.User" table="user">
<id name="id" column="id" type="java.lang.Integer">
<generator class="increment"></generator>
</id>
<property name="username" column="username" type="java.lang.String" />
<property name="password" column="password" type="java.lang.String" />
<list name="workRecord" inverse="false" cascade="all">
<key column="user_id" not-null="false"/>
<index column="record_index" />
<one-to-many class="com.daojie.model.WorkRecord"/>
</list>
</class>
<!-- WorkRecord -->
<class name="com.daojie.model.WorkRecord" table="workrecord">
<id name="id" type="java.lang.Integer">
<generator class="increment" />
</id>
<property name="type" type="string" />
<property name="dateTime" type="date" />
<property name="attachment" type="string" />
<property name="lat" type="double" />
<property name="lng" type="double" />
<property name="address" type="string" />
</class>
public class User {
private Integer id;
private String username;
private String password;
private List<WorkRecord> workRecord = new ArrayList<WorkRecord>();
...get set
}
public class WorkRecord {
private Integer id;
private Integer userId;
private String type;
private Date dateTime;
private String address;
private double lat;
private double lng;
private String attachment;
...get set
}
Hibernate:
select
user0_.id as id0_0_,
user0_.username as username0_0_,
user0_.password as password0_0_
from
user user0_
where
user0_.id=?
Hibernate:
insert
into
workrecord
(type, dateTime, attachment, lat, lng, address, id)
values
(?, ?, ?,