HHH-7736 join subclass support and set mutable property to the plural attribute binding

This commit is contained in:
Strong Liu 2013-01-14 02:19:40 +08:00
parent 9b7462c39c
commit 0bed7eaad9
34 changed files with 205 additions and 186 deletions

View File

@ -513,7 +513,7 @@ public final class StringHelper {
*/ */
public static String generateAlias(String description, int unique) { public static String generateAlias(String description, int unique) {
return generateAliasRoot(description) + return generateAliasRoot(description) +
Integer.toString(unique) + unique +
'_'; '_';
} }

View File

@ -182,6 +182,7 @@ import org.jboss.logging.Logger;
* @author Hardy Ferentschik * @author Hardy Ferentschik
* @author Gail Badner * @author Gail Badner
* @author Brett Meyer * @author Brett Meyer
* @author Strong Liu
*/ */
public class Binder { public class Binder {
private static final CoreMessageLogger log = Logger.getMessageLogger( private static final CoreMessageLogger log = Logger.getMessageLogger(
@ -1410,7 +1411,7 @@ public class Binder {
attributeBinding.setCustomSqlDelete( attributeSource.getCustomSqlDelete() ); attributeBinding.setCustomSqlDelete( attributeSource.getCustomSqlDelete() );
attributeBinding.setCustomSqlDeleteAll( attributeSource.getCustomSqlDeleteAll() ); attributeBinding.setCustomSqlDeleteAll( attributeSource.getCustomSqlDeleteAll() );
attributeBinding.setWhere( attributeSource.getWhere() ); attributeBinding.setWhere( attributeSource.getWhere() );
attributeBinding.setMutable( attributeSource.isMutable() );
switch ( attributeSource.getElementSource().getNature() ) { switch ( attributeSource.getElementSource().getNature() ) {
case BASIC: case BASIC:
bindBasicPluralAttribute( attributeSource, attributeBinding, reflectedCollectionJavaTypes ); bindBasicPluralAttribute( attributeSource, attributeBinding, reflectedCollectionJavaTypes );

View File

@ -257,6 +257,11 @@ public class PluralAttributeSourceImpl implements PluralAttributeSource, Orderab
return associationAttribute.getOrderBy(); return associationAttribute.getOrderBy();
} }
@Override
public boolean isMutable() {
return associationAttribute.isMutable();
}
@Override @Override
public boolean isOrdered() { public boolean isOrdered() {
return StringHelper.isNotEmpty( getOrder() ); return StringHelper.isNotEmpty( getOrder() );

View File

@ -85,6 +85,7 @@ public class PluralAssociationAttribute extends AssociationAttribute {
private LazyCollectionOption lazyOption; private LazyCollectionOption lazyOption;
private final boolean isCollectionIdPresent; private final boolean isCollectionIdPresent;
private final boolean mutable;
public static PluralAssociationAttribute createPluralAssociationAttribute( public static PluralAssociationAttribute createPluralAssociationAttribute(
@ -207,6 +208,8 @@ public class PluralAssociationAttribute extends AssociationAttribute {
inverseForeignKeyName = null; inverseForeignKeyName = null;
} }
this.mutable = JandexHelper.getSingleAnnotation( annotations(), HibernateDotNames.IMMUTABLE ) == null;
this.caching = determineCachingSettings(); this.caching = determineCachingSettings();
this.isExtraLazy = lazyOption == LazyCollectionOption.EXTRA; this.isExtraLazy = lazyOption == LazyCollectionOption.EXTRA;
this.customPersister = determineCustomPersister(); this.customPersister = determineCustomPersister();
@ -487,6 +490,9 @@ public class PluralAssociationAttribute extends AssociationAttribute {
} }
public boolean isMutable() {
return mutable;
}
} }

View File

@ -334,13 +334,7 @@ public class EntityClass extends ConfiguredClass {
HibernateDotNames.IMMUTABLE, HibernateDotNames.IMMUTABLE,
ClassInfo.class ClassInfo.class
); );
if ( hibernateImmutableAnnotation != null ) { isImmutable = hibernateImmutableAnnotation != null ;
isImmutable = true;
}
else {
isImmutable = false;
}
final AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation( final AnnotationInstance whereAnnotation = JandexHelper.getSingleAnnotation(
getClassInfo(), HibernateDotNames.WHERE getClassInfo(), HibernateDotNames.WHERE
); );

View File

@ -191,6 +191,11 @@ public abstract class AbstractPluralAttributeSourceImpl
return elementClassReference; return elementClassReference;
} }
@Override
public boolean isMutable() {
return pluralAttributeElement.isMutable();
}
@Override @Override
public String getMappedBy() { public String getMappedBy() {
return null; return null;

View File

@ -98,9 +98,9 @@ class ColumnSourceImpl
@Override @Override
public Size getSize() { public Size getSize() {
return new Size( return new Size(
Helper.getValue( columnElement.getPrecision(), -1 ), Helper.getValue( columnElement.getPrecision(), Size.DEFAULT_PRECISION ),
Helper.getValue( columnElement.getScale(), -1 ), Helper.getValue( columnElement.getScale(), Size.DEFAULT_SCALE ),
Helper.getValue( columnElement.getLength(), -1 ), Helper.getValue( columnElement.getLength(), Size.DEFAULT_LENGTH ),
Size.LobMultiplier.NONE Size.LobMultiplier.NONE
); );
} }

View File

@ -26,7 +26,6 @@ package org.hibernate.metamodel.spi.binding;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -38,9 +37,6 @@ import org.hibernate.internal.FilterConfiguration;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.ValueHolder; import org.hibernate.internal.util.ValueHolder;
import org.hibernate.internal.util.collections.ArrayHelper; import org.hibernate.internal.util.collections.ArrayHelper;
import org.hibernate.internal.util.collections.JoinedIterable;
import org.hibernate.internal.util.collections.JoinedIterator;
import org.hibernate.internal.util.collections.SingletonIterator;
import org.hibernate.metamodel.spi.domain.AttributeContainer; import org.hibernate.metamodel.spi.domain.AttributeContainer;
import org.hibernate.metamodel.spi.domain.Entity; import org.hibernate.metamodel.spi.domain.Entity;
import org.hibernate.metamodel.spi.domain.SingularAttribute; import org.hibernate.metamodel.spi.domain.SingularAttribute;
@ -58,6 +54,7 @@ import org.hibernate.tuple.entity.EntityTuplizer;
* @author Steve Ebersole * @author Steve Ebersole
* @author Hardy Ferentschik * @author Hardy Ferentschik
* @author Gail Badner * @author Gail Badner
* @author Strong Liu
*/ */
public class EntityBinding extends AbstractAttributeBindingContainer implements Filterable { public class EntityBinding extends AbstractAttributeBindingContainer implements Filterable {
private static final String NULL_DISCRIMINATOR_MATCH_VALUE = "null"; private static final String NULL_DISCRIMINATOR_MATCH_VALUE = "null";
@ -592,8 +589,7 @@ public class EntityBinding extends AbstractAttributeBindingContainer implements
*/ */
public int getAttributeBindingClosureSpan() { public int getAttributeBindingClosureSpan() {
// TODO: update account for join attribute bindings // TODO: update account for join attribute bindings
return isRoot() ? getNonIdAttributeBindingClosure().length : return getAttributeBindingClosure().length;
superEntityBinding.getAttributeBindingClosureSpan() + getNonIdAttributeBindingClosure().length;
} }
/** /**
@ -606,23 +602,35 @@ public class EntityBinding extends AbstractAttributeBindingContainer implements
public AttributeBinding[] getAttributeBindingClosure() { public AttributeBinding[] getAttributeBindingClosure() {
// TODO: update size to account for joins // TODO: update size to account for joins
if ( isRoot() ) { if ( isRoot() ) {
return getNonIdAttributeBindingClosure(); return attributeBindingMapInternal().values()
.toArray( new AttributeBinding[attributeBindingMapInternal().size()] );
} }
else { else {
return ArrayHelper.join( return ArrayHelper.join(
superEntityBinding.getAttributeBindingClosure(), superEntityBinding.getAttributeBindingClosure(),
getNonIdAttributeBindingClosure() attributeBindingMapInternal().values()
.toArray( new AttributeBinding[attributeBindingMapInternal().size()] )
); );
} }
} }
private AttributeBinding[] getNonIdAttributeBindingClosure() { public AttributeBinding[] getNonIdAttributeBindingClosure(){
List<AttributeBinding> list = new ArrayList<AttributeBinding>(); // TODO: update size to account for joins
attributeBindings(); if ( isRoot() ) {
for ( final AttributeBinding ab : attributeBindings() ) { return internalGetNonIdAttributeBindingClosure();
if(ab instanceof CompositeAttributeBinding){
} }
else {
return ArrayHelper.join(
superEntityBinding.getNonIdAttributeBindingClosure(),
internalGetNonIdAttributeBindingClosure()
);
}
}
private AttributeBinding[] internalGetNonIdAttributeBindingClosure() {
List<AttributeBinding> list = new ArrayList<AttributeBinding>();
for ( final AttributeBinding ab : attributeBindings() ) {
boolean isId = getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( ab ); boolean isId = getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( ab );
if ( !isId ) { if ( !isId ) {
list.add( ab ); list.add( ab );
@ -739,13 +747,26 @@ public class EntityBinding extends AbstractAttributeBindingContainer implements
results = ArrayHelper.join( results = ArrayHelper.join(
results, results,
subEntityBinding.getNonIdAttributeBindingClosure() subEntityBinding.attributeBindingMapInternal().values().toArray( new AttributeBinding[subEntityBinding.attributeBindingMapInternal().size()] )
); );
// TODO: if EntityBinding.attributeBindings() excludes joined attributes, then they need to be added here // TODO: if EntityBinding.attributeBindings() excludes joined attributes, then they need to be added here
} }
return results; return results;
} }
public AttributeBinding[] getNonIdEntitiesAttributeBindingClosure() {
AttributeBinding[] results = getNonIdAttributeBindingClosure();
for ( EntityBinding subEntityBinding : getPreOrderSubEntityBindingClosure() ) {
// only add attribute bindings declared for the subEntityBinding
results = ArrayHelper.join(
results,
subEntityBinding.internalGetNonIdAttributeBindingClosure()
);
// TODO: if EntityBinding.attributeBindings() excludes joined attributes, then they need to be added here
}
return results;
}
public boolean isClassOrSuperclassSecondaryTable(SecondaryTable secondaryTable) { public boolean isClassOrSuperclassSecondaryTable(SecondaryTable secondaryTable) {
String secondaryTableName = secondaryTable.getSecondaryTableReference().getLogicalName().getText(); String secondaryTableName = secondaryTable.getSecondaryTableReference().getLogicalName().getText();

View File

@ -140,19 +140,17 @@ public class EntityIdentifier {
public Class getIdClassClass() { public Class getIdClassClass() {
ensureBound(); ensureBound();
if ( ! isNonAggregatedComposite() ) { ensureNonAggregatedComposite();
throw new UnsupportedOperationException(
String.format(
"Entity identifiers of nature %s does not support idClasses.",
entityIdentifierBinding.getNature()
)
);
}
return ( (NonAggregatedCompositeIdentifierBindingImpl) entityIdentifierBinding ).getIdClassClass(); return ( (NonAggregatedCompositeIdentifierBindingImpl) entityIdentifierBinding ).getIdClassClass();
} }
public String getIdClassPropertyAccessorName() { public String getIdClassPropertyAccessorName() {
ensureBound(); ensureBound();
ensureNonAggregatedComposite();
return ( (NonAggregatedCompositeIdentifierBindingImpl) entityIdentifierBinding ).getIdClassPropertyAccessorName();
}
private void ensureNonAggregatedComposite() {
if ( ! isNonAggregatedComposite() ) { if ( ! isNonAggregatedComposite() ) {
throw new UnsupportedOperationException( throw new UnsupportedOperationException(
String.format( String.format(
@ -161,7 +159,6 @@ public class EntityIdentifier {
) )
); );
} }
return ( (NonAggregatedCompositeIdentifierBindingImpl) entityIdentifierBinding ).getIdClassPropertyAccessorName();
} }
public boolean isIdentifierMapper() { public boolean isIdentifierMapper() {
@ -409,6 +406,10 @@ public class EntityIdentifier {
return (CompositeAttributeBinding) getAttributeBinding(); return (CompositeAttributeBinding) getAttributeBinding();
} }
public boolean isIdentifierAttributeBinding(AttributeBinding attributeBinding) { public boolean isIdentifierAttributeBinding(AttributeBinding attributeBinding) {
if ( !isIdentifierMapper() && getNonAggregatedCompositeAttributeBinding().equals( attributeBinding ) ) {
return true;
}
for ( AttributeBinding idAttributeBindings : getNonAggregatedCompositeAttributeBinding().attributeBindings() ) { for ( AttributeBinding idAttributeBindings : getNonAggregatedCompositeAttributeBinding().attributeBindings() ) {
if ( idAttributeBindings.equals( attributeBinding ) ) { if ( idAttributeBindings.equals( attributeBinding ) ) {
return true; return true;

View File

@ -43,7 +43,7 @@ import org.hibernate.dialect.Dialect;
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class ForeignKey extends AbstractConstraint implements Constraint, Exportable { public class ForeignKey extends AbstractConstraint {
private static final Logger LOG = Logger.getLogger( ForeignKey.class ); private static final Logger LOG = Logger.getLogger( ForeignKey.class );
private static final String ON_DELETE = " on delete "; private static final String ON_DELETE = " on delete ";

View File

@ -31,7 +31,7 @@ import org.hibernate.dialect.Dialect;
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class Index extends AbstractConstraint implements Constraint { public class Index extends AbstractConstraint{
protected Index(Table table, String name) { protected Index(Table table, String name) {
super( table, name ); super( table, name );
} }

View File

@ -34,7 +34,7 @@ import org.hibernate.dialect.Dialect;
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class PrimaryKey extends AbstractConstraint implements Constraint, Exportable { public class PrimaryKey extends AbstractConstraint {
private static final String GENERATED_NAME_PREFIX = "PK"; private static final String GENERATED_NAME_PREFIX = "PK";

View File

@ -31,7 +31,7 @@ import org.hibernate.dialect.Dialect;
* @author Gavin King * @author Gavin King
* @author Steve Ebersole * @author Steve Ebersole
*/ */
public class UniqueKey extends AbstractConstraint implements Constraint { public class UniqueKey extends AbstractConstraint {
private static final String GENERATED_NAME_PREFIX = "UK"; private static final String GENERATED_NAME_PREFIX = "UK";
protected UniqueKey(Table table, String name) { protected UniqueKey(Table table, String name) {

View File

@ -61,6 +61,8 @@ public interface PluralAttributeSource
public boolean isInverse(); public boolean isInverse();
public boolean isMutable();
public String getCustomLoaderName(); public String getCustomLoaderName();
public CustomSQL getCustomSqlInsert(); public CustomSQL getCustomSqlInsert();

View File

@ -851,10 +851,10 @@ public abstract class AbstractEntityPersister
this.factory = factory; this.factory = factory;
this.cacheAccessStrategy = cacheAccessStrategy; this.cacheAccessStrategy = cacheAccessStrategy;
this.naturalIdRegionAccessStrategy = naturalIdRegionAccessStrategy; this.naturalIdRegionAccessStrategy = naturalIdRegionAccessStrategy;
this.isLazyPropertiesCacheable = this.isLazyPropertiesCacheable = entityBinding.getHierarchyDetails()
entityBinding.getHierarchyDetails().getCaching() == null ? .getCaching() == null || entityBinding.getHierarchyDetails()
false : .getCaching()
entityBinding.getHierarchyDetails().getCaching().isCacheLazyProperties(); .isCacheLazyProperties();
this.entityMetamodel = new EntityMetamodel( entityBinding, factory ); this.entityMetamodel = new EntityMetamodel( entityBinding, factory );
this.entityTuplizer = this.entityMetamodel.getTuplizer(); this.entityTuplizer = this.entityMetamodel.getTuplizer();
int batch = entityBinding.getBatchSize(); int batch = entityBinding.getBatchSize();
@ -951,12 +951,7 @@ public abstract class AbstractEntityPersister
int i = 0; int i = 0;
boolean foundFormula = false; boolean foundFormula = false;
for ( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : entityBinding.getNonIdAttributeBindingClosure() ) {
if ( entityBinding.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( attributeBinding ) ) {
// entity identifier is not considered a "normal" property
continue;
}
thisClassProperties.add( attributeBinding ); thisClassProperties.add( attributeBinding );
propertySubclassNames[i] = ( (EntityBinding) attributeBinding.getContainer() ).getEntity().getName(); propertySubclassNames[i] = ( (EntityBinding) attributeBinding.getContainer() ).getEntity().getName();
@ -1054,12 +1049,7 @@ public abstract class AbstractEntityPersister
List<Boolean> columnSelectables = new ArrayList<Boolean>(); List<Boolean> columnSelectables = new ArrayList<Boolean>();
List<Boolean> propNullables = new ArrayList<Boolean>(); List<Boolean> propNullables = new ArrayList<Boolean>();
for ( AttributeBinding attributeBinding : entityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : entityBinding.getNonIdEntitiesAttributeBindingClosure() ) {
if ( entityBinding.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( attributeBinding ) ) {
// entity identifier is not considered a "normal" property
continue;
}
names.add( attributeBinding.getAttribute().getName() ); names.add( attributeBinding.getAttribute().getName() );
classes.add( ( (EntityBinding) attributeBinding.getContainer() ).getEntity().getName() ); classes.add( ( (EntityBinding) attributeBinding.getContainer() ).getEntity().getName() );
boolean isDefinedBySubclass = ! thisClassProperties.contains( attributeBinding ); boolean isDefinedBySubclass = ! thisClassProperties.contains( attributeBinding );
@ -1199,6 +1189,9 @@ public abstract class AbstractEntityPersister
this.cacheEntryHelper = buildCacheEntryHelper(); this.cacheEntryHelper = buildCacheEntryHelper();
} }
protected static String getTemplateFromString(String string, SessionFactoryImplementor factory) { protected static String getTemplateFromString(String string, SessionFactoryImplementor factory) {
return string == null ? return string == null ?
null : null :
@ -4384,10 +4377,6 @@ public abstract class AbstractEntityPersister
return entityMetamodel.getTuplizer().createProxy( id, session ); return entityMetamodel.getTuplizer().createProxy( id, session );
} }
public String toString() {
return StringHelper.unqualify( getClass().getName() ) +
'(' + entityMetamodel.getName() + ')';
}
public final String selectFragment( public final String selectFragment(
Joinable rhs, Joinable rhs,
@ -4989,6 +4978,11 @@ public abstract class AbstractEntityPersister
return lazyPropertyColumnAliases; return lazyPropertyColumnAliases;
} }
public String toString() {
return StringHelper.unqualify( getClass().getName() ) +
'(' + entityMetamodel.getName() + ')';
}
/** /**
* Consolidated these onto a single helper because the 2 pieces work in tandem. * Consolidated these onto a single helper because the 2 pieces work in tandem.
*/ */

View File

@ -25,6 +25,8 @@ package org.hibernate.persister.entity;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
@ -54,7 +56,6 @@ import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.metamodel.spi.binding.AttributeBinding; import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding; import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SecondaryTable; import org.hibernate.metamodel.spi.binding.SecondaryTable;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding; import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
@ -62,13 +63,15 @@ import org.hibernate.metamodel.spi.relational.PrimaryKey;
import org.hibernate.metamodel.spi.relational.TableSpecification; import org.hibernate.metamodel.spi.relational.TableSpecification;
import org.hibernate.sql.CaseFragment; import org.hibernate.sql.CaseFragment;
import org.hibernate.sql.SelectFragment; import org.hibernate.sql.SelectFragment;
import org.hibernate.type.*; import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.Type;
/** /**
* An <tt>EntityPersister</tt> implementing the normalized "table-per-subclass" * An <tt>EntityPersister</tt> implementing the normalized "table-per-subclass"
* mapping strategy * mapping strategy
* *
* @author Gavin King * @author Gavin King
* @author Strong Liu
*/ */
public class JoinedSubclassEntityPersister extends AbstractEntityPersister { public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
@ -689,13 +692,13 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
final TableSpecification[] tables = entityBinding.getTableClosure(); final TableSpecification[] tables = entityBinding.getTableClosure();
final SecondaryTable[] secondaryTables = entityBinding.getSecondaryTableClosure(); final SecondaryTable[] secondaryTables = entityBinding.getSecondaryTableClosure();
final String[] synchronizedTableNames = entityBinding.getSynchronizedTableNameClosure(); final String[] synchronizedTableNames = entityBinding.getSynchronizedTableNameClosure();
final AttributeBinding[] attributeBindings = entityBinding.getAttributeBindingClosure(); final AttributeBinding[] attributeBindings = entityBinding.getNonIdAttributeBindingClosure();
//todo the count of these two are not equal, which they should be //todo the count of these two are not equal, which they should be
final EntityBinding[] preOrderSubEntityBindings = entityBinding.getPreOrderSubEntityBindingClosure(); final EntityBinding[] preOrderSubEntityBindings = entityBinding.getPreOrderSubEntityBindingClosure();
final EntityBinding[] postOrderSubEntityBindings = entityBinding.getPostOrderSubEntityBindingClosure(); final EntityBinding[] postOrderSubEntityBindings = entityBinding.getPostOrderSubEntityBindingClosure();
final TableSpecification[] subTables = entityBinding.getPreOrderSubTableClosure(); final TableSpecification[] subTables = entityBinding.getPreOrderSubTableClosure();
final SecondaryTable[] subSecondaryTables = entityBinding.getSubEntitySecondaryTables(); final SecondaryTable[] subSecondaryTables = entityBinding.getSubEntitySecondaryTables();
final AttributeBinding[] allAttributeBindings = entityBinding.getEntitiesAttributeBindingClosure(); final AttributeBinding[] allAttributeBindings = entityBinding.getNonIdEntitiesAttributeBindingClosure();
final int idColumnSpan = getIdentifierColumnSpan(); final int idColumnSpan = getIdentifierColumnSpan();
coreTableSpan = tables.length; coreTableSpan = tables.length;
@ -924,11 +927,9 @@ public class JoinedSubclassEntityPersister extends AbstractEntityPersister {
valueBindings = singularAttributeBinding.getRelationalValueBindings(); valueBindings = singularAttributeBinding.getRelationalValueBindings();
} }
else { else {
PluralAttributeBinding pluralAttributeBinding = PluralAttributeBinding.class.cast( attributeBinding ); valueBindings = Collections.EMPTY_LIST;
valueBindings = pluralAttributeBinding.getPluralAttributeElementBinding().getRelationalValueBindings();
} }
RelationalValueBinding valueBinding = valueBindings.get( 0 ); TableSpecification table = attributeBinding.getContainer().seekEntityBinding().getPrimaryTable();// valueBinding.getValue().getTable();
TableSpecification table = valueBinding.getValue().getTable();
final String tableName = table.getQualifiedName( factory.getDialect() ); final String tableName = table.getQualifiedName( factory.getDialect() );
if ( i < hydrateSpan ) { if ( i < hydrateSpan ) {
propertyTableNumbers[i] = getTableId( tableName, tableNames ); propertyTableNumbers[i] = getTableId( tableName, tableNames );

View File

@ -23,8 +23,10 @@
* *
*/ */
package org.hibernate.persister.entity; package org.hibernate.persister.entity;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
@ -53,9 +55,9 @@ import org.hibernate.mapping.Subclass;
import org.hibernate.mapping.Table; import org.hibernate.mapping.Table;
import org.hibernate.mapping.Value; import org.hibernate.mapping.Value;
import org.hibernate.metamodel.spi.binding.AttributeBinding; import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.CustomSQL;
import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.EntityDiscriminator; import org.hibernate.metamodel.spi.binding.EntityDiscriminator;
import org.hibernate.metamodel.spi.binding.EntityIdentifier;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding; import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SecondaryTable; import org.hibernate.metamodel.spi.binding.SecondaryTable;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding; import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
@ -648,16 +650,11 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
} }
// PROPERTIES // PROPERTIES
propertyTableNumbers = new int[ getPropertySpan() ]; propertyTableNumbers = new int[ getPropertySpan() ];
int i=0; int i=0;
for( AttributeBinding attributeBinding : entityBinding.getAttributeBindingClosure() ) { for( AttributeBinding attributeBinding : entityBinding.getNonIdAttributeBindingClosure() ) {
// TODO: fix when joins are working (HHH-6391) // TODO: fix when joins are working (HHH-6391)
//propertyTableNumbers[i++] = entityBinding.getJoinNumber( attributeBinding); //propertyTableNumbers[i++] = entityBinding.getJoinNumber( attributeBinding);
if ( entityBinding.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( attributeBinding ) ) {
continue; // skip identifier binding
}
final int tableNumber; final int tableNumber;
if ( attributeBinding.getAttribute().isSingular() ) { if ( attributeBinding.getAttribute().isSingular() ) {
SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding; SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
@ -675,11 +672,7 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
ArrayList<Integer> formulaJoinedNumbers = new ArrayList<Integer>(); ArrayList<Integer> formulaJoinedNumbers = new ArrayList<Integer>();
ArrayList<Integer> propertyJoinNumbers = new ArrayList<Integer>(); ArrayList<Integer> propertyJoinNumbers = new ArrayList<Integer>();
for ( AttributeBinding attributeBinding : entityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : entityBinding.getNonIdEntitiesAttributeBindingClosure() ) {
if ( entityBinding.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( attributeBinding ) ) {
continue; // skip identifier binding
}
if ( attributeBinding.getAttribute().isSingular() ) { if ( attributeBinding.getAttribute().isSingular() ) {
SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding; SingularAttributeBinding singularAttributeBinding = (SingularAttributeBinding) attributeBinding;
int join = entityBinding.getSecondaryTableNumber( singularAttributeBinding ); int join = entityBinding.getSecondaryTableNumber( singularAttributeBinding );
@ -752,7 +745,6 @@ public class SingleTableEntityPersister extends AbstractEntityPersister {
postConstruct( mapping ); postConstruct( mapping );
} }
protected boolean isInverseTable(int j) { protected boolean isInverseTable(int j) {
return isInverseTable[j]; return isInverseTable[j];
} }

View File

@ -27,7 +27,10 @@ import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import org.jboss.logging.Logger;
import org.hibernate.dialect.Dialect; import org.hibernate.dialect.Dialect;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.type.LiteralType; import org.hibernate.type.LiteralType;
/** /**
@ -39,7 +42,9 @@ public class Insert {
private Dialect dialect; private Dialect dialect;
private String tableName; private String tableName;
private String comment; private String comment;
private Map columns = new LinkedHashMap(); private Map<String, String> columns = new LinkedHashMap<String, String>();
private static final CoreMessageLogger LOG = Logger.getMessageLogger(CoreMessageLogger.class,
Insert.class.getName());
public Insert(Dialect dialect) { public Insert(Dialect dialect) {
this.dialect = dialect; this.dialect = dialect;
@ -59,8 +64,8 @@ public class Insert {
} }
public Insert addColumns(String[] columnNames) { public Insert addColumns(String[] columnNames) {
for ( int i=0; i<columnNames.length; i++ ) { for ( String columnName : columnNames ) {
addColumn( columnNames[i] ); addColumn( columnName );
} }
return this; return this;
} }
@ -84,7 +89,10 @@ public class Insert {
} }
public Insert addColumn(String columnName, String valueExpression) { public Insert addColumn(String columnName, String valueExpression) {
columns.put(columnName, valueExpression); String old = columns.put( columnName, valueExpression );
if ( old != null ) {
LOG.warn( "Duplicated column name " + columnName + " is being added into Insert, this is more likely a hibernate internal issue" );
}
return this; return this;
} }
@ -112,12 +120,12 @@ public class Insert {
} }
buf.append("insert into ") buf.append("insert into ")
.append(tableName); .append(tableName);
if ( columns.size()==0 ) { if ( columns.isEmpty() ) {
buf.append(' ').append( dialect.getNoColumnsInsertString() ); buf.append(' ').append( dialect.getNoColumnsInsertString() );
} }
else { else {
buf.append(" ("); buf.append(" (");
Iterator iter = columns.keySet().iterator(); Iterator<String> iter = columns.keySet().iterator();
while ( iter.hasNext() ) { while ( iter.hasNext() ) {
buf.append( iter.next() ); buf.append( iter.next() );
if ( iter.hasNext() ) { if ( iter.hasNext() ) {

View File

@ -241,11 +241,7 @@ public abstract class AbstractEntityTuplizer implements EntityTuplizer {
boolean foundCustomAccessor = false; boolean foundCustomAccessor = false;
int i = 0; int i = 0;
for ( AttributeBinding property : mappingInfo.getAttributeBindingClosure() ) { for ( AttributeBinding property : mappingInfo.getNonIdAttributeBindingClosure() ) {
if ( mappingInfo.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( property ) ) {
continue; // ID binding processed above
}
//TODO: redesign how PropertyAccessors are acquired... //TODO: redesign how PropertyAccessors are acquired...
getters[ i ] = buildPropertyGetter( property ); getters[ i ] = buildPropertyGetter( property );
setters[ i ] = buildPropertySetter( property ); setters[ i ] = buildPropertySetter( property );

View File

@ -398,22 +398,7 @@ public class EntityMetamodel implements Serializable {
boolean hasLazy = false; boolean hasLazy = false;
// TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding // TODO: Fix after HHH-6337 is fixed; for now assume entityBinding is the root binding
final EntityIdentifier rootEntityIdentifier = entityBinding.getHierarchyDetails().getEntityIdentifier(); final AttributeBinding [] attributeBindings = entityBinding.getNonIdAttributeBindingClosure();
// entityBinding.getAttributeClosureSpan() includes the identifier binding;
// "properties" here excludes the ID, so subtract 1 if the identifier binding is non-null
int identifierAttributeBindingSpan;
if ( rootEntityIdentifier.getAttributeBinding() == null ) {
identifierAttributeBindingSpan = 0;
}
else if ( rootEntityIdentifier.isNonAggregatedComposite() ) {
identifierAttributeBindingSpan =
( (CompositeAttributeBinding) rootEntityIdentifier.getAttributeBinding() ).attributeBindingSpan();
}
else {
identifierAttributeBindingSpan = 1;
}
final AttributeBinding [] attributeBindings = entityBinding.getAttributeBindingClosure();
propertySpan = attributeBindings.length; propertySpan = attributeBindings.length;
properties = new StandardProperty[propertySpan]; properties = new StandardProperty[propertySpan];
@ -445,11 +430,6 @@ public class EntityMetamodel implements Serializable {
boolean foundUpdateableNaturalIdProperty = false; boolean foundUpdateableNaturalIdProperty = false;
for ( AttributeBinding attributeBinding : attributeBindings ) { for ( AttributeBinding attributeBinding : attributeBindings ) {
if ( entityBinding.getHierarchyDetails().getEntityIdentifier().isIdentifierAttributeBinding( attributeBinding ) ) {
// skip the identifier attribute binding
continue;
}
if ( attributeBinding == entityBinding.getHierarchyDetails().getEntityVersion().getVersioningAttributeBinding() ) { if ( attributeBinding == entityBinding.getHierarchyDetails().getEntityVersion().getVersioningAttributeBinding() ) {
tempVersionProperty = i; tempVersionProperty = i;
properties[i] = PropertyFactory.buildVersionProperty( properties[i] = PropertyFactory.buildVersionProperty(

View File

@ -135,22 +135,22 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(),
directAttributeBindings.iterator().next() directAttributeBindings.iterator().next()
); );
assertEquals( 0, noInheritanceEntityBinding.getAttributeBindingClosureSpan() ); assertEquals( 1, noInheritanceEntityBinding.getAttributeBindingClosureSpan() );
Iterator<AttributeBinding> iterator = noInheritanceEntityBinding.attributeBindings().iterator(); Iterator<AttributeBinding> iterator = noInheritanceEntityBinding.attributeBindings().iterator();
assertTrue( iterator.hasNext() ); assertTrue( iterator.hasNext() );
assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), iterator.next() ); assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), iterator.next() );
assertFalse( iterator.hasNext() ); assertFalse( iterator.hasNext() );
AttributeBinding[] attributeBindings = noInheritanceEntityBinding.getAttributeBindingClosure(); AttributeBinding[] attributeBindings = noInheritanceEntityBinding.getAttributeBindingClosure();
assertTrue( attributeBindings.length == 0 ); assertTrue( attributeBindings.length > 0 );
// int index =0; int index =0;
// assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), attributeBindings[index++] ); assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), attributeBindings[index++] );
// assertFalse( index < attributeBindings.length ); assertFalse( index < attributeBindings.length );
attributeBindings = noInheritanceEntityBinding.getEntitiesAttributeBindingClosure(); attributeBindings = noInheritanceEntityBinding.getEntitiesAttributeBindingClosure();
// int index = 0; index = 0;
assertFalse( attributeBindings.length > 0 ); assertTrue( attributeBindings.length > 0 );
// assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), attributeBindings[index++] ); assertSame( noInheritanceEntityBinding.getHierarchyDetails().getEntityIdentifier().getAttributeBinding(), attributeBindings[index++] );
// assertFalse( index < attributeBindings.length ); assertFalse( index < attributeBindings.length );
} }
@Test @Test
@ -193,19 +193,19 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
} }
assertEquals( 1, directAttributeBindings.size() ); assertEquals( 1, directAttributeBindings.size() );
assertTrue( directAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( directAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertEquals( 0, rootEntityBinding.getAttributeBindingClosureSpan() ); assertEquals( 1, rootEntityBinding.getAttributeBindingClosureSpan() );
Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>(); Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>();
for ( AttributeBinding attributeBinding : rootEntityBinding.getAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : rootEntityBinding.getAttributeBindingClosure() ) {
assertTrue( attributeBindingClosure.add( attributeBinding ) ); assertTrue( attributeBindingClosure.add( attributeBinding ) );
} }
assertEquals( 0, attributeBindingClosure.size() ); assertEquals( 1, attributeBindingClosure.size() );
assertFalse( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>(); Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>();
for ( AttributeBinding subAttributeBinding : rootEntityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding subAttributeBinding : rootEntityBinding.getEntitiesAttributeBindingClosure() ) {
assertTrue( subAttributeBindings.add( subAttributeBinding ) ); assertTrue( subAttributeBindings.add( subAttributeBinding ) );
} }
assertEquals( 3, subAttributeBindings.size() ); assertEquals( 4, subAttributeBindings.size() );
assertFalse( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) ); assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) );
assertTrue( subAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) ); assertTrue( subAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) );
@ -310,20 +310,20 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
} }
assertEquals( 1, directAttributeBindings.size() ); assertEquals( 1, directAttributeBindings.size() );
assertTrue( directAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) ); assertTrue( directAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) );
assertEquals( 1, otherSubclassEntityBinding.getAttributeBindingClosureSpan() ); assertEquals( 2, otherSubclassEntityBinding.getAttributeBindingClosureSpan() );
Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>(); Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>();
for ( AttributeBinding attributeBinding : otherSubclassEntityBinding.getAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : otherSubclassEntityBinding.getAttributeBindingClosure() ) {
assertTrue( attributeBindingClosure.add( attributeBinding ) ); assertTrue( attributeBindingClosure.add( attributeBinding ) );
} }
assertEquals(1, attributeBindingClosure.size() ); assertEquals(2, attributeBindingClosure.size() );
assertFalse( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( attributeBindingClosure.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) ); assertTrue( attributeBindingClosure.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) );
Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>(); Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>();
for ( AttributeBinding subAttributeBinding : otherSubclassEntityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding subAttributeBinding : otherSubclassEntityBinding.getEntitiesAttributeBindingClosure() ) {
assertTrue( subAttributeBindings.add( subAttributeBinding ) ); assertTrue( subAttributeBindings.add( subAttributeBinding ) );
} }
assertEquals( 1, subAttributeBindings.size() ); assertEquals( 2, subAttributeBindings.size() );
assertFalse( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( subAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) ); assertTrue( subAttributeBindings.contains( otherSubclassEntityBinding.locateAttributeBinding( "otherName" ) ) );
} }
@ -364,20 +364,20 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
} }
assertEquals( 1, directAttributeBindings.size() ); assertEquals( 1, directAttributeBindings.size() );
assertTrue( directAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( directAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
assertEquals( 1, subclassEntityBinding.getAttributeBindingClosureSpan() ); assertEquals( 2, subclassEntityBinding.getAttributeBindingClosureSpan() );
Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>(); Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>();
for ( AttributeBinding attributeBinding : subclassEntityBinding.getAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : subclassEntityBinding.getAttributeBindingClosure() ) {
assertTrue( attributeBindingClosure.add( attributeBinding ) ); assertTrue( attributeBindingClosure.add( attributeBinding ) );
} }
assertEquals( 1, attributeBindingClosure.size() ); assertEquals( 2, attributeBindingClosure.size() );
assertFalse( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( attributeBindingClosure.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( attributeBindingClosure.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>(); Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>();
for ( AttributeBinding subAttributeBinding : subclassEntityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding subAttributeBinding : subclassEntityBinding.getEntitiesAttributeBindingClosure() ) {
assertTrue( subAttributeBindings.add( subAttributeBinding ) ); assertTrue( subAttributeBindings.add( subAttributeBinding ) );
} }
assertEquals( 2, subAttributeBindings.size() ); assertEquals( 3, subAttributeBindings.size() );
assertFalse( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) ); assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) );
} }
@ -411,21 +411,21 @@ public class InheritanceBindingTest extends BaseAnnotationBindingTestCase {
} }
assertEquals( 1, directAttributeBindings.size() ); assertEquals( 1, directAttributeBindings.size() );
assertTrue( directAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) ); assertTrue( directAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) );
assertEquals( 2, subclassOfSubclassEntityBinding.getAttributeBindingClosureSpan() ); assertEquals( 3, subclassOfSubclassEntityBinding.getAttributeBindingClosureSpan() );
Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>(); Set<AttributeBinding> attributeBindingClosure = new HashSet<AttributeBinding>();
for ( AttributeBinding attributeBinding : subclassOfSubclassEntityBinding.getAttributeBindingClosure() ) { for ( AttributeBinding attributeBinding : subclassOfSubclassEntityBinding.getAttributeBindingClosure() ) {
assertTrue( attributeBindingClosure.add( attributeBinding ) ); assertTrue( attributeBindingClosure.add( attributeBinding ) );
} }
assertEquals( 2, attributeBindingClosure.size() ); assertEquals( 3, attributeBindingClosure.size() );
assertFalse( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( attributeBindingClosure.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( attributeBindingClosure.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( attributeBindingClosure.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
assertTrue( attributeBindingClosure.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) ); assertTrue( attributeBindingClosure.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) );
Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>(); Set<AttributeBinding> subAttributeBindings = new HashSet<AttributeBinding>();
for ( AttributeBinding subAttributeBinding : subclassOfSubclassEntityBinding.getEntitiesAttributeBindingClosure() ) { for ( AttributeBinding subAttributeBinding : subclassOfSubclassEntityBinding.getEntitiesAttributeBindingClosure() ) {
assertTrue( subAttributeBindings.add( subAttributeBinding ) ); assertTrue( subAttributeBindings.add( subAttributeBinding ) );
} }
assertEquals( 2, subAttributeBindings.size() ); assertEquals( 3, subAttributeBindings.size() );
assertFalse( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) ); assertTrue( subAttributeBindings.contains( rootEntityBinding.locateAttributeBinding( "id" ) ) );
assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) ); assertTrue( subAttributeBindings.contains( subclassEntityBinding.locateAttributeBinding( "name" ) ) );
assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) ); assertTrue( subAttributeBindings.contains( subclassOfSubclassEntityBinding.locateAttributeBinding( "otherOtherName" ) ) );
} }

View File

@ -40,9 +40,10 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class DerivedIdentitySimpleParentIdClassDepTest extends BaseCoreFunctionalTestCase { public class DerivedIdentitySimpleParentIdClassDepTest extends BaseCoreFunctionalTestCase {
@FailureExpectedWithNewMetamodel
@Test @Test
@FailureExpectedWithNewMetamodel
public void testManyToOne() throws Exception { public void testManyToOne() throws Exception {
assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) ); assertTrue( SchemaUtil.isColumnPresent( "Dependent", "emp_empId", metadata() ) );
assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", metadata() ) ); assertTrue( ! SchemaUtil.isColumnPresent( "Dependent", "emp", metadata() ) );

View File

@ -34,7 +34,6 @@ import org.hibernate.HibernateException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.ServiceRegistryBuilder; import org.hibernate.testing.ServiceRegistryBuilder;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -84,7 +83,6 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testImmutableCollection() { public void testImmutableCollection() {
Country country = new Country(); Country country = new Country();
country.setName("Germany"); country.setName("Germany");

View File

@ -82,7 +82,6 @@ import static org.junit.Assert.fail;
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@RequiresDialectFeature(DialectChecks.SupportsSequences.class) @RequiresDialectFeature(DialectChecks.SupportsSequences.class)
@FailureExpectedWithNewMetamodel
public class CriteriaQueryTest extends BaseCoreFunctionalTestCase { public class CriteriaQueryTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {
@ -1733,6 +1732,7 @@ public class CriteriaQueryTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testCriteriaCollectionOfValue() { public void testCriteriaCollectionOfValue() {
Session session = openSession(); Session session = openSession();
Transaction t = session.beginTransaction(); Transaction t = session.beginTransaction();

View File

@ -47,7 +47,7 @@ import static org.junit.Assert.assertTrue;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewMetamodel //@FailureExpectedWithNewMetamodel
public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase { public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
StateProvince stateProvince; StateProvince stateProvince;
private Zoo zoo1; private Zoo zoo1;
@ -205,6 +205,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOrderByNoSelectAliasRef() { public void testOrderByNoSelectAliasRef() {
createData(); createData();
@ -346,6 +347,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOrderBySelectAliasRef() { public void testOrderBySelectAliasRef() {
createData(); createData();
@ -523,6 +525,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOrderByEntityWithFetchJoinedCollection() { public void testOrderByEntityWithFetchJoinedCollection() {
createData(); createData();
@ -544,6 +547,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOrderBySelectNewArgAliasRef() { public void testOrderBySelectNewArgAliasRef() {
createData(); createData();
@ -588,6 +592,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test(timeout = 5 * 60 * 1000) @Test(timeout = 5 * 60 * 1000)
@FailureExpectedWithNewMetamodel
public void testOrderBySelectNewMapArgAliasRef() { public void testOrderBySelectNewMapArgAliasRef() {
createData(); createData();
@ -638,6 +643,7 @@ public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOrderByAggregatedArgAliasRef() { public void testOrderByAggregatedArgAliasRef() {
createData(); createData();

View File

@ -56,7 +56,7 @@ import static org.junit.Assert.fail;
* *
* @author Max Rydahl Andersen * @author Max Rydahl Andersen
*/ */
@FailureExpectedWithNewMetamodel //@FailureExpectedWithNewMetamodel
public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase { public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
private boolean initialVersion2SqlFlagValue; private boolean initialVersion2SqlFlagValue;
@ -161,6 +161,7 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
@Test @Test
@TestForIssue( jiraKey = "HHH-1724" ) @TestForIssue( jiraKey = "HHH-1724" )
@FailureExpectedWithNewMetamodel
public void testCriteriaAggregationReturnType() { public void testCriteriaAggregationReturnType() {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
@ -222,6 +223,7 @@ public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testCountReturnValues() { public void testCountReturnValues() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -50,7 +50,6 @@ import static org.junit.Assert.fail;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewMetamodel
public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase { public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {
@ -148,6 +147,7 @@ public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase
comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewMetamodel
public void testScrollingJoinFetchesSingleRowResultSet() { public void testScrollingJoinFetchesSingleRowResultSet() {
Session s = openSession(); Session s = openSession();
Transaction txn = s.beginTransaction(); Transaction txn = s.beginTransaction();
@ -274,6 +274,7 @@ public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase
value = DialectChecks.SupportsResultSetPositioningOnForwardOnlyCursorCheck.class, value = DialectChecks.SupportsResultSetPositioningOnForwardOnlyCursorCheck.class,
comment = "Driver does not support result set positioning methods on forward-only cursors" comment = "Driver does not support result set positioning methods on forward-only cursors"
) )
@FailureExpectedWithNewMetamodel
public void testScrollingJoinFetchesForward() { public void testScrollingJoinFetchesForward() {
TestData data = new TestData(); TestData data = new TestData();
data.prepare(); data.prepare();
@ -306,6 +307,7 @@ public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase
comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewMetamodel
public void testScrollingJoinFetchesReverse() { public void testScrollingJoinFetchesReverse() {
TestData data = new TestData(); TestData data = new TestData();
data.prepare(); data.prepare();
@ -340,6 +342,7 @@ public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase
comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewMetamodel
public void testScrollingJoinFetchesPositioning() { public void testScrollingJoinFetchesPositioning() {
TestData data = new TestData(); TestData data = new TestData();
data.prepare(); data.prepare();

View File

@ -42,7 +42,7 @@ import static org.junit.Assert.fail;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewMetamodel //@FailureExpectedWithNewMetamodel
public class WithClauseTest extends BaseCoreFunctionalTestCase { public class WithClauseTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {
@ -50,6 +50,7 @@ public class WithClauseTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testWithClauseFailsWithFetch() { public void testWithClauseFailsWithFetch() {
TestData data = new TestData(); TestData data = new TestData();
data.prepare(); data.prepare();
@ -113,6 +114,7 @@ public class WithClauseTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testWithClause() { public void testWithClause() {
TestData data = new TestData(); TestData data = new TestData();
data.prepare(); data.prepare();

View File

@ -35,7 +35,6 @@ import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.proxy.HibernateProxy; import org.hibernate.proxy.HibernateProxy;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.TextType; import org.hibernate.type.TextType;
@ -852,7 +851,6 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testImmutableCollectionWithUpdate() { public void testImmutableCollectionWithUpdate() {
clearCounts(); clearCounts();
@ -1074,7 +1072,6 @@ public class ImmutableTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testImmutableCollectionWithMerge() { public void testImmutableCollectionWithMerge() {
clearCounts(); clearCounts();

View File

@ -31,7 +31,6 @@ import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -51,7 +50,6 @@ public class KeyManyToOneTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testCriteriaRestrictionOnKeyManyToOne() { public void testCriteriaRestrictionOnKeyManyToOne() {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();

View File

@ -28,7 +28,6 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@FailureExpectedWithNewMetamodel
public class MultiTableTest extends LegacyTestCase { public class MultiTableTest extends LegacyTestCase {
@Override @Override
protected boolean isCleanupTestDataRequired() { protected boolean isCleanupTestDataRequired() {
@ -59,6 +58,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testFetchOneToMany() throws Exception { public void testFetchOneToMany() throws Exception {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
@ -69,6 +69,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testNarrow() throws Exception { public void testNarrow() throws Exception {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
@ -80,6 +81,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testJoins() throws Exception { public void testJoins() throws Exception {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
@ -103,6 +105,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testSubclassCollection() throws Exception { public void testSubclassCollection() throws Exception {
//if ( getDialect() instanceof HSQLDialect ) return; //TODO: figure out why!? //if ( getDialect() instanceof HSQLDialect ) return; //TODO: figure out why!?
Session s = openSession(); Session s = openSession();
@ -194,6 +197,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testQueries() throws Exception { public void testQueries() throws Exception {
Session s = openSession(); Session s = openSession();
s.beginTransaction(); s.beginTransaction();
@ -220,6 +224,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testConstraints() throws Exception { public void testConstraints() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -239,6 +244,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testMultiTable() throws Exception { public void testMultiTable() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -377,6 +383,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testMultiTableGeneratedId() throws Exception { public void testMultiTableGeneratedId() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -495,6 +502,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testMultiTableCollections() throws Exception { public void testMultiTableCollections() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -543,6 +551,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testMultiTableManyToOne() throws Exception { public void testMultiTableManyToOne() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -576,6 +585,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testMultiTableNativeId() throws Exception { public void testMultiTableNativeId() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();
@ -589,6 +599,7 @@ public class MultiTableTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testCollection() throws Exception { public void testCollection() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -51,7 +51,6 @@ import org.hibernate.dialect.SybaseAnywhereDialect;
import org.hibernate.dialect.SybaseDialect; import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect; import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -59,7 +58,6 @@ import static org.junit.Assert.assertTrue;
@SuppressWarnings( {"UnnecessaryUnboxing", "UnnecessaryBoxing"}) @SuppressWarnings( {"UnnecessaryUnboxing", "UnnecessaryBoxing"})
//@FailureExpectedWithNewMetamodel
public class SQLFunctionsTest extends LegacyTestCase { public class SQLFunctionsTest extends LegacyTestCase {
private static final Logger log = Logger.getLogger( SQLFunctionsTest.class ); private static final Logger log = Logger.getLogger( SQLFunctionsTest.class );
@ -217,7 +215,6 @@ public class SQLFunctionsTest extends LegacyTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testBroken() throws Exception { public void testBroken() throws Exception {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -49,7 +49,6 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewMetamodel
public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase { public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase {
private static class TextAsMaterializedClobType extends AbstractSingleColumnStandardBasicType<String> { private static class TextAsMaterializedClobType extends AbstractSingleColumnStandardBasicType<String> {
public final static TextAsMaterializedClobType INSTANCE = new TextAsMaterializedClobType(); public final static TextAsMaterializedClobType INSTANCE = new TextAsMaterializedClobType();
@ -77,6 +76,7 @@ public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewMetamodel
public void testOneToOneFormula() { public void testOneToOneFormula() {
Person p = new Person(); Person p = new Person();
p.setName("Gavin King"); p.setName("Gavin King");

View File

@ -28,7 +28,6 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertNull; import static org.junit.Assert.assertNull;
@ -36,7 +35,6 @@ import static org.junit.Assert.assertNull;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewMetamodel
public class OptionalOneToOneTest extends BaseCoreFunctionalTestCase { public class OptionalOneToOneTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {