SHARE
TWEET

Untitled

a guest Apr 21st, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package by.specific.entity;
  2.  
  3. import javax.persistence.*;
  4.  
  5. @Entity
  6. @Table(name = "estate", schema = "courseProject", catalog = "")
  7. public class EstateEntity {
  8.     private int id;
  9.     private String loginIndef;
  10.     private String price;
  11.     private String floor;
  12.     private Integer roomCount;
  13.     private Integer area;
  14.     private String other;
  15.     private String urlPicture;
  16.     private String typeEstate;
  17.     private String country;
  18.     private String name;
  19.     private UserEntity userByLoginIndef;
  20.  
  21.     @Id
  22.     @Column(name = "id", nullable = false)
  23.     public int getId() {
  24.         return id;
  25.     }
  26.  
  27.     public void setId(int id) {
  28.         this.id = id;
  29.     }
  30.  
  31.     @Basic
  32.     @Column(name = "loginIndef", nullable = false, length = 255)
  33.     public String getLoginIndef() {
  34.         return loginIndef;
  35.     }
  36.  
  37.     public void setLoginIndef(String loginIndef) {
  38.         this.loginIndef = loginIndef;
  39.     }
  40.  
  41.     @Basic
  42.     @Column(name = "price", nullable = false, length = 255)
  43.     public String getPrice() {
  44.         return price;
  45.     }
  46.  
  47.     public void setPrice(String price) {
  48.         this.price = price;
  49.     }
  50.  
  51.     @Basic
  52.     @Column(name = "floor", nullable = true, length = 45)
  53.     public String getFloor() {
  54.         return floor;
  55.     }
  56.  
  57.     public void setFloor(String floor) {
  58.         this.floor = floor;
  59.     }
  60.  
  61.     @Basic
  62.     @Column(name = "roomCount", nullable = true)
  63.     public Integer getRoomCount() {
  64.         return roomCount;
  65.     }
  66.  
  67.     public void setRoomCount(Integer roomCount) {
  68.         this.roomCount = roomCount;
  69.     }
  70.  
  71.     @Basic
  72.     @Column(name = "area", nullable = true)
  73.     public Integer getArea() {
  74.         return area;
  75.     }
  76.  
  77.     public void setArea(Integer area) {
  78.         this.area = area;
  79.     }
  80.  
  81.     @Basic
  82.     @Column(name = "other", nullable = true, length = 1800)
  83.     public String getOther() {
  84.         return other;
  85.     }
  86.  
  87.     public void setOther(String other) {
  88.         this.other = other;
  89.     }
  90.  
  91.     @Basic
  92.     @Column(name = "urlPicture", nullable = true, length = 450)
  93.     public String getUrlPicture() {
  94.         return urlPicture;
  95.     }
  96.  
  97.     public void setUrlPicture(String urlPicture) {
  98.         this.urlPicture = urlPicture;
  99.     }
  100.  
  101.     @Basic
  102.     @Column(name = "typeEstate", nullable = false, length = 45)
  103.     public String getTypeEstate() {
  104.         return typeEstate;
  105.     }
  106.  
  107.     public void setTypeEstate(String typeEstate) {
  108.         this.typeEstate = typeEstate;
  109.     }
  110.  
  111.     @Basic
  112.     @Column(name = "country", nullable = false, length = 45)
  113.     public String getCountry() {
  114.         return country;
  115.     }
  116.  
  117.     public void setCountry(String country) {
  118.         this.country = country;
  119.     }
  120.  
  121.     @Basic
  122.     @Column(name = "name", nullable = true, length = 256)
  123.     public String getName() {
  124.         return name;
  125.     }
  126.  
  127.     public void setName(String name) {
  128.         this.name = name;
  129.     }
  130.  
  131.     @Override
  132.     public boolean equals(Object o) {
  133.         if (this == o) return true;
  134.         if (o == null || getClass() != o.getClass()) return false;
  135.  
  136.         EstateEntity that = (EstateEntity) o;
  137.  
  138.         if (id != that.id) return false;
  139.         if (loginIndef != null ? !loginIndef.equals(that.loginIndef) : that.loginIndef != null) return false;
  140.         if (price != null ? !price.equals(that.price) : that.price != null) return false;
  141.         if (floor != null ? !floor.equals(that.floor) : that.floor != null) return false;
  142.         if (roomCount != null ? !roomCount.equals(that.roomCount) : that.roomCount != null) return false;
  143.         if (area != null ? !area.equals(that.area) : that.area != null) return false;
  144.         if (other != null ? !other.equals(that.other) : that.other != null) return false;
  145.         if (urlPicture != null ? !urlPicture.equals(that.urlPicture) : that.urlPicture != null) return false;
  146.         if (typeEstate != null ? !typeEstate.equals(that.typeEstate) : that.typeEstate != null) return false;
  147.         if (country != null ? !country.equals(that.country) : that.country != null) return false;
  148.         if (name != null ? !name.equals(that.name) : that.name != null) return false;
  149.  
  150.         return true;
  151.     }
  152.  
  153.     @Override
  154.     public int hashCode() {
  155.         int result = id;
  156.         result = 31 * result + (loginIndef != null ? loginIndef.hashCode() : 0);
  157.         result = 31 * result + (price != null ? price.hashCode() : 0);
  158.         result = 31 * result + (floor != null ? floor.hashCode() : 0);
  159.         result = 31 * result + (roomCount != null ? roomCount.hashCode() : 0);
  160.         result = 31 * result + (area != null ? area.hashCode() : 0);
  161.         result = 31 * result + (other != null ? other.hashCode() : 0);
  162.         result = 31 * result + (urlPicture != null ? urlPicture.hashCode() : 0);
  163.         result = 31 * result + (typeEstate != null ? typeEstate.hashCode() : 0);
  164.         result = 31 * result + (country != null ? country.hashCode() : 0);
  165.         result = 31 * result + (name != null ? name.hashCode() : 0);
  166.         return result;
  167.     }
  168.  
  169.     @ManyToOne
  170.     @JoinColumn(name = "loginIndef", referencedColumnName = "login", nullable = false)
  171.     public UserEntity getUserByLoginIndef() {
  172.         return userByLoginIndef;
  173.     }
  174.  
  175.     public void setUserByLoginIndef(UserEntity userByLoginIndef) {
  176.         this.userByLoginIndef = userByLoginIndef;
  177.     }
  178. }
  179.    
  180. package by.specific.entity;
  181.  
  182. import javax.persistence.*;
  183. import java.util.Collection;
  184.  
  185. @Entity
  186. @Table(name = "user", schema = "courseProject", catalog = "")
  187. public class UserEntity {
  188.     private String login;
  189.     private String password;
  190.     private String email;
  191.     private String role;
  192.     private String bonus;
  193.     private Collection<EstateEntity> estatesByLogin;
  194.  
  195.     @Id
  196.     @Column(name = "login", nullable = false, length = 255)
  197.     public String getLogin() {
  198.         return login;
  199.     }
  200.  
  201.     public void setLogin(String login) {
  202.         this.login = login;
  203.     }
  204.  
  205.     @Basic
  206.     @Column(name = "password", nullable = false, length = 255)
  207.     public String getPassword() {
  208.         return password;
  209.     }
  210.  
  211.     public void setPassword(String password) {
  212.         this.password = password;
  213.     }
  214.  
  215.     @Basic
  216.     @Column(name = "email", nullable = false, length = 45)
  217.     public String getEmail() {
  218.         return email;
  219.     }
  220.  
  221.     public void setEmail(String email) {
  222.         this.email = email;
  223.     }
  224.  
  225.     @Basic
  226.     @Column(name = "role", nullable = false, length = 45)
  227.     public String getRole() {
  228.         return role;
  229.     }
  230.  
  231.     public void setRole(String role) {
  232.         this.role = role;
  233.     }
  234.  
  235.     @Basic
  236.     @Column(name = "bonus", nullable = true, length = 45)
  237.     public String getBonus() {
  238.         return bonus;
  239.     }
  240.  
  241.     public void setBonus(String bonus) {
  242.         this.bonus = bonus;
  243.     }
  244.  
  245.     @Override
  246.     public boolean equals(Object o) {
  247.         if (this == o) return true;
  248.         if (o == null || getClass() != o.getClass()) return false;
  249.  
  250.         UserEntity that = (UserEntity) o;
  251.  
  252.         if (login != null ? !login.equals(that.login) : that.login != null) return false;
  253.         if (password != null ? !password.equals(that.password) : that.password != null) return false;
  254.         if (email != null ? !email.equals(that.email) : that.email != null) return false;
  255.         if (role != null ? !role.equals(that.role) : that.role != null) return false;
  256.         if (bonus != null ? !bonus.equals(that.bonus) : that.bonus != null) return false;
  257.  
  258.         return true;
  259.     }
  260.  
  261.     @Override
  262.     public int hashCode() {
  263.         int result = login != null ? login.hashCode() : 0;
  264.         result = 31 * result + (password != null ? password.hashCode() : 0);
  265.         result = 31 * result + (email != null ? email.hashCode() : 0);
  266.         result = 31 * result + (role != null ? role.hashCode() : 0);
  267.         result = 31 * result + (bonus != null ? bonus.hashCode() : 0);
  268.         return result;
  269.     }
  270.  
  271.     @OneToMany(mappedBy = "userByLoginIndef")
  272.     public Collection<EstateEntity> getEstatesByLogin() {
  273.         return estatesByLogin;
  274.     }
  275.  
  276.     public void setEstatesByLogin(Collection<EstateEntity> estatesByLogin) {
  277.         this.estatesByLogin = estatesByLogin;
  278.     }
  279. }
  280.    
  281. <beans xmlns="http://www.springframework.org/schema/beans"
  282.        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  283.        xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx"
  284.        xmlns:mvc="http://www.springframework.org/schema/mvc"
  285.        xsi:schemaLocation="http://www.springframework.org/schema/beans
  286.         http://www.springframework.org/schema/beans/spring-beans.xsd
  287.         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
  288.  
  289.     <context:component-scan base-package="by.specific"/>
  290.  
  291.     <bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  292.         <property name="prefix" value="/WEB-INF/pages/"/>
  293.         <property name="suffix" value=".jsp"/>
  294.     </bean>
  295.  
  296.     <!-- Database Information -->
  297.     <bean id="dataSource" class="org.apache.commons.dbcp.BasicDataSource"
  298.           destroy-method="close">
  299.         <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
  300.         <property name="url"
  301.                   value="jdbc:mysql://localhost:3306/courseProject"/>
  302.         <property name="username" value="root"/>
  303.         <property name="password" value="Liz54387621"/>
  304.     </bean>
  305.  
  306.     <!-- Hibernate 4 SessionFactory Bean definition -->
  307.     <bean id="hibernate4AnnotatedSessionFactory"
  308.           class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
  309.         <property name="dataSource" ref="dataSource"/>
  310.         <property name="annotatedClasses">
  311.             <list>
  312.                <value>by.specific.entity.EstateEntity</value>
  313.                 <value>by.specific.entity.UserEntity</value>
  314.             </list>
  315.         </property>
  316.         <property name="hibernateProperties">
  317.             <props>
  318.                 <prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
  319.                 <prop key="hibernate.connection.autocommit">true</prop>
  320.                 <prop key="hibernate.show_sql">true</prop>
  321.                 <prop key="hibernate.connection.url">jdbc:mysql://localhost:3306/MySQL</prop>
  322.                 <prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
  323.             </props>
  324.         </property>
  325.     </bean>
  326.  
  327.     <!--BookDao and BookService beans-->
  328.     <bean id="estateDao" class="by.specific.dao.EstateDaoImpl">
  329.         <property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
  330.     </bean>
  331.     <bean id="estateService" class="by.specific.service.EstateServiceImpl">
  332.         <property name="estateDao" ref="estateDao"/>
  333.     </bean>
  334.     <bean id="UsersDao" class="by.specific.dao.UsersDaoImpl">
  335.         <property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
  336.     </bean>
  337.     <bean id="UserSService" class="by.specific.service.UsersServiceImpl">
  338.         <property name="UsersDao" ref="UsersDao"/>
  339.     </bean>
  340.  
  341.     <context:component-scan base-package="by.specific"/>
  342.  
  343.     <tx:annotation-driven transaction-manager="transactionManager"/>
  344.  
  345.     <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager">
  346.         <property name="sessionFactory" ref="hibernate4AnnotatedSessionFactory"/>
  347.     </bean>
  348.  
  349.     <mvc:default-servlet-handler/>
  350.     <mvc:annotation-driven/>
  351.     <mvc:resources mapping="/css/**" location="/css/"/>
  352. </beans>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top