Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » entity » [javadoc | source]

    1   /*
    2    *  Licensed to the Apache Software Foundation (ASF) under one or more
    3    *  contributor license agreements.  See the NOTICE file distributed with
    4    *  this work for additional information regarding copyright ownership.
    5    *  The ASF licenses this file to You under the Apache License, Version 2.0
    6    *  (the "License"); you may not use this file except in compliance with
    7    *  the License.  You may obtain a copy of the License at
    8    * 
    9    *       http://www.apache.org/licenses/LICENSE-2.0
   10    * 
   11    *  Unless required by applicable law or agreed to in writing, software
   12    *  distributed under the License is distributed on an "AS IS" BASIS,
   13    *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   14    *  See the License for the specific language governing permissions and
   15    *  limitations under the License.
   16    */
   17   package org.apache.webbeans.reservation.entity;
   18   
   19   import java.util.Date;
   20   import java.util.HashSet;
   21   import java.util.Set;
   22   
   23   import javax.persistence.CascadeType;
   24   import javax.persistence.Column;
   25   import javax.persistence.Entity;
   26   import javax.persistence.GeneratedValue;
   27   import javax.persistence.Id;
   28   import javax.persistence.OneToMany;
   29   import javax.persistence.Temporal;
   30   import javax.persistence.TemporalType;
   31   import javax.persistence.Version;
   32   
   33   @Entity
   34   public class User
   35   {
   36       @Id
   37       @GeneratedValue
   38       private int id;
   39       
   40       @Column(length=64,nullable=false)
   41       private String name;
   42       
   43       @Column(length=64,nullable=false)
   44       private String surname;
   45       
   46       @Column
   47       private int age;
   48       
   49       @Column(length=50,nullable=false,unique=true)
   50       private String userName;
   51       
   52       @Column(nullable=false,length=20)
   53       private String password;
   54       
   55       @Temporal(value=TemporalType.DATE)
   56       private Date registerDate;
   57       
   58       @OneToMany(mappedBy="user",cascade={CascadeType.ALL})
   59       private Set<Reservation> reservations = new HashSet<Reservation>();
   60       
   61       @Version
   62       private int version;
   63       
   64       @Column
   65       private boolean admin;
   66       
   67   
   68       @Temporal(value=TemporalType.TIMESTAMP)
   69       private Date lastLoginDate;
   70   
   71       public User()
   72       {
   73           
   74       }
   75   
   76       
   77       /**
   78        * @return the name
   79        */
   80       public String getName()
   81       {
   82           return name;
   83       }
   84   
   85       /**
   86        * @param name the name to set
   87        */
   88       public void setName(String name)
   89       {
   90           this.name = name;
   91       }
   92   
   93       /**
   94        * @return the surname
   95        */
   96       public String getSurname()
   97       {
   98           return surname;
   99       }
  100   
  101       /**
  102        * @param surname the surname to set
  103        */
  104       public void setSurname(String surname)
  105       {
  106           this.surname = surname;
  107       }
  108   
  109       /**
  110        * @return the age
  111        */
  112       public int getAge()
  113       {
  114           return age;
  115       }
  116   
  117       /**
  118        * @param age the age to set
  119        */
  120       public void setAge(int age)
  121       {
  122           this.age = age;
  123       }
  124   
  125       /**
  126        * @return the reservations
  127        */
  128       public Set<Reservation> getReservations()
  129       {
  130           return reservations;
  131       }
  132   
  133       /**
  134        * @param reservations the reservations to set
  135        */
  136       public void setReservations(Set<Reservation> reservations)
  137       {
  138           this.reservations = reservations;
  139       }
  140   
  141       /**
  142        * @return the id
  143        */
  144       public int getId()
  145       {
  146           return id;
  147       }
  148       
  149       public void addHotel(Reservation hotel)
  150       {
  151           this.reservations.add(hotel);
  152           
  153           hotel.setUser(this);
  154       }
  155   
  156       /**
  157        * @return the password
  158        */
  159       public String getPassword()
  160       {
  161           return password;
  162       }
  163   
  164       /**
  165        * @param password the password to set
  166        */
  167       public void setPassword(String password)
  168       {
  169           this.password = password;
  170       }
  171   
  172   
  173       /**
  174        * @return the userName
  175        */
  176       public String getUserName()
  177       {
  178           return userName;
  179       }
  180   
  181   
  182       /**
  183        * @param userName the userName to set
  184        */
  185       public void setUserName(String userName)
  186       {
  187           this.userName = userName;
  188       }
  189   
  190   
  191       /**
  192        * @return the version
  193        */
  194       public int getVersion()
  195       {
  196           return version;
  197       }
  198   
  199   
  200       /**
  201        * @return the registerDate
  202        */
  203       public Date getRegisterDate()
  204       {
  205           return registerDate;
  206       }
  207   
  208   
  209       /**
  210        * @param registerDate the registerDate to set
  211        */
  212       public void setRegisterDate(Date registerDate)
  213       {
  214           this.registerDate = registerDate;
  215       }
  216   
  217   
  218       /**
  219        * @return the admin
  220        */
  221       public boolean isAdmin()
  222       {
  223           return admin;
  224       }
  225   
  226   
  227       /**
  228        * @param admin the admin to set
  229        */
  230       public void setAdmin(boolean admin)
  231       {
  232           this.admin = admin;
  233       }
  234   
  235   
  236       /**
  237        * @return the lastLoginDate
  238        */
  239       public Date getLastLoginDate()
  240       {
  241           return lastLoginDate;
  242       }
  243   
  244   
  245       /**
  246        * @param lastLoginDate the lastLoginDate to set
  247        */
  248       public void setLastLoginDate(Date lastLoginDate)
  249       {
  250           this.lastLoginDate = lastLoginDate;
  251       }
  252       
  253       
  254   }

Home » apache-openwebbeans-1.0.0-incubating-M3-binary » org.apache.webbeans.reservation » entity » [javadoc | source]