Advertisement
Guest User

Untitled

a guest
Oct 5th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.62 KB | None | 0 0
  1. <session-factory>
  2.  
  3. <property name="connection.driver_class">com.mysql.jdbc.Driver</property>
  4.  
  5. <property name="connection.url">jdbc:mysql://localhost:3306/lapkiDB</property>
  6.  
  7. <property name="connection.username">root</property>
  8. <property name="connection.password">1769</property>
  9.  
  10. <property name="dialect">org.hibernate.dialect.MySQL55Dialect</property>
  11.  
  12. <property name="show_sql">true</property>
  13. <property name="format_sql">true</property>
  14. <property name="use_sql_comments">false</property>
  15.  
  16.  
  17. <property name="hbm2ddl.auto">update</property>
  18.  
  19.  
  20.  
  21.  
  22. <mapping class="entities.Animal"/>
  23. <mapping class="entities.Shelter"/>
  24. <mapping class="entities.AnimalBreed"/>
  25. <mapping class="entities.Type"/>
  26. <mapping class="entities.MetroStation"/>
  27. <mapping class="entities.City"/>
  28.  
  29.  
  30.  
  31. </session-factory>
  32.  
  33. @Entity
  34.  
  35. @Table(name = "animals")
  36. public class Animal {
  37.  
  38. @Id
  39. @GeneratedValue(strategy = GenerationType.IDENTITY)
  40. private int animal_id;
  41.  
  42. @Column(name = "name")
  43. private String name;
  44.  
  45. @ManyToOne(fetch = FetchType.LAZY)
  46. @JoinColumn(name = "type_id")
  47. private Type type;
  48.  
  49. @Column(name = "sex")
  50. private char sex;
  51.  
  52. @ManyToOne(fetch = FetchType.LAZY)
  53. @JoinColumn(name = "animalBreed_id")
  54. private AnimalBreed animalBreed;
  55.  
  56. @Column(name = "age")
  57. private int age;
  58.  
  59. @Column(name = "description")
  60. private String description;
  61.  
  62. @Column(name = "photos") // узнать про хранение фото
  63. private String photos;
  64.  
  65. @ManyToOne(fetch = FetchType.LAZY)
  66. @JoinColumn(name = "shelter_id")
  67. private Shelter shelter;
  68.  
  69. public Animal() {
  70. }
  71.  
  72. public Animal(String name, Type type, char sex, AnimalBreed animalBreed, int age, String description, String photos, Shelter shelter) {
  73. this.name = name;
  74. this.type = type;
  75. this.sex = sex;
  76. this.animalBreed = animalBreed;
  77. this.age = age;
  78. this.description = description;
  79. this.photos = photos;
  80. this.shelter = shelter;
  81. }
  82.  
  83. public int getAnimal_id() {
  84. return animal_id;
  85. }
  86.  
  87. public void setAnimal_id(int animal_id) {
  88. this.animal_id = animal_id;
  89. }
  90.  
  91. public String getName() {
  92. return name;
  93. }
  94.  
  95. public void setName(String name) {
  96. this.name = name;
  97. }
  98.  
  99. public Type getType() {
  100. return type;
  101. }
  102.  
  103. public void setType(Type type) {
  104. this.type = type;
  105. }
  106.  
  107. public char getSex() {
  108. return sex;
  109. }
  110.  
  111. public void setSex(char sex) {
  112. this.sex = sex;
  113. }
  114.  
  115. public AnimalBreed getAnimalBreed() {
  116. return animalBreed;
  117. }
  118.  
  119. public void setAnimalBreed(AnimalBreed animalBreed) {
  120. this.animalBreed = animalBreed;
  121. }
  122.  
  123. public int getAge() {
  124. return age;
  125. }
  126.  
  127. public void setAge(int age) {
  128. this.age = age;
  129. }
  130.  
  131. public String getDescription() {
  132. return description;
  133. }
  134.  
  135. public void setDescription(String description) {
  136. this.description = description;
  137. }
  138.  
  139. public String getPhotos() {
  140. return photos;
  141. }
  142.  
  143. public void setPhotos(String photos) {
  144. this.photos = photos;
  145. }
  146.  
  147. public Shelter getShelter() {
  148. return shelter;
  149. }
  150.  
  151. public void setShelter(Shelter shelter) {
  152. this.shelter = shelter;
  153. }
  154.  
  155. @Override
  156. public String toString() {
  157. return "Animal{" +
  158. "animal_id=" + animal_id +
  159. ", name='" + name + ''' +
  160. ", type=" + type +
  161. ", sex=" + sex +
  162. ", animalBreed=" + animalBreed +
  163. ", age=" + age +
  164. ", description='" + description + ''' +
  165. ", photos='" + photos + ''' +
  166. ", shelter=" + shelter +
  167. '}';
  168. }
  169.  
  170. @Entity
  171. @Table(name = "shelters")
  172. public class Shelter {
  173.  
  174.  
  175. @Id
  176. @GeneratedValue(strategy = GenerationType.IDENTITY)
  177. private int shelter_id;
  178.  
  179. @Column(name = "name")
  180. private String shelterName; // +
  181.  
  182. @ManyToOne(fetch = FetchType.LAZY)
  183. @JoinColumn(name = "city_id")
  184. private City city; // +
  185.  
  186. @Column(name = "adress")
  187. private String adress; // +
  188.  
  189. @ManyToOne(fetch = FetchType.LAZY)
  190. @JoinColumn(name = "metroStation_id")
  191. private MetroStation metroStation; // +
  192.  
  193. @Column(name = "phones")
  194. private String phones; // +
  195.  
  196. @Column(name = "webSite")
  197. private String webSite; // +
  198.  
  199. @OneToMany(fetch = FetchType.LAZY, mappedBy = "shelter")
  200. private Set<Animal> animals; // +
  201.  
  202. public Shelter() {
  203. }
  204.  
  205. public Shelter(String shelterName, City city, String adress, MetroStation metroStation, String phones, String webSite) {
  206. this.shelterName = shelterName;
  207. this.city = city;
  208. this.adress = adress;
  209. this.metroStation = metroStation;
  210. this.phones = phones;
  211. this.webSite = webSite;
  212. }
  213.  
  214. public int getShelter_id() {
  215. return shelter_id;
  216. }
  217.  
  218. public void setShelter_id(int shelter_id) {
  219. this.shelter_id = shelter_id;
  220. }
  221.  
  222. public String getShelterName() {
  223. return shelterName;
  224. }
  225.  
  226. public void setShelterName(String shelterName) {
  227. this.shelterName = shelterName;
  228. }
  229.  
  230. public City getCity() {
  231. return city;
  232. }
  233.  
  234. public void setCity(City city) {
  235. this.city = city;
  236. }
  237.  
  238. public String getAdress() {
  239. return adress;
  240. }
  241.  
  242. public void setAdress(String adress) {
  243. this.adress = adress;
  244. }
  245.  
  246. public MetroStation getMetroStation() {
  247. return metroStation;
  248. }
  249.  
  250. public void setMetroStation(MetroStation metroStation) {
  251. this.metroStation = metroStation;
  252. }
  253.  
  254. public String getPhones() {
  255. return phones;
  256. }
  257.  
  258. public void setPhones(String phones) {
  259. this.phones = phones;
  260. }
  261.  
  262. public String getWebSite() {
  263. return webSite;
  264. }
  265.  
  266. public void setWebSite(String webSite) {
  267. this.webSite = webSite;
  268. }
  269.  
  270. public Set<Animal> getAnimals() {
  271. return animals;
  272. }
  273.  
  274. public void setAnimals(Set<Animal> animals) {
  275. this.animals = animals;
  276. }
  277.  
  278. @Override
  279. public String toString() {
  280. return "Shelter{" +
  281. "shelter_id=" + shelter_id +
  282. ", shelterName='" + shelterName + ''' +
  283. ", city=" + city +
  284. ", adress='" + adress + ''' +
  285. ", metroStation=" + metroStation +
  286. ", phones='" + phones + ''' +
  287. ", webSite='" + webSite + ''' +
  288. '}';
  289. }
  290.  
  291. @Entity
  292. @Table(name = "types")
  293. public class Type {
  294.  
  295. @Id
  296. @GeneratedValue(strategy = GenerationType.IDENTITY)
  297. private int type_id;
  298.  
  299. @Column(name = "type")
  300. private String type;
  301.  
  302. @OneToMany(fetch = FetchType.LAZY, mappedBy = "type")
  303. private Set<AnimalBreed> animalBreeds;
  304.  
  305. @OneToMany(fetch = FetchType.LAZY, mappedBy = "type")
  306. private Set<Animal> animals;
  307.  
  308. public Type() {
  309. }
  310.  
  311. public Type(String type) {
  312. this.type = type;
  313. }
  314.  
  315. public int getType_id() {
  316. return type_id;
  317. }
  318.  
  319. public void setType_id(int type_id) {
  320. this.type_id = type_id;
  321. }
  322.  
  323. public String getType() {
  324. return type;
  325. }
  326.  
  327. public void setType(String type) {
  328. this.type = type;
  329. }
  330.  
  331. public Set<AnimalBreed> getAnimalBreeds() {
  332. return animalBreeds;
  333. }
  334.  
  335. public void setAnimalBreeds(Set<AnimalBreed> animalBreeds) {
  336. this.animalBreeds = animalBreeds;
  337. }
  338.  
  339. public Set<Animal> getAnimals() {
  340. return animals;
  341. }
  342.  
  343. public void setAnimals(Set<Animal> animals) {
  344. this.animals = animals;
  345. }
  346.  
  347. @Override
  348. public String toString() {
  349. return "Type{" +
  350. "type_id=" + type_id +
  351. ", type='" + type + ''' +
  352. '}';
  353. }
  354.  
  355. @Entity
  356. @Table(name = "AnimalBreed")
  357. public class AnimalBreed {
  358.  
  359.  
  360. @Id
  361. @GeneratedValue(strategy = GenerationType.IDENTITY)
  362. private int animalBreed_id;
  363.  
  364. @ManyToOne(fetch = FetchType.LAZY)
  365. @JoinColumn(name = "type_id")
  366. private Type type;
  367.  
  368. @Column(name = "AnimalBreedName") // внеш
  369. private String animalBreedName;
  370.  
  371. @OneToMany(fetch = FetchType.LAZY, mappedBy = "animalBreed")
  372. private Set<Animal> animals;
  373.  
  374. public AnimalBreed() {
  375. }
  376.  
  377. public AnimalBreed(Type type, String animalBreedName) {
  378. this.type = type;
  379. this.animalBreedName = animalBreedName;
  380. }
  381.  
  382. public int getAnimalBreed_id() {
  383. return animalBreed_id;
  384. }
  385.  
  386. public void setAnimalBreed_id(int animalBreed_id) {
  387. this.animalBreed_id = animalBreed_id;
  388. }
  389.  
  390. public Type getType() {
  391. return type;
  392. }
  393.  
  394. public void setType(Type type) {
  395. this.type = type;
  396. }
  397.  
  398. public String getAnimalBreedName() {
  399. return animalBreedName;
  400. }
  401.  
  402. public void setAnimalBreedName(String animalBreedName) {
  403. this.animalBreedName = animalBreedName;
  404. }
  405.  
  406. public Set<Animal> getAnimals() {
  407. return animals;
  408. }
  409.  
  410. public void setAnimals(Set<Animal> animals) {
  411. this.animals = animals;
  412. }
  413.  
  414. @Override
  415. public String toString() {
  416. return "AnimalBreed{" +
  417. "animalBreed_id=" + animalBreed_id +
  418. ", type=" + type +
  419. ", animalBreedName='" + animalBreedName + ''' +
  420. '}';
  421. }
  422.  
  423. @Entity
  424. @Table(name = "City")
  425. public class City {
  426.  
  427. @Id
  428. @GeneratedValue(strategy = GenerationType.IDENTITY)
  429. private int city_id;
  430.  
  431. @Column(name = "cityName")
  432. private String cityName;
  433.  
  434. @OneToMany(fetch = FetchType.LAZY, mappedBy = "city")
  435. private Set<MetroStation> metroStations;
  436.  
  437. @OneToMany(fetch = FetchType.LAZY, mappedBy = "city")
  438. private Set<Shelter> shelters;
  439.  
  440. public City() {
  441. }
  442.  
  443. public City(String cityName) {
  444. this.cityName = cityName;
  445. }
  446.  
  447. public int getCity_id() {
  448. return city_id;
  449. }
  450.  
  451. public void setCity_id(int city_id) {
  452. this.city_id = city_id;
  453. }
  454.  
  455. public String getCityName() {
  456. return cityName;
  457. }
  458.  
  459. public void setCityName(String cityName) {
  460. this.cityName = cityName;
  461. }
  462.  
  463. public Set<MetroStation> getMetroStations() {
  464. return metroStations;
  465. }
  466.  
  467. public void setMetroStations(Set<MetroStation> metroStations) {
  468. this.metroStations = metroStations;
  469. }
  470.  
  471. public Set<Shelter> getShelters() {
  472. return shelters;
  473. }
  474.  
  475. public void setShelters(Set<Shelter> shelters) {
  476. this.shelters = shelters;
  477. }
  478.  
  479. @Override
  480. public String toString() {
  481. return "City{" +
  482. "city_id=" + city_id +
  483. ", cityName='" + cityName + ''' +
  484. '}';
  485. }
  486.  
  487. @Entity
  488. @Table(name = "MetroStation")
  489. public class MetroStation {
  490.  
  491. @Id
  492. @GeneratedValue(strategy = GenerationType.IDENTITY)
  493. private int metroStation_id;
  494.  
  495. @Column(name = "metroStationName")
  496. private String metroStationName;
  497.  
  498. @ManyToOne(fetch = FetchType.LAZY)
  499. @JoinColumn(name = "city_id")
  500. private City city;
  501.  
  502. @OneToMany(fetch = FetchType.LAZY, mappedBy = "metroStation")
  503. private Set<Shelter> shelters;
  504.  
  505. public MetroStation() {
  506. }
  507.  
  508. public MetroStation(String metroStationName, City city) {
  509. this.metroStationName = metroStationName;
  510. this.city = city;
  511. }
  512.  
  513. public int getMetroStation_id() {
  514. return metroStation_id;
  515. }
  516.  
  517. public void setMetroStation_id(int metroStation_id) {
  518. this.metroStation_id = metroStation_id;
  519. }
  520.  
  521. public String getMetroStationName() {
  522. return metroStationName;
  523. }
  524.  
  525. public void setMetroStationName(String metroStationName) {
  526. this.metroStationName = metroStationName;
  527. }
  528.  
  529. public City getCity() {
  530. return city;
  531. }
  532.  
  533. public void setCity(City city) {
  534. this.city = city;
  535. }
  536.  
  537. public Set<Shelter> getShelters() {
  538. return shelters;
  539. }
  540.  
  541. public void setShelters(Set<Shelter> shelters) {
  542. this.shelters = shelters;
  543. }
  544.  
  545. @Override
  546. public String toString() {
  547. return "MetroStation{" +
  548. "metroStation_id=" + metroStation_id +
  549. ", metroStationName='" + metroStationName + ''' +
  550. ", city=" + city +
  551. '}';
  552. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement