KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > singletableinheritance > Person


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.singletableinheritance;
23
24 import javax.persistence.DiscriminatorColumn;
25 import javax.persistence.DiscriminatorType;
26 import javax.persistence.Entity;
27 import javax.persistence.GeneratedValue; import javax.persistence.GenerationType;
28 import javax.persistence.Id;
29 import javax.persistence.Inheritance;
30 import javax.persistence.InheritanceType;
31 import javax.persistence.Version;
32
33 /**
34  * @author Gavin King
35  */

36 @Entity
37 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
38 @DiscriminatorColumn(name = "person_type", discriminatorType = DiscriminatorType.STRING)
39 public class Person
40 {
41    private long id;
42    private String JavaDoc name;
43    private String JavaDoc address;
44    private String JavaDoc zip;
45    private String JavaDoc country;
46    private char sex;
47    private int version;
48
49    @Id @GeneratedValue(strategy=GenerationType.AUTO)
50            public long getId()
51    {
52       return id;
53    }
54
55    public void setId(long id)
56    {
57       this.id = id;
58    }
59
60    public char getSex()
61    {
62       return sex;
63    }
64
65    public void setSex(char sex)
66    {
67       this.sex = sex;
68    }
69
70    public String JavaDoc getName()
71    {
72       return name;
73    }
74
75    public void setName(String JavaDoc identity)
76    {
77       this.name = identity;
78    }
79
80    public String JavaDoc getCountry()
81    {
82       return country;
83    }
84
85    public void setCountry(String JavaDoc country)
86    {
87       this.country = country;
88    }
89
90    public String JavaDoc getZip()
91    {
92       return zip;
93    }
94
95    public void setZip(String JavaDoc zip)
96    {
97       this.zip = zip;
98    }
99
100    public String JavaDoc getAddress()
101    {
102       return address;
103    }
104
105    public void setAddress(String JavaDoc address)
106    {
107       this.address = address;
108    }
109
110    @Version
111    public int getVersion()
112    {
113       return version;
114    }
115
116    public void setVersion(int version)
117    {
118       this.version = version;
119    }
120 }
121
Popular Tags