命令行模式添加或修改多个ip地址
2013-05-17 10:56
246 查看
如果下面部分内容有不明白的可以查找:
基于Annotation的关系映射 前期准备:http://blog.csdn.net/p_3er/article/details/9061911
基于xml的多对一:http://blog.csdn.net/p_3er/article/details/9036759
基于xml的一对多:http://blog.csdn.net/p_3er/article/details/9036921
本文是把多对一与一对多结合起来了,形成一个双向的映射。如果只想要单向的话,把别外一边的注解去掉就是了。
Department:
Employee:
基于Annotation的关系映射 前期准备:http://blog.csdn.net/p_3er/article/details/9061911
基于xml的多对一:http://blog.csdn.net/p_3er/article/details/9036759
基于xml的一对多:http://blog.csdn.net/p_3er/article/details/9036921
本文是把多对一与一对多结合起来了,形成一个双向的映射。如果只想要单向的话,把别外一边的注解去掉就是了。
Department:
@Entity @Table(name = "department", catalog = "hibernate") public class Department implements java.io.Serializable { private Integer id; private String name; private Set<Employee> employees = new HashSet<Employee>(0); public Department() { } public Department(String name, Set<Employee> employees) { this.name = name; this.employees = employees; } @Id @GeneratedValue @Column(name = "id", unique = true, nullable = false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @Column(name = "name", nullable = false, length = 45) public String getName() { return this.name; } public void setName(String name) { this.name = name; } @OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "department") /* 一对多。 department和employee的一对多关系中,当指定department中的mappedBy后,关系只能被employee来主动维护.也就是employee级联的处理department. 之前的映射文件: <set name="employees" inverse="false" cascade="all"> <key column="department_id"></key> <one-to-many class="cn.framelife.hibernate.entity.Employee"/> </set> */ public Set<Employee> getEmployees() { return this.employees; } public void setEmployees(Set<Employee> employees) { this.employees = employees; } }
Employee:
@Entity @Table(name = "employee", catalog = "hibernate") public class Employee implements java.io.Serializable { private Integer id; private Department department; private String name; public Employee() { } @Id @GeneratedValue @Column(name = "id", unique = true, nullable = false) public Integer getId() { return this.id; } public void setId(Integer id) { this.id = id; } @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "department_id") /* 多对一。 <many-to-one name="department" column="department_id"></many-to-one> */ public Department getDepartment() { return this.department; } public void setDepartment(Department department) { this.department = department; } @Column(name = "name", nullable = false, length = 45) public String getName() { return this.name; } public void setName(String name) { this.name = name; } }
相关文章推荐
- MySql cmd 命令行模式操作数据库 添加查询 修改 删除 ( 表 字段 数据)
- cmd 命令行模式操作数据库 添加查询 修改 删除 ( 表 字段 数据)
- MYSQL添加新用户和数据库(命令行模式和phpmyadmin)
- CentOS(RedHat)命令行永久修改IP地址、网关、DNS
- Windows 如何在cmd命令行中查看、修改、删除与添加环境变量
- 稳扎稳打Silverlight(58) - 4.0通信之WCF RIA Services: 通过 Domain Service, 以 MVVM 模式实现数据的添加、删除、修改和查询
- 修改为支持多个层拖动模式可以制作为[许愿墙]
- 使用navicat的命令行模式创建修改表和存储过程
- VM虚拟机中的centos6.3命令行模式添加GCC
- 轻松学习Ionic (四) 修改应用图标及添加启动画面(更新官方命令行工具自动生成)
- CentOS(RedHat)命令行永久修改IP地址、网关、DNS
- 如何在cmd命令行中查看、修改、删除与添加环境变量
- centos7命令行与图形界面启动模式修改
- 稳扎稳打Silverlight(58) - 4.0通信之WCF RIA Services: 通过 Domain Service, 以 MVVM 模式实现数据的添加、删除、修改和查询
- windows下sc create命令行添加/创建/修改服务
- 命令行模式下修改linux分辨率的快捷方法
- CentOS命令行修改IP地址
- 在命令行修改IP地址
- Editor中添加脚本,自动修改动画模式Legacy模式
- 修改Linux文本(命令行)模式的分辨率