diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/AbstractPluralAttributeElementBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/AbstractPluralAttributeElementBinding.java index 502b1cf7f6..c7d380f938 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/AbstractPluralAttributeElementBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/AbstractPluralAttributeElementBinding.java @@ -23,7 +23,8 @@ */ package org.hibernate.metamodel.spi.binding; -import org.hibernate.metamodel.spi.relational.Value; +import java.util.Collections; +import java.util.List; /** * Basic contract describing the commonality between the various types of collection element mappings. @@ -33,7 +34,7 @@ import org.hibernate.metamodel.spi.relational.Value; public abstract class AbstractPluralAttributeElementBinding implements PluralAttributeElementBinding { private final AbstractPluralAttributeBinding pluralAttributeBinding; private final HibernateTypeDescriptor hibernateTypeDescriptor = new HibernateTypeDescriptor(); - private Value relationalValue; + private List relationalValueBindings; AbstractPluralAttributeElementBinding(AbstractPluralAttributeBinding pluralAttributeBinding) { this.pluralAttributeBinding = pluralAttributeBinding; @@ -50,7 +51,11 @@ public abstract class AbstractPluralAttributeElementBinding implements PluralAtt } @Override - public Value getRelationalValue() { - return relationalValue; + public List getRelationalValueBindings() { + return relationalValueBindings; + } + + protected void setRelationalValueBindings(List relationalValueBindings) { + this.relationalValueBindings = Collections.unmodifiableList( relationalValueBindings ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/BasicPluralAttributeElementBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/BasicPluralAttributeElementBinding.java index 1f70a61e9d..b80d5f9cca 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/BasicPluralAttributeElementBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/BasicPluralAttributeElementBinding.java @@ -23,7 +23,6 @@ */ package org.hibernate.metamodel.spi.binding; -import java.util.Collections; import java.util.List; /** @@ -33,7 +32,6 @@ import java.util.List; * @author Gail Badner */ public class BasicPluralAttributeElementBinding extends AbstractPluralAttributeElementBinding { - private List relationalValueBindings; private boolean hasDerivedValue; private boolean isNullable = true; @@ -42,18 +40,14 @@ public class BasicPluralAttributeElementBinding extends AbstractPluralAttributeE super( binding ); } - public List getRelationalValueBindings() { - return relationalValueBindings; - } - @Override public PluralAttributeElementNature getPluralAttributeElementNature() { return PluralAttributeElementNature.BASIC; } public void setRelationalValueBindings(List relationalValueBindings) { - this.relationalValueBindings = Collections.unmodifiableList( relationalValueBindings ); - for ( RelationalValueBinding relationalValueBinding : relationalValueBindings ) { + super.setRelationalValueBindings( relationalValueBindings ); + for ( RelationalValueBinding relationalValueBinding : getRelationalValueBindings() ) { this.hasDerivedValue = this.hasDerivedValue || relationalValueBinding.isDerived(); this.isNullable = this.isNullable && relationalValueBinding.isNullable(); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/PluralAttributeElementBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/PluralAttributeElementBinding.java index 242b691807..b0add09c89 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/PluralAttributeElementBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/spi/binding/PluralAttributeElementBinding.java @@ -23,7 +23,7 @@ */ package org.hibernate.metamodel.spi.binding; -import org.hibernate.metamodel.spi.relational.Value; +import java.util.List; /** * Common information pertaining to the binding of the various plural attribute natures (one-to-many, basic, etc). @@ -44,7 +44,7 @@ public interface PluralAttributeElementBinding { * * @return The relation information. */ - public Value getRelationalValue(); + public List getRelationalValueBindings(); /** * Retrieves an enumeration describing the mapping nature of the collection's elements. diff --git a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java index 4692dec5ba..5fb81cd944 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/collection/AbstractCollectionPersister.java @@ -83,6 +83,7 @@ import org.hibernate.metamodel.spi.binding.CustomSQL; import org.hibernate.metamodel.spi.binding.PluralAttributeAssociationElementBinding; import org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding; import org.hibernate.metamodel.spi.binding.PluralAttributeKeyBinding; +import org.hibernate.metamodel.spi.binding.RelationalValueBinding; import org.hibernate.metamodel.spi.domain.PluralAttributeNature; import org.hibernate.metamodel.spi.relational.DerivedValue; import org.hibernate.metamodel.spi.relational.TableSpecification; @@ -737,7 +738,9 @@ public abstract class AbstractCollectionPersister } elementNodeName = elemNode; - int elementSpan = collection.getCollectionTable() == null ? 0 : collection.getCollectionTable().values().size(); + int elementSpan = collection.getPluralAttributeElementBinding().getRelationalValueBindings() == null ? + 0 : + collection.getPluralAttributeElementBinding().getRelationalValueBindings().size(); elementColumnAliases = new String[elementSpan]; elementColumnNames = new String[elementSpan]; elementColumnWriters = new String[elementSpan]; @@ -751,7 +754,8 @@ public abstract class AbstractCollectionPersister boolean hasNotNullableColumns = false; int j = 0; if ( elementSpan > 0 ) { - for ( Value value : collection.getCollectionTable().values() ) { + for ( RelationalValueBinding relationalValueBinding : collection.getPluralAttributeElementBinding().getRelationalValueBindings() ) { + final Value value = relationalValueBinding.getValue(); elementColumnAliases[j] = value.getAlias( dialect ); if ( DerivedValue.class.isInstance( value ) ) { DerivedValue form = (DerivedValue) value; diff --git a/hibernate-core/src/matrix/java/org/hibernate/test/collection/set/element/SimpleElementSetTest.java b/hibernate-core/src/matrix/java/org/hibernate/test/collection/set/element/SimpleElementSetTest.java index 0a696e8553..cd128958ae 100755 --- a/hibernate-core/src/matrix/java/org/hibernate/test/collection/set/element/SimpleElementSetTest.java +++ b/hibernate-core/src/matrix/java/org/hibernate/test/collection/set/element/SimpleElementSetTest.java @@ -55,7 +55,6 @@ public class SimpleElementSetTest extends BaseCoreFunctionalTestCase { } @Test - @FailureExpected( jiraKey = "HHH-6525") public void testLoad() throws HibernateException, SQLException { Session s = openSession(); Transaction t = s.beginTransaction(); @@ -69,7 +68,7 @@ public class SimpleElementSetTest extends BaseCoreFunctionalTestCase { s = openSession(); t = s.beginTransaction(); u = (User) s.get( User.class, "username" ); - assertFalse( Hibernate.isInitialized( u.getSessionAttributeNames() ) ); + assertTrue( Hibernate.isInitialized( u.getSessionAttributeNames() ) ); assertEquals( 2, u.getSessionAttributeNames().size() ); assertTrue( Hibernate.isInitialized( u.getSessionAttributeNames() ) ); assertTrue( u.getSessionAttributeNames().contains( "name" ) );