View Javadoc

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 javax.jdo.annotations;
18  
19  import java.lang.annotation.ElementType;
20  import java.lang.annotation.Retention;
21  import java.lang.annotation.RetentionPolicy;
22  import java.lang.annotation.Target;
23  
24  /**
25   * Annotation for defining the persistence of a member.
26   * This corresponds to the xml elements "field" and "property". 
27   * 
28   * @version 2.1
29   * @since 2.1
30   */
31  @Target({ElementType.FIELD, ElementType.METHOD}) 
32  @Retention(RetentionPolicy.RUNTIME)
33  public @interface Persistent
34  {
35      /** Modifier for this field. This is normally not specified, and the 
36       * defaults are used, or the @Transactional or @NotPersistent 
37       * annotation is specified directly on the member. One possible use
38       * for specifying persistenceModifier is for embedded instances in which
39       * a member is not persistent but in the non-embedded instances the
40       * member is persistent. Note that it is not portable to specify a
41       * member to be not persistent in the non-embedded case and persistent
42       * in the embedded usage.
43       * @return the persistence modifier
44       */
45      PersistenceModifier persistenceModifier() 
46          default PersistenceModifier.UNSPECIFIED;
47  
48      /** Table to use for persisting this member.
49       * @return the table to use for persisting this member
50       */
51      String table() default "";
52  
53      /** Whether this member is in the default fetch group. 
54       * @return whether this member is in the default fetch group
55       */
56      String defaultFetchGroup() default "";
57  
58      /** Behavior when this member contains a null value. 
59       * @return the behavior when this member contains a null value
60       */
61      NullValue nullValue() default NullValue.NONE;
62  
63      /** Whether this member is embedded. 
64       * @return whether this member is embedded
65       */
66      String embedded() default "";
67  
68      /** Whether the elements of this member are embedded. 
69       * @return whether the elements of this member are embedded
70       */
71      String embeddedElement() default "";
72  
73      /** Whether the keys of this member are embedded. 
74       * @return whether the keys of this member are embedded
75       */
76      String embeddedKey() default "";
77  
78      /** Whether the values of this member are embedded. 
79       * @return whether the values of this member are embedded
80       */
81      String embeddedValue() default "";
82  
83      /** Whether this member is serialized into a single column. 
84       * @return whether this member is serialized into a single column
85       */
86      String serialized() default "";
87  
88      /** Whether the elements of this member are serialized. 
89       * @return whether the elements of this member are serialized
90       */
91      String serializedElement() default "";
92  
93      /** Whether the keys of this member are serialized. 
94       * @return whether the keys of this member are serialized
95       */
96      String serializedKey() default "";
97  
98      /** Whether the values of this member are serialized. 
99       * @return whether the values of this member are serialized
100      */
101     String serializedValue() default "";
102 
103     /** Whether related object(s) of this member are dependent
104      * and so deleted when this object is deleted. 
105      * @return whether the related object(s) of this member
106      * are dependent
107      */
108     String dependent() default "";
109 
110     /** Whether the elements of this member are dependent. 
111      * @return whether the elements of this member are dependent
112      */
113     String dependentElement() default "";
114 
115     /** Whether the keys of this member are dependent. 
116      * @return whether the keys of this member are dependent
117      */
118     String dependentKey() default "";
119 
120     /** Whether the values of this member are dependent. 
121      * @return whether the values of this member are dependent
122      */
123     String dependentValue() default "";
124 
125     /** Whether this member is part of the primary key for application
126      * identity. This is equivalent to specifying @PrimaryKey as 
127      * a separate annotation on the member.
128      * @return whether this member is part of the primary key
129      */
130     String primaryKey() default "";
131 
132     /** Value strategy to use to generate the value for this field 
133      * or property (if any).
134      * @return the generated value strategy
135      */
136     IdGeneratorStrategy valueStrategy() default IdGeneratorStrategy.UNSPECIFIED;
137 
138     /** Custom value strategy to use to generate the value for this field 
139      * or property (if any). If customValueStrategy is non-empty, then
140      * valueStrategy must be UNSPECIFIED.
141      * @return the custom value strategy
142      */
143     String customValueStrategy() default "";
144 
145     /** Name of the sequence to use with particular value strategies. 
146      * @return the name of the sequence
147      */
148     String sequence() default "";
149 
150     /** Name of the fetch-group to use when this member is loaded 
151      * due to being referenced when not already loaded.
152      * @return the name of the load fetch group
153      */
154     String loadFetchGroup() default "";
155 
156     /** Types of the member. Used when the declared 
157      * member type is a supertype of the actual type that is stored in the 
158      * member. For example, the declared member type might be an interface type
159      * that must contain an object of a concrete type when used
160      * for persistence.
161      * @return the types
162      */
163     Class[] types() default {};
164 
165     /** Name of the related member in the other class 
166      * where this value is mapped (bidirectional relationship). 
167      * @return the related member in the other class
168      */
169     String mappedBy() default "";
170 
171     /** Column definition(s) for this member. Used for mapping 
172      * multiple columns
173      * to the same member, for example relationships with 
174      * multiple column foreign keys. 
175      * @return the columns for this member
176      */
177     Column[] columns() default {}; 
178 
179     /** Column name where the values are stored for this member. 
180      * @return the name of the column
181      */
182     String column() default "";
183 
184     /** Null indicator column for this member. Used for nested 
185      * embedded fields or properties to indicate whether the embedded
186      * instance should have a null value.
187      * @return the null indicator column
188      */
189     String nullIndicatorColumn() default "";
190 
191     /** Name of the member when this is embedded in another object.
192      * The fully-qualified member name is used. For example, 
193      * "line.point1.x" refers to the member x in class Point 
194      * that is embedded as member point1 in class Line that is embedded 
195      * in a member called line.
196      * @return the name of the member
197      */
198     String name() default ""; 
199 
200     /** Recursion depth for this member. Used only when
201      * the annotation is used within the definition of a FetchGroup.
202      * @return the recursion depth
203      */
204     int recursionDepth() default 1;
205 
206     /** Whether this field/property is cacheable in a Level2 cache.
207      * @since 2.2
208      */
209     String cacheable() default "true";
210 
211     /** Vendor extensions for this member. 
212      * @return the vendor extensions
213      */
214     Extension[] extensions() default {};
215 }