KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > metadata > ClassMetadata


1 //$Id: ClassMetadata.java,v 1.10 2005/07/16 22:20:46 oneovthafew Exp $
2
package org.hibernate.metadata;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import org.hibernate.HibernateException;
8 import org.hibernate.EntityMode;
9 import org.hibernate.engine.SessionImplementor;
10 import org.hibernate.type.Type;
11
12 /**
13  * Exposes entity class metadata to the application
14  *
15  * @see org.hibernate.SessionFactory#getClassMetadata(Class)
16  * @author Gavin King
17  */

18 public interface ClassMetadata {
19
20     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
21
// stuff that is persister-centric and/or EntityInfo-centric ~~~~~~~~~~~~~~
22
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
23

24     /**
25      * The name of the entity
26      */

27     public String JavaDoc getEntityName();
28
29     /**
30      * Get the name of the identifier property (or return null)
31      */

32     public String JavaDoc getIdentifierPropertyName();
33
34     /**
35      * Get the names of the class' persistent properties
36      */

37     public String JavaDoc[] getPropertyNames();
38
39     /**
40      * Get the identifier Hibernate type
41      */

42     public Type getIdentifierType();
43
44     /**
45      * Get the Hibernate types of the class properties
46      */

47     public Type[] getPropertyTypes();
48
49     /**
50      * Get the type of a particular (named) property
51      */

52     public Type getPropertyType(String JavaDoc propertyName) throws HibernateException;
53
54     /**
55      * Does this class support dynamic proxies?
56      */

57     public boolean hasProxy();
58
59     /**
60      * Are instances of this class mutable?
61      */

62     public boolean isMutable();
63
64     /**
65      * Are instances of this class versioned by a timestamp or version number column?
66      */

67     public boolean isVersioned();
68
69     /**
70      * Get the index of the version property
71      */

72     public int getVersionProperty();
73
74     /**
75      * Get the nullability of the class' persistent properties
76      */

77     public boolean[] getPropertyNullability();
78
79
80     /**
81      * Get the "laziness" of the properties of this class
82      */

83     public boolean[] getPropertyLaziness();
84
85     /**
86      * Does this class have an identifier property?
87      */

88     public boolean hasIdentifierProperty();
89
90     /**
91      * Does this entity declare a natural id?
92      */

93     public boolean hasNaturalIdentifier();
94
95     /**
96      * Which properties hold the natural id?
97      */

98     public int[] getNaturalIdentifierProperties();
99     
100     /**
101      * Does this entity have mapped subclasses?
102      */

103     public boolean hasSubclasses();
104     
105     /**
106      * Does this entity extend a mapped superclass?
107      */

108     public boolean isInherited();
109     
110     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
111
// stuff that is tuplizer-centric, but is passed a session ~~~~~~~~~~~~~~~~
112
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
113

114     /**
115      * Return the values of the mapped properties of the object
116      */

117     public Object JavaDoc[] getPropertyValuesToInsert(Object JavaDoc entity, Map JavaDoc mergeMap, SessionImplementor session)
118     throws HibernateException;
119
120
121     // ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
122
// stuff that is Tuplizer-centric ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
124

125     /**
126      * The persistent class, or null
127      */

128     public Class JavaDoc getMappedClass(EntityMode entityMode);
129
130     /**
131      * Create a class instance initialized with the given identifier
132      */

133     public Object JavaDoc instantiate(Serializable JavaDoc id, EntityMode entityMode) throws HibernateException;
134
135     /**
136      * Get the value of a particular (named) property
137      */

138     public Object JavaDoc getPropertyValue(Object JavaDoc object, String JavaDoc propertyName, EntityMode entityMode) throws HibernateException;
139
140     /**
141      * Extract the property values from the given entity.
142      *
143      * @param entity The entity from which to extract the property values.
144      * @param entityMode The entity-mode of the given entity
145      * @return The property values.
146      * @throws HibernateException
147      */

148     public Object JavaDoc[] getPropertyValues(Object JavaDoc entity, EntityMode entityMode) throws HibernateException;
149
150     /**
151      * Set the value of a particular (named) property
152      */

153     public void setPropertyValue(Object JavaDoc object, String JavaDoc propertyName, Object JavaDoc value, EntityMode entityMode) throws HibernateException;
154
155     /**
156      * Set the given values to the mapped properties of the given object
157      */

158     public void setPropertyValues(Object JavaDoc object, Object JavaDoc[] values, EntityMode entityMode) throws HibernateException;
159
160     /**
161      * Get the identifier of an instance (throw an exception if no identifier property)
162      */

163     public Serializable JavaDoc getIdentifier(Object JavaDoc entity, EntityMode entityMode) throws HibernateException;
164
165     /**
166      * Set the identifier of an instance (or do nothing if no identifier property)
167      */

168     public void setIdentifier(Object JavaDoc object, Serializable JavaDoc id, EntityMode entityMode) throws HibernateException;
169
170     /**
171      * Does the class implement the <tt>Lifecycle</tt> interface?
172      */

173     public boolean implementsLifecycle(EntityMode entityMode);
174
175     /**
176      * Does the class implement the <tt>Validatable</tt> interface?
177      */

178     public boolean implementsValidatable(EntityMode entityMode);
179
180     /**
181      * Get the version number (or timestamp) from the object's version property
182      * (or return null if not versioned)
183      */

184     public Object JavaDoc getVersion(Object JavaDoc object, EntityMode entityMode) throws HibernateException;
185
186 }
187
Popular Tags