Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Collections;
- import java.util.ArrayList;
- public class Man
- {
- int id;
- String name;
- ArrayList<Car> cars;
- 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 ArrayList<Car> getCars() {
- return cars;
- }
- public void setCars(ArrayList<Car> cars) {
- this.cars = cars;
- }
- }
- package Collections;
- public class Car
- {
- int len;
- int width;
- String model;
- int id;
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public int getLen() {
- return len;
- }
- public void setLen(int len) {
- this.len = len;
- }
- public int getWidth() {
- return width;
- }
- public void setWidth(int width) {
- this.width = width;
- }
- public String getModel() {
- return model;
- }
- public void setModel(String model) {
- this.model = model;
- }
- }
- <?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>
- <class name="Collections.Man" table="emp.man">
- <id name="id">
- <generator class="increment"></generator>
- </id>
- <property name="name"></property>
- <list name="cars" table="emp.cars">
- <key column="id"></key>
- <index column="index"></index>
- <one-to-many class="Collections.Car"></one-to-many>
- </list>
- </class>
- <class name="Collections.Car" table="emp.car">
- <id name="id">
- <generator class="increment"></generator>
- </id>
- <property name="len"></property>
- <property name="width"></property>
- </class>
- </hibernate-mapping>
- <?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>
- <property name="hibernate.hbm2ddl.auto">create</property>
- <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
- <property name="hibernate.connection.url">jdbc:mysql://localhost:3306?createDatabaseIfNotExist=true</property>
- <property name="hibernate.connection.username">root</property>
- <property name="hibernate.connection.password">root</property>
- <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
- <mapping resource="Man.hbm.xml"></mapping>
- </session-factory>
- </hibernate-configuration>
Add Comment
Please, Sign In to add comment