1 package org.hibernate.loader.collection; 3 4 import java.io.Serializable ; 5 import java.util.Collection ; 6 import java.util.Iterator ; 7 import java.util.Map ; 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 22 public class SubselectCollectionLoader extends BasicCollectionLoader { 23 24 private final Serializable [] keys; 25 private final Type[] types; 26 private final Object [] values; 27 private final Map namedParameters; 28 29 public SubselectCollectionLoader( 30 QueryableCollection persister, 31 String subquery, 32 Collection entityKeys, 33 QueryParameters queryParameters, 34 SessionFactoryImplementor factory, 35 Map enabledFilters) 36 throws MappingException { 37 38 super(persister, 1, subquery, factory, enabledFilters); 39 40 keys = new Serializable [ entityKeys.size() ]; 41 Iterator 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 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 |