KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > persister > collection > CollectionPersister


1 //$Id: CollectionPersister.java,v 1.9 2005/06/19 16:39:54 oneovthafew Exp $
2
package org.hibernate.persister.collection;
3
4 import java.io.Serializable JavaDoc;
5 import java.sql.ResultSet JavaDoc;
6 import java.sql.SQLException JavaDoc;
7 import java.util.Map JavaDoc;
8
9 import org.hibernate.HibernateException;
10 import org.hibernate.MappingException;
11 import org.hibernate.cache.CacheConcurrencyStrategy;
12 import org.hibernate.cache.entry.CacheEntryStructure;
13 import org.hibernate.collection.PersistentCollection;
14 import org.hibernate.engine.SessionFactoryImplementor;
15 import org.hibernate.engine.SessionImplementor;
16 import org.hibernate.id.IdentifierGenerator;
17 import org.hibernate.metadata.CollectionMetadata;
18 import org.hibernate.persister.entity.EntityPersister;
19 import org.hibernate.type.CollectionType;
20 import org.hibernate.type.Type;
21
22 /**
23  * A strategy for persisting a collection role. Defines a contract between
24  * the persistence strategy and the actual persistent collection framework
25  * and session. Does not define operations that are required for querying
26  * collections, or loading by outer join.<br>
27  * <br>
28  * Implements persistence of a collection instance while the instance is
29  * referenced in a particular role.<br>
30  * <br>
31  * This class is highly coupled to the <tt>PersistentCollection</tt>
32  * hierarchy, since double dispatch is used to load and update collection
33  * elements.<br>
34  * <br>
35  * May be considered an immutable view of the mapping object
36  *
37  * @see QueryableCollection
38  * @see PersistentCollection
39  * @author Gavin King
40  */

41 public interface CollectionPersister {
42     /**
43      * Initialize the given collection with the given key
44      */

45     public void initialize(Serializable JavaDoc key, SessionImplementor session) //TODO: add owner argument!!
46
throws HibernateException;
47     /**
48      * Get the cache
49      */

50     public CacheConcurrencyStrategy getCache();
51     /**
52      * Is this collection role cacheable
53      */

54     public boolean hasCache();
55     /**
56      * Get the cache structure
57      */

58     public CacheEntryStructure getCacheEntryStructure();
59     /**
60      * Get the associated <tt>Type</tt>
61      */

62     public CollectionType getCollectionType();
63     /**
64      * Get the "key" type (the type of the foreign key)
65      */

66     public Type getKeyType();
67     /**
68      * Get the "index" type for a list or map (optional operation)
69      */

70     public Type getIndexType();
71     /**
72      * Get the "element" type
73      */

74     public Type getElementType();
75     /**
76      * Return the element class of an array, or null otherwise
77      */

78     public Class JavaDoc getElementClass();
79     /**
80      * Read the key from a row of the JDBC <tt>ResultSet</tt>
81      */

82     public Object JavaDoc readKey(ResultSet JavaDoc rs, String JavaDoc[] keyAliases, SessionImplementor session)
83         throws HibernateException, SQLException JavaDoc;
84     /**
85      * Read the element from a row of the JDBC <tt>ResultSet</tt>
86      */

87     public Object JavaDoc readElement(
88         ResultSet JavaDoc rs,
89         Object JavaDoc owner,
90         String JavaDoc[] columnAliases,
91         SessionImplementor session)
92         throws HibernateException, SQLException JavaDoc;
93     /**
94      * Read the index from a row of the JDBC <tt>ResultSet</tt>
95      */

96     public Object JavaDoc readIndex(ResultSet JavaDoc rs, String JavaDoc[] columnAliases, SessionImplementor session)
97         throws HibernateException, SQLException JavaDoc;
98     /**
99      * Read the identifier from a row of the JDBC <tt>ResultSet</tt>
100      */

101     public Object JavaDoc readIdentifier(
102         ResultSet JavaDoc rs,
103         String JavaDoc columnAlias,
104         SessionImplementor session)
105         throws HibernateException, SQLException JavaDoc;
106     /**
107      * Is this an array or primitive values?
108      */

109     public boolean isPrimitiveArray();
110     /**
111      * Is this an array?
112      */

113     public boolean isArray();
114     /**
115      * Is this a one-to-many association?
116      */

117     public boolean isOneToMany();
118     /**
119      * Is this a many-to-many association? Note that this is mainly
120      * a convenience feature as the single persister does not
121      * conatin all the information needed to handle a many-to-many
122      * itself, as internally it is looked at as two many-to-ones.
123      */

124     public boolean isManyToMany();
125
126     public String JavaDoc getManyToManyFilterFragment(String JavaDoc alias, Map JavaDoc enabledFilters);
127
128     /**
129      * Is this an "indexed" collection? (list or map)
130      */

131     public boolean hasIndex();
132     /**
133      * Is this collection lazyily initialized?
134      */

135     public boolean isLazy();
136     /**
137      * Is this collection "inverse", so state changes are not
138      * propogated to the database.
139      */

140     public boolean isInverse();
141     /**
142      * Completely remove the persistent state of the collection
143      */

144     public void remove(Serializable JavaDoc id, SessionImplementor session)
145         throws HibernateException;
146     /**
147      * (Re)create the collection's persistent state
148      */

149     public void recreate(
150         PersistentCollection collection,
151         Serializable JavaDoc key,
152         SessionImplementor session)
153         throws HibernateException;
154     /**
155      * Delete the persistent state of any elements that were removed from
156      * the collection
157      */

158     public void deleteRows(
159         PersistentCollection collection,
160         Serializable JavaDoc key,
161         SessionImplementor session)
162         throws HibernateException;
163     /**
164      * Update the persistent state of any elements that were modified
165      */

166     public void updateRows(
167         PersistentCollection collection,
168         Serializable JavaDoc key,
169         SessionImplementor session)
170         throws HibernateException;
171     /**
172      * Insert the persistent state of any new collection elements
173      */

174     public void insertRows(
175         PersistentCollection collection,
176         Serializable JavaDoc key,
177         SessionImplementor session)
178         throws HibernateException;
179     /**
180      * Get the name of this collection role (the fully qualified class name,
181      * extended by a "property path")
182      */

183     public String JavaDoc getRole();
184     /**
185      * Get the persister of the entity that "owns" this collection
186      */

187     public EntityPersister getOwnerEntityPersister();
188     /**
189      * Get the surrogate key generation strategy (optional operation)
190      */

191     public IdentifierGenerator getIdentifierGenerator();
192     /**
193      * Get the type of the surrogate key
194      */

195     public Type getIdentifierType();
196     /**
197      * Does this collection implement "orphan delete"?
198      */

199     public boolean hasOrphanDelete();
200     /**
201      * Is this an ordered collection? (An ordered collection is
202      * ordered by the initialization operation, not by sorting
203      * that happens in memory, as in the case of a sorted collection.)
204      */

205     public boolean hasOrdering();
206     /**
207      * Get the "space" that holds the persistent state
208      */

209     public Serializable JavaDoc[] getCollectionSpaces();
210
211     public CollectionMetadata getCollectionMetadata();
212
213     /**
214      * Is cascade delete handled by the database-level
215      * foreign key constraint definition?
216      */

217     public abstract boolean isCascadeDeleteEnabled();
218     
219     /**
220      * Does this collection cause version increment of the
221      * owning entity?
222      */

223     public boolean isVersioned();
224     
225     /**
226      * Can the elements of this collection change?
227      */

228     public boolean isMutable();
229     
230     //public boolean isSubselectLoadable();
231

232     public String JavaDoc getNodeName();
233     
234     public String JavaDoc getElementNodeName();
235     
236     public String JavaDoc getIndexNodeName();
237
238     public void postInstantiate() throws MappingException;
239     
240     public SessionFactoryImplementor getFactory();
241
242     public boolean isAffectedByEnabledFilters(SessionImplementor session);
243
244     /**
245      * Generates the collection's key column aliases, based on the given
246      * suffix.
247      *
248      * @param suffix The suffix to use in the key column alias generation.
249      * @return The key column aliases.
250      */

251     public String JavaDoc[] getKeyColumnAliases(String JavaDoc suffix);
252
253     /**
254      * Generates the collection's index column aliases, based on the given
255      * suffix.
256      *
257      * @param suffix The suffix to use in the index column alias generation.
258      * @return The key column aliases, or null if not indexed.
259      */

260     public String JavaDoc[] getIndexColumnAliases(String JavaDoc suffix);
261
262     /**
263      * Generates the collection's element column aliases, based on the given
264      * suffix.
265      *
266      * @param suffix The suffix to use in the element column alias generation.
267      * @return The key column aliases.
268      */

269     public String JavaDoc[] getElementColumnAliases(String JavaDoc suffix);
270
271     /**
272      * Generates the collection's identifier column aliases, based on the given
273      * suffix.
274      *
275      * @param suffix The suffix to use in the key column alias generation.
276      * @return The key column aliases.
277      */

278     public String JavaDoc getIdentifierColumnAlias(String JavaDoc suffix);
279 }
280
Popular Tags