Linux安全网 - Linux操作系统_Linux 命令_Linux教程_Linux黑客

绿色网站无广告
会员投稿 投稿指南 本期推荐:
搜索:
您的位置: Linux安全网 > Linux集群 > Architecture > » 正文

14.hibernate 一对一component(组合),jpa映射

来源: xukongmoji 分享至:
只存在一个表:
husband表结构:

package com.bjsxt.hibernate; import javax.persistence.Embedded; import javax.persistence.Entity; import javax.persistence.GeneratedValue; import javax.persistence.Id; import javax.persistence.JoinColumn; import javax.persistence.JoinColumns; import javax.persistence.OneToOne; @Entity public class Husband { private int id; private String name; private Wife wife; @Id @GeneratedValue public int getId() { return id; } public String getName() { return name; } @Embedded public Wife getWife() { return wife; } public void setId(int id) { this.id = id; } public void setName(String name) { this.name = name; } public void setWife(Wife wife) { this.wife = wife; } }


package com.bjsxt.hibernate; public class Wife { private String wifeName; private int age; public int getAge() { return age; } public void setAge(int age) { this.age = age; } public String getWifeName() { return wifeName; } public void setWifeName(String name) { this.wifeName = name; } }
  • 大小: 2.4 KB
  • 查看图片附件

Tags:
分享至:
最新图文资讯
1 2 3 4 5 6
验证码:点击我更换图片 理智评论文明上网,拒绝恶意谩骂 用户名:
关于我们 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 发展历史