01: // $Id: IdentifierProperty.java 9295 2006-02-15 22:28:15Z epbernard $
02: package org.hibernate.tuple;
03:
04: import org.hibernate.engine.IdentifierValue;
05: import org.hibernate.id.IdentifierGenerator;
06: import org.hibernate.id.PostInsertIdentifierGenerator;
07: import org.hibernate.type.Type;
08:
09: /**
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: private boolean hasIdentifierMapper;
23:
24: /**
25: * Construct a non-virtual identifier property.
26: *
27: * @param name The name of the property representing the identifier within
28: * its owning entity.
29: * @param node The node name to use for XML-based representation of this
30: * property.
31: * @param type The Hibernate Type for the identifier property.
32: * @param embedded Is this an embedded identifier.
33: * @param unsavedValue The value which, if found as the value on the identifier
34: * property, represents new (i.e., un-saved) instances of the owning entity.
35: * @param identifierGenerator The generator to use for id value generation.
36: */
37: public IdentifierProperty(String name, String node, Type type,
38: boolean embedded, IdentifierValue unsavedValue,
39: IdentifierGenerator identifierGenerator) {
40: super (name, node, type);
41: this .virtual = false;
42: this .embedded = embedded;
43: this .hasIdentifierMapper = false;
44: this .unsavedValue = unsavedValue;
45: this .identifierGenerator = identifierGenerator;
46: this .identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
47: }
48:
49: /**
50: * Construct a virtual IdentifierProperty.
51: *
52: * @param type The Hibernate Type for the identifier property.
53: * @param embedded Is this an embedded identifier.
54: * @param unsavedValue The value which, if found as the value on the identifier
55: * property, represents new (i.e., un-saved) instances of the owning entity.
56: * @param identifierGenerator The generator to use for id value generation.
57: */
58: public IdentifierProperty(Type type, boolean embedded,
59: boolean hasIdentifierMapper, IdentifierValue unsavedValue,
60: IdentifierGenerator identifierGenerator) {
61: super (null, null, type);
62: this .virtual = true;
63: this .embedded = embedded;
64: this .hasIdentifierMapper = hasIdentifierMapper;
65: this .unsavedValue = unsavedValue;
66: this .identifierGenerator = identifierGenerator;
67: this .identifierAssignedByInsert = identifierGenerator instanceof PostInsertIdentifierGenerator;
68: }
69:
70: public boolean isVirtual() {
71: return virtual;
72: }
73:
74: public boolean isEmbedded() {
75: return embedded;
76: }
77:
78: public IdentifierValue getUnsavedValue() {
79: return unsavedValue;
80: }
81:
82: public IdentifierGenerator getIdentifierGenerator() {
83: return identifierGenerator;
84: }
85:
86: public boolean isIdentifierAssignedByInsert() {
87: return identifierAssignedByInsert;
88: }
89:
90: public boolean hasIdentifierMapper() {
91: return hasIdentifierMapper;
92: }
93: }
|