KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > tuple > IdentifierProperty


1 // $Id: IdentifierProperty.java,v 1.3 2005/06/05 04:31:34 oneovthafew Exp $
2
package org.hibernate.tuple;
3
4 import org.hibernate.engine.IdentifierValue;
5 import org.hibernate.id.IdentifierGenerator;
6 import org.hibernate.id.PostInsertIdentifierGenerator;
7 import org.hibernate.type.Type;
8
9 /**
10  * Represents a defined entity identifier property within the Hibernate
11  * runtime-metamodel.
12  *
13  * @author Steve Ebersole
14  */

15 public class IdentifierProperty extends Property {
16
17     private boolean virtual;
18     private boolean embedded;
19     private IdentifierValue unsavedValue;
20     private IdentifierGenerator identifierGenerator;
21     private boolean identifierAssignedByInsert;
22
23     /**
24      * Construct a non-virtual identifier property.
25      *
26      * @param name The name of the property representing the identifier within
27      * its owning entity.
28      * @param node The node name to use for XML-based representation of this
29      * property.
30      * @param type The Hibernate Type for the identifier property.
31      * @param embedded Is this an embedded identifier.
32      * @param unsavedValue The value which, if found as the value on the identifier
33      * property, represents new (i.e., un-saved) instances of the owning entity.
34      * @param identifierGenerator The generator to use for id value generation.
35      */

36     public IdentifierProperty(
37             String JavaDoc name,
38             String JavaDoc node,
39             Type type,
40             boolean embedded,
41             IdentifierValue unsavedValue,
42             IdentifierGenerator identifierGenerator) {
43         super(name, node, type);
44         this.virtual = false;
45         this.embedded = embedded;
46         this.unsavedValue = unsavedValue;
47         this.identifierGenerator = identifierGenerator;
48         this.identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
49     }
50
51     /**
52      * Construct a virtual IdentifierProperty.
53      *
54      * @param type The Hibernate Type for the identifier property.
55      * @param embedded Is this an embedded identifier.
56      * @param unsavedValue The value which, if found as the value on the identifier
57      * property, represents new (i.e., un-saved) instances of the owning entity.
58      * @param identifierGenerator The generator to use for id value generation.
59      */

60     public IdentifierProperty(
61             Type type,
62             boolean embedded,
63             IdentifierValue unsavedValue,
64             IdentifierGenerator identifierGenerator) {
65         super(null, null, type);
66         this.virtual = true;
67         this.embedded = embedded;
68         this.unsavedValue = unsavedValue;
69         this.identifierGenerator = identifierGenerator;
70         this.identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
71     }
72
73     public boolean isVirtual() {
74         return virtual;
75     }
76
77     public boolean isEmbedded() {
78         return embedded;
79     }
80
81     public IdentifierValue getUnsavedValue() {
82         return unsavedValue;
83     }
84
85     public IdentifierGenerator getIdentifierGenerator() {
86         return identifierGenerator;
87     }
88
89     public boolean isIdentifierAssignedByInsert() {
90         return identifierAssignedByInsert;
91     }
92 }
93
Popular Tags