View Javadoc
1   /*
2    * JBoss, Home of Professional Open Source
3    * Copyright 2014, Red Hat, Inc. and/or its affiliates, and individual
4    * contributors by the @authors tag. See the copyright.txt in the
5    * distribution for a full listing of individual contributors.
6    *
7    * Licensed under the Apache License, Version 2.0 (the "License");
8    * you may not use this file except in compliance with the License.
9    * You may obtain a copy of the License at
10   * http://www.apache.org/licenses/LICENSE-2.0
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.jboss.as.quickstart.hibernate4.model;
18  
19  import java.io.Serializable;
20  
21  import javax.persistence.Column;
22  import javax.persistence.Entity;
23  import javax.persistence.Id;
24  import javax.persistence.Table;
25  import javax.persistence.UniqueConstraint;
26  import javax.validation.constraints.Digits;
27  import javax.validation.constraints.NotNull;
28  import javax.validation.constraints.Pattern;
29  import javax.validation.constraints.Size;
30  import javax.xml.bind.annotation.XmlRootElement;
31  
32  import org.hibernate.validator.constraints.Email;
33  import org.hibernate.validator.constraints.NotEmpty;
34  
35  /*The Model uses JPA Entity as well as Hibernate Validators
36   * 
37   */
38  
39  @Entity
40  @XmlRootElement
41  @Table(name = "MemberHibernate4Demo", uniqueConstraints = @UniqueConstraint(columnNames = "id"))
42  public class Member implements Serializable {
43      /** Default value included to remove warning. Remove or modify at will. **/
44      private static final long serialVersionUID = 1L;
45  
46      @Id
47      private Long id;
48  
49      @NotNull
50      @Size(min = 1, max = 25)
51      @Pattern(regexp = "[A-Za-z ]*", message = "must contain only letters and spaces")
52      private String name;
53  
54      /** using hibernate4 validators **/
55      @NotNull
56      @NotEmpty
57      @Email
58      private String email;
59  
60      @NotNull
61      @Size(min = 9, max = 12)
62      @Digits(fraction = 0, integer = 12)
63      @Column(name = "phone_number")
64      private String phoneNumber;
65  
66      private String address;
67  
68      public Long getId() {
69          return id;
70      }
71  
72      public void setId(Long id) {
73          this.id = id;
74      }
75  
76      public String getName() {
77          return name;
78      }
79  
80      public void setName(String name) {
81          this.name = name;
82      }
83  
84      public String getEmail() {
85          return email;
86      }
87  
88      public void setEmail(String email) {
89          this.email = email;
90      }
91  
92      public String getPhoneNumber() {
93          return phoneNumber;
94      }
95  
96      public void setPhoneNumber(String phoneNumber) {
97          this.phoneNumber = phoneNumber;
98      }
99  
100     public String getAddress() {
101         return address;
102     }
103 
104     public void setAddress(String address) {
105         this.address = address;
106     }
107 }