KickJava   Java API By Example, From Geeks To Geeks.

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


1 //$Id: SubselectCollectionLoader.java,v 1.5 2005/06/13 20:10:20 oneovthafew Exp $
2
package org.hibernate.loader.collection;
3
4 import java.io.Serializable JavaDoc;
5 import java.util.Collection JavaDoc;
6 import java.util.Iterator JavaDoc;
7 import java.util.Map JavaDoc;
8
9 import org.hibernate.HibernateException;
10 import org.hibernate.MappingException;
11 import org.hibernate.engine.EntityKey;
12 import org.hibernate.engine.QueryParameters;
13 import org.hibernate.engine.SessionFactoryImplementor;
14 import org.hibernate.engine.SessionImplementor;
15 import org.hibernate.persister.collection.QueryableCollection;
16 import org.hibernate.type.Type;
17
18 /**
19  * Implements subselect fetching for a collection
20  * @author Gavin King
21  */

22 public class SubselectCollectionLoader extends BasicCollectionLoader {
23     
24     private final Serializable JavaDoc[] keys;
25     private final Type[] types;
26     private final Object JavaDoc[] values;
27     private final Map JavaDoc namedParameters;
28
29     public SubselectCollectionLoader(
30             QueryableCollection persister,
31             String JavaDoc subquery,
32             Collection JavaDoc entityKeys,
33             QueryParameters queryParameters,
34             SessionFactoryImplementor factory,
35             Map JavaDoc enabledFilters)
36     throws MappingException {
37         
38         super(persister, 1, subquery, factory, enabledFilters);
39
40         keys = new Serializable JavaDoc[ entityKeys.size() ];
41         Iterator JavaDoc iter = entityKeys.iterator();
42         int i=0;
43         while ( iter.hasNext() ) {
44             keys[i++] = ( (EntityKey) iter.next() ).getIdentifier();
45         }
46         
47         this.namedParameters = queryParameters.getNamedParameters();
48         this.types = queryParameters.getFilteredPositionalParameterTypes();
49         this.values = queryParameters.getFilteredPositionalParameterValues();
50         
51     }
52
53     public void initialize(Serializable JavaDoc id, SessionImplementor session)
54     throws HibernateException {
55         loadCollectionSubselect(
56                 session,
57                 keys,
58                 values,
59                 types,
60                 namedParameters,
61                 getKeyType()
62             );
63     }
64
65 }
66
Popular Tags