|
From: <hib...@li...> - 2006-05-04 11:58:07
|
Author: ste...@jb...
Date: 2006-05-04 07:57:58 -0400 (Thu, 04 May 2006)
New Revision: 9870
Modified:
trunk/Hibernate3/src/org/hibernate/loader/BasicLoader.java
Log:
HHH-1413 : multiple bag fetches
Modified: trunk/Hibernate3/src/org/hibernate/loader/BasicLoader.java
===================================================================
--- trunk/Hibernate3/src/org/hibernate/loader/BasicLoader.java 2006-05-04 03:17:03 UTC (rev 9869)
+++ trunk/Hibernate3/src/org/hibernate/loader/BasicLoader.java 2006-05-04 11:57:58 UTC (rev 9870)
@@ -4,6 +4,8 @@
import org.hibernate.engine.SessionFactoryImplementor;
import org.hibernate.persister.entity.Loadable;
import org.hibernate.persister.collection.CollectionPersister;
+import org.hibernate.type.BagType;
+import org.hibernate.HibernateException;
/**
* Uses the default mapping from property to result set column
@@ -22,7 +24,7 @@
public BasicLoader(SessionFactoryImplementor factory) {
super(factory);
}
-
+
protected final EntityAliases[] getEntityAliases() {
return descriptors;
}
@@ -43,12 +45,16 @@
}
CollectionPersister[] collectionPersisters = getCollectionPersisters();
+ int bagCount = 0;
if ( collectionPersisters != null ) {
String[] collectionSuffixes = getCollectionSuffixes();
collectionDescriptors = new CollectionAliases[collectionPersisters.length];
for ( int i = 0; i < collectionPersisters.length; i++ ) {
- collectionDescriptors[i] = new GeneratedCollectionAliases(
- collectionPersisters[i],
+ if ( isBag( collectionPersisters[i] ) ) {
+ bagCount++;
+ }
+ collectionDescriptors[i] = new GeneratedCollectionAliases(
+ collectionPersisters[i],
collectionSuffixes[i]
);
}
@@ -56,8 +62,15 @@
else {
collectionDescriptors = null;
}
+ if ( bagCount > 1 ) {
+ throw new HibernateException( "cannot simultaneously fetch multiple bags" );
+ }
}
-
+
+ private boolean isBag(CollectionPersister collectionPersister) {
+ return collectionPersister.getCollectionType().getClass().isAssignableFrom( BagType.class );
+ }
+
/**
* Utility method that generates 0_, 1_ suffixes. Subclasses don't
* necessarily need to use this algorithm, but it is intended that
|