KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > loader > collection > CollectionLoader


1 //$Id: CollectionLoader.java,v 1.11 2005/06/13 20:27:16 oneovthafew Exp $
2
package org.hibernate.loader.collection;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Map JavaDoc;
6
7 import org.hibernate.HibernateException;
8 import org.hibernate.engine.SessionFactoryImplementor;
9 import org.hibernate.engine.SessionImplementor;
10 import org.hibernate.loader.OuterJoinLoader;
11 import org.hibernate.persister.collection.QueryableCollection;
12 import org.hibernate.type.Type;
13
14 /**
15  * Superclass for loaders that initialize collections
16  *
17  * @see OneToManyLoader
18  * @see BasicCollectionLoader
19  * @author Gavin King
20  */

21 public class CollectionLoader extends OuterJoinLoader implements CollectionInitializer {
22
23     private final QueryableCollection collectionPersister;
24
25     public CollectionLoader(QueryableCollection collectionPersister, SessionFactoryImplementor factory, Map JavaDoc enabledFilters) {
26         super( factory, enabledFilters );
27         this.collectionPersister = collectionPersister;
28     }
29
30     protected boolean isSubselectLoadingEnabled() {
31         return hasSubselectLoadableCollections();
32     }
33
34     public void initialize(Serializable JavaDoc id, SessionImplementor session)
35     throws HibernateException {
36         loadCollection( session, id, getKeyType() );
37     }
38
39     protected Type getKeyType() {
40         return collectionPersister.getKeyType();
41     }
42
43     public String JavaDoc toString() {
44         return getClass().getName() + '(' + collectionPersister.getRole() + ')';
45     }
46 }
47
Popular Tags