HHH-7624 only root level fetch-profile element get processed

This commit is contained in:
Strong Liu 2012-09-20 10:55:08 +02:00
parent 4d0f01614a
commit e2f68ef4a1
3 changed files with 47 additions and 7 deletions

View File

@ -400,7 +400,10 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
if ( profile == null || profile.getName() == null ) { if ( profile == null || profile.getName() == null ) {
throw new IllegalArgumentException( "Fetch profile object or name is null: " + profile ); throw new IllegalArgumentException( "Fetch profile object or name is null: " + profile );
} }
fetchProfiles.put( profile.getName(), profile ); FetchProfile old = fetchProfiles.put( profile.getName(), profile );
if ( old != null ) {
LOG.warn( "Duplicated fetch profile with same name [" + profile.getName() + "] found." );
}
} }
@Override @Override

View File

@ -228,6 +228,49 @@ public class HibernateMappingProcessor {
private void processFetchProfiles() { private void processFetchProfiles() {
processFetchProfiles( mappingRoot().getFetchProfile(), null ); processFetchProfiles( mappingRoot().getFetchProfile(), null );
for ( JaxbClassElement classElement : mappingRoot().getClazz() ) {
processFetchProfiles(
classElement.getFetchProfile(), mappingDocument.getMappingLocalBindingContext()
.qualifyClassName( classElement.getName() )
);
// processing fetch profiles defined in the <joined-subclass>
processFetchProfilesInJoinedSubclass(classElement.getJoinedSubclass());
// <union-subclass>
processFetchProfilesInUnionSubclass( classElement.getUnionSubclass() );
// <subclass>
processFetchProfilesInSubclass( classElement.getSubclass() );
}
}
private void processFetchProfilesInSubclass(List<JaxbSubclassElement> subclass) {
for ( JaxbSubclassElement subclassElement : subclass ) {
processFetchProfiles(
subclassElement.getFetchProfile(), mappingDocument.getMappingLocalBindingContext()
.qualifyClassName( subclassElement.getName() )
);
processFetchProfilesInSubclass( subclassElement.getSubclass() );
}
}
private void processFetchProfilesInUnionSubclass(List<JaxbUnionSubclassElement> unionSubclass) {
for ( JaxbUnionSubclassElement subclassElement : unionSubclass ) {
processFetchProfiles(
subclassElement.getFetchProfile(), mappingDocument.getMappingLocalBindingContext()
.qualifyClassName( subclassElement.getName() )
);
processFetchProfilesInUnionSubclass( subclassElement.getUnionSubclass() );
}
}
private void processFetchProfilesInJoinedSubclass(List<JaxbJoinedSubclassElement> joinedSubclassElements) {
for ( JaxbJoinedSubclassElement subclassElement : joinedSubclassElements ) {
processFetchProfiles(
subclassElement.getFetchProfile(), mappingDocument.getMappingLocalBindingContext()
.qualifyClassName( subclassElement.getName() )
);
processFetchProfilesInJoinedSubclass( subclassElement.getJoinedSubclass() );
}
} }
public void processFetchProfiles(List<JaxbFetchProfileElement> fetchProfiles, String containingEntityName) { public void processFetchProfiles(List<JaxbFetchProfileElement> fetchProfiles, String containingEntityName) {

View File

@ -32,7 +32,6 @@ import org.hibernate.UnknownProfileException;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -174,7 +173,6 @@ public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testBasicFetchProfileOperation() { public void testBasicFetchProfileOperation() {
assertTrue( "fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition( "enrollment.details" ) ); assertTrue( "fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition( "enrollment.details" ) );
assertTrue( "fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition( "offering.details" ) ); assertTrue( "fetch profile not parsed properly", sessionFactory().containsFetchProfileDefinition( "offering.details" ) );
@ -237,7 +235,6 @@ public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testLoadOneToManyFetchProfile() { public void testLoadOneToManyFetchProfile() {
performWithStandardData( performWithStandardData(
new TestCode() { new TestCode() {
@ -257,7 +254,6 @@ public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testLoadDeepFetchProfile() { public void testLoadDeepFetchProfile() {
performWithStandardData( performWithStandardData(
new TestCode() { new TestCode() {
@ -281,7 +277,6 @@ public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testLoadComponentDerefFetchProfile() { public void testLoadComponentDerefFetchProfile() {
performWithStandardData( performWithStandardData(
new TestCode() { new TestCode() {
@ -306,7 +301,6 @@ public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
* TODO : this is actually not strictly true. what we should have happen is to subsequently load those fetches * TODO : this is actually not strictly true. what we should have happen is to subsequently load those fetches
*/ */
@Test @Test
@FailureExpectedWithNewMetamodel
public void testHQL() { public void testHQL() {
performWithStandardData( performWithStandardData(
new TestCode() { new TestCode() {