HHH-3414 : fetch profiles
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@15138 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
a06e9ac1eb
commit
39123a97fc
|
@ -22,7 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
|
@ -22,7 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
|
@ -22,7 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
|
@ -22,7 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
|
@ -22,7 +22,10 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
import org.hibernate.junit.functional.FunctionalTestCase;
|
import org.hibernate.junit.functional.FunctionalTestCase;
|
||||||
import org.hibernate.Session;
|
import org.hibernate.Session;
|
||||||
|
@ -33,17 +36,19 @@ import org.hibernate.cfg.Environment;
|
||||||
import org.hibernate.engine.SessionImplementor;
|
import org.hibernate.engine.SessionImplementor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* Various tests related to join-style fetch profiles.
|
||||||
*
|
*
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class BasicFetchProfileTest extends FunctionalTestCase {
|
public class JoinFetchProfileTest extends FunctionalTestCase {
|
||||||
public BasicFetchProfileTest(String string) {
|
private List sections;
|
||||||
|
|
||||||
|
public JoinFetchProfileTest(String string) {
|
||||||
super( string );
|
super( string );
|
||||||
}
|
}
|
||||||
|
|
||||||
public String[] getMappings() {
|
public String[] getMappings() {
|
||||||
return new String[] { "fetchprofiles/basic/Mappings.hbm.xml" };
|
return new String[] { "fetchprofiles/join/Mappings.hbm.xml" };
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCacheConcurrencyStrategy() {
|
public String getCacheConcurrencyStrategy() {
|
||||||
|
@ -278,4 +283,29 @@ public class BasicFetchProfileTest extends FunctionalTestCase {
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* fetch-profiles should have no effect what-so-ever on the direct results of the HQL query.
|
||||||
|
*
|
||||||
|
* TODO : this is actually not strictly true. what we should have happen is to subsequently load those fetches
|
||||||
|
*/
|
||||||
|
public void testHQL() {
|
||||||
|
performWithStandardData(
|
||||||
|
new TestCode() {
|
||||||
|
public void perform(TestData data) {
|
||||||
|
Session session = openSession();
|
||||||
|
session.beginTransaction();
|
||||||
|
session.enableFetchProfile( "offering.details" );
|
||||||
|
session.enableFetchProfile( "enrollment.details" );
|
||||||
|
List sections = session.createQuery( "from CourseOffering" ).list();
|
||||||
|
int sectionCount = sections.size();
|
||||||
|
assertEquals( "unexpected CourseOffering count", 1, sectionCount );
|
||||||
|
assertEquals( 1, sfi().getStatistics().getEntityLoadCount() );
|
||||||
|
assertEquals( 0, sfi().getStatistics().getEntityFetchCount() );
|
||||||
|
session.getTransaction().commit();
|
||||||
|
session.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@
|
||||||
~
|
~
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<hibernate-mapping package="org.hibernate.test.fetchprofiles.basic">
|
<hibernate-mapping package="org.hibernate.test.fetchprofiles.join">
|
||||||
|
|
||||||
<class name="Department">
|
<class name="Department">
|
||||||
<id name="id" type="long">
|
<id name="id" type="long">
|
|
@ -22,7 +22,7 @@
|
||||||
* Boston, MA 02110-1301 USA
|
* Boston, MA 02110-1301 USA
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
package org.hibernate.test.fetchprofiles.basic;
|
package org.hibernate.test.fetchprofiles.join;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO : javadoc
|
* TODO : javadoc
|
Loading…
Reference in New Issue