chapter 01

hibernate.cfg.xml


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

<hibernate-configuration>

<session-factory>

<!-- Database connection settings -->
<property name="connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="connection.url">jdbc:oracle:thin:@localhost:1521:orcl</property>
<property name="connection.username">system</property>
<property name="connection.password">orcl</property>

<!-- JDBC connection pool (use the built-in) -->
<property name="connection.pool_size">2</property>

<!-- SQL dialect -->
<property name="dialect">org.hibernate.dialect.Oracle9Dialect</property>

<!-- Echo all executed SQL to stdout -->
<property name="show_sql">true</property>

<property name="hbm2ddl.auto">create</property>

<property name="current_session_context_class">thread</property>

<mapping resource="com/demo/manyToMany/Project.hbm.xml"/>
<mapping resource="com/demo/manyToMany/Employee.hbm.xml"/>

</session-factory>

</hibernate-configuration>


package com.demo.manyToMany;

import java.util.HashSet;
import java.util.Set;

public class Employee {

public Employee(){}
public Employee(int id, String name, Set<Project> projects) {
super();
this.id = id;
this.name = name;
this.projects = projects;
}

private int id;
private String name;
private Set<Project> projects = new HashSet<Project>();

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Project> getProjects() {
return projects;
}
public void setProjects(Set<Project> projects) {
this.projects = projects;
}
}


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.demo.manyToMany">

<class name="Employee" table="Employee">
<id name="id">
<generator class="sequence">
<param name="sequence">seq_projectSys_employee</param>
</generator>
</id>
<property name="name"/>
<set name="projects" table="EmployeeProject" inverse="true">
<key column="employee_id" />
<many-to-many class="Project" column="project_id" />
</set>
</class>

</hibernate-mapping>


package com.demo.manyToMany;

import java.util.HashSet;
import java.util.Set;

public class Project {

public Project(){}
public Project(int id, String name, Set<Employee> employees) {
super();
this.id = id;
this.name = name;
this.employees = employees;
}
private int id;
private String name;
private Set<Employee> employees = new HashSet<Employee>();

public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Set<Employee> getEmployees() {
return employees;
}
public void setEmployees(Set<Employee> employees) {
this.employees = employees;
}

}


<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping
package="com.demo.manyToMany">

<class name="Project" table="Project">
<id name="id">
<generator class="sequence">
<param name="sequence">seq_projectSys_project</param>
</generator>
</id>
<property name="name"/>
<set name="employees" table="EmployeeProject">
<key column="project_id" />
<many-to-many class="Employee" column="employee_id" />
</set>
</class>

</hibernate-mapping>

chapter 01

时间: 2024-12-20 01:19:02

chapter 01的相关文章

[Learning You a Haskell for Great Goods!] chapter 01 starting out

Installation under CentOS/Fedora # yum install ghc Version [[email protected] haskell]# ghc -v Glasgow Haskell Compiler, Version 7.0.4, for Haskell 98, stage 2 booted by GHC version 7.0.4 Change prompt echo :set prompt "ghci> " > ~/.ghci C

Chapter 01:创建和销毁对象

<一>考虑用静态工厂方法代替构造器 下面是Boolean类的一个简单示例: public final class Boolean implements java.io.Serializable, Comparable<Boolean> { public static final Boolean TRUE = new Boolean(true); public static final Boolean FALSE = new Boolean(false); public static

CCJ PRML Study Note - Chapter 1.2 : Probability Theory

Chapter 1.2 : Probability Theory Chapter 1.2 : Probability Theory Christopher M. Bishop, PRML, Chapter 1 Introdcution Chapter 1.2 : Probability Theory 1. Uncertainty 2. Example discussed through this chapter 3. Basic Terminology 3.1 Probability densi

信息安全系统设计基础期中总结

Chapter 00 Linux基础 man命令调用手册页 man <command_name> 手册通常被分为8个区段,要查看相应区段的内容,就在 man 后面加上相应区段的数字即可: 1 一般命令 2 系统调用 3 库函数,涵盖了C标准函数库 4 特殊文件(通常是/dev中的设备)和驱动程序 5 文件格式和约定 6 游戏和屏保 7 杂项 8 系统管理命令和守护进程 man有一个-k 选项用起来非常好,这个选项让你学习命令.编程时有了一个搜索引擎,可以举一反三.结合后面学习的grep 命令和

SQL Server2012 T-SQL基础教程--读书笔记

SQL Server2012 T-SQL基础教程--读书笔记 SqlServer Chapter 01 T-SQL 查询和编程背景 1.3 创建表和定义数据的完整性 1.3.1 创建表 1.3.2 定义数据的完整性 1. 主键约束 2. 唯一约束 3. 外键束约 4. CHECK约束 5. 默认约束 Chapter 02 单表查询 2.1 SELECT 语句元素 2.1.7 TOP和OFFSET-FETCH 1. TOP筛选 2. OFFSET-FETCH 2.1.8 开窗函数速览 2.2 谓词

Oracle学习----管理一 (1)

今天遇到的知识: Oracle server 包括什么:Oracle instance和Oracle database Oracle instance 包括什么:SGA和background process Place the following structures in order of hierarchy beginning with database. a  Tablespaces b  Extent c  segment d  database e  Block 正确的顺序:d-->a

微软Code Hunt答案(00-05)——沉迷娱乐的我

昨天看到微软出的网游Code Hunt,导师也去北京开云计算会议了.o(∩_∩)o...哈哈,还不好好玩一吧,个人感觉不是一个模块比一个模块难的,Code Hunt是按功能划分.所以不要怕自己做不来,因为不同人特长不一样.像ACM都是分工合作的啦.废话不多,我们来总结一下前01-04的答案.希望对大家有帮助,纯属娱乐.还有很多可以优化的地方,欢迎一起来讨论! 注:语言C# 网页地址:https://www.codehunt.com/       chapter 00 00.02 using Sy

我喜欢减肥我们来减肥吧

http://www.ebay.com/cln/honus.jyw4mvptb/cars/158313278016/2015.01.28.html http://www.ebay.com/cln/honus.jyw4mvptb/cars/158313282016/2015.01.28.html http://www.ebay.com/cln/honus.jyw4mvptb/cars/158313289016/2015.01.28.html http://www.ebay.com/cln/usli

百度回家看沙发沙发是减肥了卡斯加积分卡拉是减肥

http://www.ebay.com/cln/hpryu-caw8ke/cars/158056866019/2015.01.31 http://www.ebay.com/cln/xub.50x2l7cj/cars/158445650015/2015.01.31 http://www.ebay.com/cln/xub.50x2l7cj/cars/158445674015/2015.01.31 http://www.ebay.com/cln/xub.50x2l7cj/cars/1584456790