Guest User

Untitled

a guest
Feb 25th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.77 KB | None | 0 0
  1. package Collections;
  2.  
  3. import java.util.ArrayList;
  4.  
  5. public class Man
  6. {
  7. int id;
  8. String name;
  9. ArrayList<Car> cars;
  10. public int getId() {
  11. return id;
  12. }
  13. public void setId(int id) {
  14. this.id = id;
  15. }
  16. public String getName() {
  17. return name;
  18. }
  19. public void setName(String name) {
  20. this.name = name;
  21. }
  22. public ArrayList<Car> getCars() {
  23. return cars;
  24. }
  25. public void setCars(ArrayList<Car> cars) {
  26. this.cars = cars;
  27. }
  28.  
  29.  
  30. }
  31.  
  32.  
  33. package Collections;
  34.  
  35. public class Car
  36. {
  37. int len;
  38. int width;
  39. String model;
  40. int id;
  41.  
  42. public int getId() {
  43. return id;
  44. }
  45. public void setId(int id) {
  46. this.id = id;
  47. }
  48. public int getLen() {
  49. return len;
  50. }
  51. public void setLen(int len) {
  52. this.len = len;
  53. }
  54. public int getWidth() {
  55. return width;
  56. }
  57. public void setWidth(int width) {
  58. this.width = width;
  59. }
  60. public String getModel() {
  61. return model;
  62. }
  63. public void setModel(String model) {
  64. this.model = model;
  65. }
  66.  
  67.  
  68. }
  69.  
  70. <?xml version="1.0" encoding="UTF-8"?>
  71. <!DOCTYPE hibernate-mapping PUBLIC
  72. "-//Hibernate/Hibernate Mapping DTD 3.0//EN"
  73. "http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
  74. <hibernate-mapping>
  75. <class name="Collections.Man" table="emp.man">
  76. <id name="id">
  77. <generator class="increment"></generator>
  78. </id>
  79. <property name="name"></property>
  80. <list name="cars" table="emp.cars">
  81. <key column="id"></key>
  82. <index column="index"></index>
  83. <one-to-many class="Collections.Car"></one-to-many>
  84. </list>
  85. </class>
  86. <class name="Collections.Car" table="emp.car">
  87. <id name="id">
  88. <generator class="increment"></generator>
  89. </id>
  90. <property name="len"></property>
  91. <property name="width"></property>
  92. </class>
  93. </hibernate-mapping>
  94.  
  95. <?xml version='1.0' encoding='UTF-8'?>
  96. <!DOCTYPE hibernate-configuration PUBLIC
  97. "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
  98. "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
  99.  
  100. <hibernate-configuration>
  101.  
  102. <session-factory>
  103. <property name="hibernate.hbm2ddl.auto">create</property>
  104. <property name="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</property>
  105. <property name="hibernate.connection.url">jdbc:mysql://localhost:3306?createDatabaseIfNotExist=true</property>
  106. <property name="hibernate.connection.username">root</property>
  107. <property name="hibernate.connection.password">root</property>
  108. <property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
  109.  
  110. <mapping resource="Man.hbm.xml"></mapping>
  111. </session-factory>
  112.  
  113. </hibernate-configuration>
Add Comment
Please, Sign In to add comment