摘要: @Entity@Table(name="person_one")public class Person { private Integer id; private String name; private IDCard idcard; @OneToOne(cascade={CascadeType.ALL},optional=false) @JoinColumn(name="idcard_id") public IDCard getIdcard() { return idcard; } public void setIdcard(IDCard idcard 阅读全文
posted @ 2013-04-15 20:30 若 ♂ 只如初见 阅读(168) 评论(0) 推荐(0) 编辑
摘要: //省略了set方法/** * 关系维护端 */@Entity@Table(name="student_many")public class Student { private Integer id; private String name; private Set teacher = new HashSet(); public Student(){} public Student(String name) { super(); this.name = name; }//inverseJoinColumns 表示关联对方表主键,映射到中间表的字段为teacher_id @M 阅读全文
posted @ 2013-04-15 20:28 若 ♂ 只如初见 阅读(163) 评论(0) 推荐(0) 编辑
摘要: /** * 关系被维护端 * @author Administrator * */@Entity@Table(name="orders")public class Order { private String orderid; private Float amount; private Set orderitem=new HashSet(); @Id public String getOrderid() { return orderid; } @Column(nullable=false) public Float getAmount() { return amount; 阅读全文
posted @ 2013-04-15 20:24 若 ♂ 只如初见 阅读(244) 评论(0) 推荐(0) 编辑
摘要: import java.util.Date;import javax.persistence.Basic;import javax.persistence.Column;import javax.persistence.Entity;import javax.persistence.EnumType;import javax.persistence.Enumerated;import javax.persistence.FetchType;import javax.persistence.GeneratedValue;import javax.persistence.GenerationTyp 阅读全文
posted @ 2013-04-15 20:20 若 ♂ 只如初见 阅读(1634) 评论(0) 推荐(0) 编辑