KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > jpa > map > JpaEntity


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20 package org.apache.cayenne.jpa.map;
21
22 import java.util.ArrayList JavaDoc;
23 import java.util.Collection JavaDoc;
24
25 import org.apache.cayenne.util.TreeNodeChild;
26
27 /**
28  * A JPA-compliant entity.
29  *
30  * @author Andrus Adamchik
31  */

32 public class JpaEntity extends JpaAbstractEntity {
33
34     protected String JavaDoc name;
35     protected JpaTable table;
36     protected JpaInheritance inheritance;
37     protected String JavaDoc discriminatorValue;
38     protected JpaDiscriminatorColumn discriminatorColumn;
39     protected JpaSequenceGenerator sequenceGenerator;
40     protected JpaTableGenerator tableGenerator;
41     protected JpaSqlResultSetMapping sqlResultSetMapping;
42     protected Collection JavaDoc<JpaAttributeOverride> attributeOverrides;
43     protected Collection JavaDoc<JpaAssociationOverride> associationOverrides;
44
45     // TODO: andrus, 7/25/2006 - according to the notes in the JPA spec FR, these
46
// annotations can be specified on a mapped superclass as well as entity. Check the
47
// spec test to verify that and move these to superclass.
48
protected Collection JavaDoc<JpaNamedQuery> namedQueries;
49     protected Collection JavaDoc<JpaNamedNativeQuery> namedNativeQueries;
50
51     protected Collection JavaDoc<JpaSecondaryTable> secondaryTables;
52     protected Collection JavaDoc<JpaPrimaryKeyJoinColumn> primaryKeyJoinColumns;
53
54     public String JavaDoc getName() {
55         return name;
56     }
57
58     public void setName(String JavaDoc name) {
59         this.name = name;
60     }
61
62     @TreeNodeChild
63     public JpaDiscriminatorColumn getDiscriminatorColumn() {
64         return discriminatorColumn;
65     }
66
67     public void setDiscriminatorColumn(JpaDiscriminatorColumn discriminatorColumn) {
68         this.discriminatorColumn = discriminatorColumn;
69     }
70
71     /**
72      * Returns discriminatorValue property.
73      * <h3>Specification Documentation</h3>
74      * <p>
75      * <b>Description:</b> An optional value that indicates that the row is an entity of
76      * this entity type.
77      * </p>
78      * <p>
79      * <b>Default:</b> If the DiscriminatorValue annotation is not specified, a
80      * provider-specific function to generate a value representing the entity type is used
81      * for the value of the discriminator column. If the DiscriminatorType is STRING, the
82      * discriminator value default is the entity name.
83      * </p>
84      */

85     public String JavaDoc getDiscriminatorValue() {
86         return discriminatorValue;
87     }
88
89     public void setDiscriminatorValue(String JavaDoc discriminatorValue) {
90         this.discriminatorValue = discriminatorValue;
91     }
92
93     @TreeNodeChild
94     public JpaInheritance getInheritance() {
95         return inheritance;
96     }
97
98     public void setInheritance(JpaInheritance inheritance) {
99         this.inheritance = inheritance;
100     }
101
102     @TreeNodeChild
103     public JpaSequenceGenerator getSequenceGenerator() {
104         return sequenceGenerator;
105     }
106
107     public void setSequenceGenerator(JpaSequenceGenerator sequenceGenerator) {
108         this.sequenceGenerator = sequenceGenerator;
109     }
110
111     @TreeNodeChild
112     public JpaSqlResultSetMapping getSqlResultSetMapping() {
113         return sqlResultSetMapping;
114     }
115
116     public void setSqlResultSetMapping(JpaSqlResultSetMapping sqlResultSetMapping) {
117         this.sqlResultSetMapping = sqlResultSetMapping;
118     }
119
120     @TreeNodeChild
121     public JpaTable getTable() {
122         return table;
123     }
124
125     public void setTable(JpaTable table) {
126         this.table = table;
127     }
128
129     @TreeNodeChild
130     public JpaTableGenerator getTableGenerator() {
131         return tableGenerator;
132     }
133
134     public void setTableGenerator(JpaTableGenerator tableGenerator) {
135         this.tableGenerator = tableGenerator;
136     }
137
138     /**
139      * Returns a collection of attribute overrides. Attribute overrides allows to change
140      * the definition of attributes from a mapped superclass.
141      */

142     @TreeNodeChild(type = JpaAttributeOverride.class)
143     public Collection JavaDoc<JpaAttributeOverride> getAttributeOverrides() {
144         if (attributeOverrides == null) {
145             attributeOverrides = new ArrayList JavaDoc<JpaAttributeOverride>();
146         }
147
148         return attributeOverrides;
149     }
150
151     @TreeNodeChild(type = JpaAssociationOverride.class)
152     public Collection JavaDoc<JpaAssociationOverride> getAssociationOverrides() {
153         if (associationOverrides == null) {
154             associationOverrides = new ArrayList JavaDoc<JpaAssociationOverride>();
155         }
156
157         return associationOverrides;
158     }
159
160     @TreeNodeChild(type = JpaNamedNativeQuery.class)
161     public Collection JavaDoc<JpaNamedNativeQuery> getNamedNativeQueries() {
162         if (namedNativeQueries == null) {
163             namedNativeQueries = new ArrayList JavaDoc();
164         }
165         return namedNativeQueries;
166     }
167
168     @TreeNodeChild(type = JpaNamedQuery.class)
169     public Collection JavaDoc<JpaNamedQuery> getNamedQueries() {
170         if (namedQueries == null) {
171             namedQueries = new ArrayList JavaDoc();
172         }
173         return namedQueries;
174     }
175
176     /**
177      * Returns a collection of {@link JpaPrimaryKeyJoinColumn} objects that reference keys
178      * of a primary table. PK join columns used by subclasses in a
179      * {@link javax.persistence.InheritanceType#JOINED} mapping scenario.
180      */

181     @TreeNodeChild(type = JpaPrimaryKeyJoinColumn.class)
182     public Collection JavaDoc<JpaPrimaryKeyJoinColumn> getPrimaryKeyJoinColumns() {
183         if (primaryKeyJoinColumns == null) {
184             primaryKeyJoinColumns = new ArrayList JavaDoc();
185         }
186         return primaryKeyJoinColumns;
187     }
188
189     @TreeNodeChild(type = JpaSecondaryTable.class)
190     public Collection JavaDoc<JpaSecondaryTable> getSecondaryTables() {
191         if (secondaryTables == null) {
192             secondaryTables = new ArrayList JavaDoc();
193         }
194         return secondaryTables;
195     }
196
197     @Override JavaDoc
198     public String JavaDoc toString() {
199         return "JpaEntity:" + name;
200     }
201 }
202
Popular Tags