HHH-7436 : Add support for many-to-many associations to new metamodel

HHH-7436 : Add support for many-to-many associations to new metamodel

HHH-7436 : Add support for many-to-many associations to new metamodel
This commit is contained in:
Gail Badner 2012-11-15 17:31:21 -08:00
parent 61039c62d8
commit f75c7eff59
41 changed files with 547 additions and 97 deletions

View File

@ -41,6 +41,7 @@ import org.hibernate.TruthValue;
import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.engine.FetchStyle;
import org.hibernate.engine.FetchTiming;
import org.hibernate.engine.config.spi.ConfigurationService;
import org.hibernate.engine.spi.CascadeStyle;
@ -76,6 +77,7 @@ import org.hibernate.metamodel.spi.binding.IndexedPluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.InheritanceType;
import org.hibernate.metamodel.spi.binding.ManyToOneAttributeBinding;
import org.hibernate.metamodel.spi.binding.MetaAttribute;
import org.hibernate.metamodel.spi.binding.ManyToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.OneToManyPluralAttributeElementBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeElementBinding;
@ -83,6 +85,7 @@ import org.hibernate.metamodel.spi.binding.PluralAttributeIndexBinding;
import org.hibernate.metamodel.spi.binding.PluralAttributeKeyBinding;
import org.hibernate.metamodel.spi.binding.RelationalValueBinding;
import org.hibernate.metamodel.spi.binding.SecondaryTable;
import org.hibernate.metamodel.spi.binding.SetBinding;
import org.hibernate.metamodel.spi.binding.SingularAssociationAttributeBinding;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding;
import org.hibernate.metamodel.spi.binding.SingularAttributeBinding.NaturalIdMutability;
@ -123,6 +126,7 @@ import org.hibernate.metamodel.spi.source.IdentifierSource;
import org.hibernate.metamodel.spi.source.InLineViewSource;
import org.hibernate.metamodel.spi.source.IndexedPluralAttributeSource;
import org.hibernate.metamodel.spi.source.LocalBindingContext;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.MappingDefaults;
import org.hibernate.metamodel.spi.source.MetaAttributeContext;
import org.hibernate.metamodel.spi.source.MetaAttributeSource;
@ -386,7 +390,8 @@ public class Binder {
attributeBindingContainer,
attributeSource,
attribute,
attributeBindingContainer.getPrimaryTable() );
attributeBindingContainer.getPrimaryTable(),
false);
final BasicAttributeBinding attributeBinding =
attributeBindingContainer.makeBasicAttributeBinding(
attribute,
@ -433,7 +438,9 @@ public class Binder {
);
}
attributeBinding.getPluralAttributeKeyBinding().setInverse( false );
TableSpecification collectionTable = createCollectionTable( attributeBinding, attributeSource );
TableSpecification collectionTable = createBasicCollectionTable(
attributeBinding, attributeSource.getCollectionTableSpecificationSource()
);
if ( StringHelper.isNotEmpty( attributeSource.getCollectionTableComment() ) ) {
collectionTable.addComment( attributeSource.getCollectionTableComment() );
}
@ -454,10 +461,11 @@ public class Binder {
elementBinding.getPluralAttributeBinding().getContainer(),
relationalValueSourceContainer,
elementBinding.getPluralAttributeBinding().getAttribute(),
elementBinding.getPluralAttributeBinding().getPluralAttributeKeyBinding().getCollectionTable() ) );
elementBinding.getPluralAttributeBinding().getPluralAttributeKeyBinding().getCollectionTable(),
false) );
}
private void bindBasicSetElementTablePrimaryKey(final PluralAttributeBinding attributeBinding) {
private void bindBasicSetCollectionTablePrimaryKey(final SetBinding attributeBinding) {
final BasicPluralAttributeElementBinding elementBinding =
( BasicPluralAttributeElementBinding ) attributeBinding.getPluralAttributeElementBinding();
if ( elementBinding.getNature() != PluralAttributeElementBinding.Nature.BASIC ) {
@ -466,16 +474,7 @@ public class Binder {
elementBinding.getNature() ) );
}
if ( hasAnyNonNullableColumns( elementBinding.getRelationalValueBindings() ) ) {
final PrimaryKey primaryKey = attributeBinding.getPluralAttributeKeyBinding().getCollectionTable().getPrimaryKey();
final ForeignKey foreignKey = attributeBinding.getPluralAttributeKeyBinding().getForeignKey();
for ( final Column foreignKeyColumn : foreignKey.getSourceColumns() ) {
primaryKey.addColumn( foreignKeyColumn );
}
for ( final RelationalValueBinding elementValueBinding : elementBinding.getRelationalValueBindings() ) {
if ( elementValueBinding.getValue() instanceof Column && !elementValueBinding.isNullable() ) {
primaryKey.addColumn( ( Column ) elementValueBinding.getValue() );
}
}
bindSetCollectionTablePrimaryKey( attributeBinding );
}
else {
// for backward compatibility, allow a set with no not-null
@ -484,6 +483,20 @@ public class Binder {
}
}
private void bindSetCollectionTablePrimaryKey(final SetBinding attributeBinding) {
final PluralAttributeElementBinding elementBinding = attributeBinding.getPluralAttributeElementBinding();
final PrimaryKey primaryKey = attributeBinding.getPluralAttributeKeyBinding().getCollectionTable().getPrimaryKey();
final ForeignKey foreignKey = attributeBinding.getPluralAttributeKeyBinding().getForeignKey();
for ( final Column foreignKeyColumn : foreignKey.getSourceColumns() ) {
primaryKey.addColumn( foreignKeyColumn );
}
for ( final RelationalValueBinding elementValueBinding : elementBinding.getRelationalValueBindings() ) {
if ( elementValueBinding.getValue() instanceof Column && !elementValueBinding.isNullable() ) {
primaryKey.addColumn( ( Column ) elementValueBinding.getValue() );
}
}
}
private void bindCompositeCollectionElement(
final CompositePluralAttributeElementBinding elementBinding,
final CompositePluralAttributeElementSource elementSource,
@ -554,7 +567,9 @@ public class Binder {
indexedAttributeBinding.getContainer(),
attributeSource,
indexedAttributeBinding.getAttribute(),
indexedAttributeBinding.getPluralAttributeKeyBinding().getCollectionTable() ).get( 0 ).getValue() );
indexedAttributeBinding.getPluralAttributeKeyBinding().getCollectionTable(),
attributeBinding.getPluralAttributeElementBinding().getNature() != PluralAttributeElementBinding.Nature.ONE_TO_MANY )
.get( 0 ).getValue() );
if ( attributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.ONE_TO_MANY ) {
if ( !Column.class.isInstance( indexBinding.getIndexRelationalValue() ) ) {
throw new NotYetImplementedException( "derived value as collection index is not supported yet." );
@ -581,7 +596,13 @@ public class Binder {
final PluralAttributeKeyBinding keyBinding = attributeBinding.getPluralAttributeKeyBinding();
List<RelationalValueBinding> sourceColumnBindings =
bindValues( attributeBindingContainer, keySource, attributeBinding.getAttribute(), collectionTable );
bindValues(
attributeBindingContainer,
keySource,
attributeBinding.getAttribute(),
collectionTable,
attributeBinding.getPluralAttributeElementBinding().getNature() != PluralAttributeElementBinding.Nature.ONE_TO_MANY
);
// Determine if the foreign key (source) column is updatable and also extract the columns out
// of the RelationalValueBindings.
boolean isInsertable = false;
@ -642,8 +663,7 @@ public class Binder {
private void bindCollectionTablePrimaryKey(
final AbstractPluralAttributeBinding attributeBinding,
final PluralAttributeSource attributeSource,
final HibernateTypeHelper.ReflectedCollectionJavaTypes reflectedCollectionJavaTypes ) {
final PluralAttributeSource attributeSource) {
PluralAttributeSource.Nature pluralAttributeNature = attributeSource.getNature();
if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.ONE_TO_MANY
|| pluralAttributeNature == PluralAttributeSource.Nature.BAG ) {
@ -651,14 +671,33 @@ public class Binder {
}
if ( attributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.BASIC ) {
if ( pluralAttributeNature == PluralAttributeSource.Nature.SET ) {
bindBasicSetElementTablePrimaryKey( attributeBinding );
bindBasicSetCollectionTablePrimaryKey( (SetBinding) attributeBinding );
} else if (
pluralAttributeNature == PluralAttributeSource.Nature.LIST
|| pluralAttributeNature == PluralAttributeSource.Nature.MAP
|| pluralAttributeNature == PluralAttributeSource.Nature.ARRAY ) {
bindIndexedTablePrimaryKey( ( IndexedPluralAttributeBinding ) attributeBinding );
bindIndexedCollectionTablePrimaryKey( (IndexedPluralAttributeBinding) attributeBinding );
} else {
throw new NotYetImplementedException( "Only Sets with basic elements are supported so far." );
throw new NotYetImplementedException(
String.format( "%s of basic elements is not supported yet.", pluralAttributeNature )
);
}
}
else if ( attributeBinding.getPluralAttributeElementBinding().getNature() == PluralAttributeElementBinding.Nature.MANY_TO_MANY ) {
if ( ! attributeBinding.getPluralAttributeKeyBinding().isInverse() ) {
if ( pluralAttributeNature == PluralAttributeSource.Nature.SET ) {
bindSetCollectionTablePrimaryKey( (SetBinding) attributeBinding );
}
else if (
pluralAttributeNature == PluralAttributeSource.Nature.LIST
|| pluralAttributeNature == PluralAttributeSource.Nature.MAP) {
bindIndexedCollectionTablePrimaryKey( (IndexedPluralAttributeBinding) attributeBinding );
}
else {
throw new NotYetImplementedException(
String.format( "Many-to-many %s is not supported yet.", pluralAttributeNature )
);
}
}
}
}
@ -1125,7 +1164,7 @@ public class Binder {
}
}
private void bindIndexedTablePrimaryKey( IndexedPluralAttributeBinding attributeBinding ) {
private void bindIndexedCollectionTablePrimaryKey(IndexedPluralAttributeBinding attributeBinding) {
final PrimaryKey primaryKey = attributeBinding.getPluralAttributeKeyBinding().getCollectionTable().getPrimaryKey();
final ForeignKey foreignKey = attributeBinding.getPluralAttributeKeyBinding().getForeignKey();
final PluralAttributeIndexBinding indexBinding = attributeBinding.getPluralAttributeIndexBinding();
@ -1134,7 +1173,7 @@ public class Binder {
}
final Value value = indexBinding.getIndexRelationalValue();
if ( value instanceof Column ) {
primaryKey.addColumn( ( Column ) value );
primaryKey.addColumn( (Column) value );
}
}
@ -1188,8 +1227,8 @@ public class Binder {
if( attribute == null ){
attribute = createSingularAttribute( attributeBindingContainer, attributeSource );
}
// TODO: figure out which table is used (could be secondary table...)
final TableSpecification table = attributeBindingContainer.getPrimaryTable();
final TableSpecification table = locateTableSpecificationForAttribute( attributeBindingContainer, attributeSource );
//find the referenced entitybinding
ValueHolder< Class< ? >> referencedJavaTypeValue = createSingularAttributeJavaType( attribute );
@ -1233,8 +1272,9 @@ public class Binder {
attributeBindingContainer.seekEntityBinding().getEntity().getName(),
table.getLogicalName().getText(),
referencedAttributeBinding
));
),
false
);
// todo : currently a chicken-egg problem here between creating the attribute binding and binding its FK values...
// now we have everything to create a ManyToOneAttributeBinding
@ -1289,6 +1329,18 @@ public class Binder {
return attributeBinding;
}
private TableSpecification locateTableSpecificationForAttribute(
AttributeBindingContainer attributeBindingContainer,
SingularAttributeSource attributeSource) {
String tableName = null;
if ( ! attributeSource.relationalValueSources().isEmpty() ) {
tableName = attributeSource.relationalValueSources().get( 0 ).getContainingTableName();
}
return tableName == null ?
attributeBindingContainer.getPrimaryTable() :
attributeBindingContainer.seekEntityBinding().locateTable( tableName );
}
private AbstractPluralAttributeBinding bindMapAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource,
@ -1432,6 +1484,82 @@ public class Binder {
elementBinding.setCascadeStyle( determineCascadeStyle( elementSource.getCascadeStyles() ) );
}
private void bindManyToManyCollectionElement(
final ManyToManyPluralAttributeElementBinding elementBinding,
final ManyToManyPluralAttributeElementSource elementSource,
final EntityBinding referencedEntityBinding,
final String defaultElementJavaTypeName) {
elementBinding.setRelationalValueBindings(
bindValues(
elementBinding.getPluralAttributeBinding().getContainer(),
elementSource,
elementBinding.getPluralAttributeBinding().getAttribute(),
elementBinding.getPluralAttributeBinding().getPluralAttributeKeyBinding().getCollectionTable(),
true
)
);
if ( !elementBinding.getPluralAttributeBinding().getPluralAttributeKeyBinding().isInverse() ) {
bindCollectionTableElementForeignKey( elementBinding, elementSource, referencedEntityBinding );
}
final HibernateTypeDescriptor hibernateTypeDescriptor = elementBinding.getHibernateTypeDescriptor();
bindHibernateTypeDescriptor(
hibernateTypeDescriptor,
referencedEntityBinding.getEntity().getName(),
null,
defaultElementJavaTypeName
);
Type resolvedElementType = metadata.getTypeResolver().getTypeFactory().manyToOne(
referencedEntityBinding.getEntity().getName(),
elementSource.getReferencedEntityAttributeName(),
false,
false,
true,
false, //TODO: should be attributeBinding.isIgnoreNotFound(),
false
);
bindHibernateResolvedType( elementBinding.getHibernateTypeDescriptor(), resolvedElementType );
typeHelper.bindJdbcDataType(
resolvedElementType,
elementBinding.getRelationalValueBindings()
);
elementBinding.setCascadeStyle( determineCascadeStyle( elementSource.getCascadeStyles() ) );
elementBinding.setManyToManyWhere( elementSource.getWhere() );
elementBinding.setManyToManyOrderBy( elementSource.getOrderBy() );
//TODO: initialize filters from elementSource
}
private void bindCollectionTableElementForeignKey(
ManyToManyPluralAttributeElementBinding elementBinding,
final ManyToManyPluralAttributeElementSource elementSource,
final EntityBinding referencedEntityBinding) {
List<Column> sourceColumns = new ArrayList<Column>( elementBinding.getRelationalValueBindings().size() );
for ( RelationalValueBinding relationalValueBinding : elementBinding.getRelationalValueBindings() ) {
final Value value = relationalValueBinding.getValue();
// todo : currently formulas are not supported here... :(
if ( !Column.class.isInstance( value ) ) {
throw new NotYetImplementedException(
"Derived values are not supported when creating a foreign key that targets columns." );
}
sourceColumns.add( (Column) value );
}
List<Column> targetColumns =
determineForeignKeyTargetColumns(
referencedEntityBinding,
elementSource
);
final String foreignKeyName =
StringHelper.isEmpty( elementSource.getExplicitForeignKeyName() )
? null
: quotedIdentifier( elementSource.getExplicitForeignKeyName() );
bindForeignKey( foreignKeyName, sourceColumns, targetColumns );
}
// TODO: should this be moved to CascadeStyles as a static method?
// TODO: sources already factor in default cascade; should that be done here instead?
private CascadeStyle determineCascadeStyle(Iterable<CascadeStyle> cascadeStyles) {
@ -1517,6 +1645,30 @@ public class Binder {
}
private void bindManyToManyCollectionKey(
final AbstractPluralAttributeBinding attributeBinding,
final PluralAttributeSource attributeSource,
final EntityBinding referencedEntityBinding) {
if ( attributeSource.getElementSource().getNature() != PluralAttributeElementSource.Nature.MANY_TO_MANY ) {
throw new AssertionFailure(
String.format(
"Expected many-to-many attribute binding; instead got {%s}",
attributeSource.getElementSource().getNature()
)
);
}
final boolean isInverse = attributeSource.isInverse();
final TableSpecification collectionTable = createManyToManyCollectionTable(
attributeBinding,
isInverse,
attributeSource.getCollectionTableSpecificationSource(),
referencedEntityBinding
);
final PluralAttributeKeyBinding keyBinding = attributeBinding.getPluralAttributeKeyBinding();
keyBinding.setInverse( isInverse );
bindCollectionTableForeignKey( attributeBinding, attributeSource.getKeySource(), collectionTable );
}
private AbstractPluralAttributeBinding bindPluralAttribute(
final AttributeBindingContainer attributeBindingContainer,
final PluralAttributeSource attributeSource ) {
@ -1571,6 +1723,9 @@ public class Binder {
// Note: Collection types do not have a relational model
attributeBinding.setFetchTiming( attributeSource.getFetchTiming() );
attributeBinding.setFetchStyle( attributeSource.getFetchStyle() );
if ( attributeSource.getFetchStyle() == FetchStyle.SUBSELECT ) {
attributeBindingContainer.seekEntityBinding().setSubselectLoadableCollections( true );
}
attributeBinding.setCaching( attributeSource.getCaching() );
if ( StringHelper.isNotEmpty( attributeSource.getCustomPersisterClassName() ) ) {
attributeBinding.setExplicitPersisterClass( bindingContexts.peek().< CollectionPersister >locateClassByName(
@ -1599,7 +1754,7 @@ public class Binder {
elementSource.getReferencedEntityName() :
defaultElementJavaTypeName;
if ( referencedEntityName == null ) {
bindingContext().makeMappingException( String.format( "The mapping for the entity associated with one-to-many attribute (%s) is undefined.",
throw bindingContext().makeMappingException( String.format( "The mapping for the entity associated with one-to-many attribute (%s) is undefined.",
createAttributePath( attributeBinding )
) );
}
@ -1612,6 +1767,28 @@ public class Binder {
defaultElementJavaTypeName
);
}
else if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.MANY_TO_MANY ) {
final ManyToManyPluralAttributeElementSource elementSource =
(ManyToManyPluralAttributeElementSource) attributeSource.getElementSource();
final String defaultElementJavaTypeName = defaultCollectionElementJavaTypeName( reflectedCollectionJavaTypes );
String referencedEntityName =
elementSource.getReferencedEntityName() != null ?
elementSource.getReferencedEntityName() :
defaultElementJavaTypeName;
if ( referencedEntityName == null ) {
throw bindingContext().makeMappingException( String.format( "The mapping for the entity associated with one-to-many attribute (%s) is undefined.",
createAttributePath( attributeBinding )
) );
}
EntityBinding referencedEntityBinding = findOrBindingEntityBinding( referencedEntityName );
bindManyToManyCollectionKey( attributeBinding, attributeSource, referencedEntityBinding );
bindManyToManyCollectionElement(
(ManyToManyPluralAttributeElementBinding) attributeBinding.getPluralAttributeElementBinding(),
(ManyToManyPluralAttributeElementSource) attributeSource.getElementSource(),
referencedEntityBinding,
defaultElementJavaTypeName
);
}
else if ( attributeSource.getElementSource().getNature() == PluralAttributeElementSource.Nature.AGGREGATE ) {
bindNonAssociationCollectionKey( attributeBinding, attributeSource );
bindCompositeCollectionElement(
@ -1621,9 +1798,12 @@ public class Binder {
);
}
else {
throw new NotYetImplementedException( String.format(
"Support for collection elements of type %s not yet implemented",
attributeSource.getElementSource().getNature() ) );
throw bindingContext().makeMappingException(
String.format(
"Unknown type of collection element: %s",
attributeSource.getElementSource().getNature()
)
);
}
if ( attributeSource instanceof IndexedPluralAttributeSource ) {
@ -1633,7 +1813,7 @@ public class Binder {
defaultCollectionIndexJavaTypeName( reflectedCollectionJavaTypes ) );
}
bindCollectionTablePrimaryKey( attributeBinding, attributeSource, reflectedCollectionJavaTypes );
bindCollectionTablePrimaryKey( attributeBinding, attributeSource );
metadata.addCollection( attributeBinding );
return attributeBinding;
}
@ -1843,7 +2023,8 @@ public class Binder {
final AttributeBindingContainer attributeBindingContainer,
final RelationalValueSourceContainer valueSourceContainer,
final Attribute attribute,
final TableSpecification defaultTable) {
final TableSpecification defaultTable,
final boolean forceNonNullable) {
final List<DefaultNamingStrategy> list = new ArrayList<DefaultNamingStrategy>( 1 );
list.add(
new DefaultNamingStrategy() {
@ -1853,7 +2034,7 @@ public class Binder {
}
}
);
return bindValues( attributeBindingContainer, valueSourceContainer, attribute, defaultTable, list );
return bindValues( attributeBindingContainer, valueSourceContainer, attribute, defaultTable, list, forceNonNullable );
}
private List< RelationalValueBinding > bindValues(
@ -1861,7 +2042,8 @@ public class Binder {
final RelationalValueSourceContainer valueSourceContainer,
final Attribute attribute,
final TableSpecification defaultTable,
final List<DefaultNamingStrategy> defaultNamingStrategyList) {
final List<DefaultNamingStrategy> defaultNamingStrategyList,
final boolean forceNonNullable) {
final List<RelationalValueBinding> valueBindings = new ArrayList<RelationalValueBinding>();
final NaturalIdMutability naturalIdMutability = SingularAttributeSource.class.isInstance(
valueSourceContainer
@ -1869,13 +2051,14 @@ public class Binder {
: NaturalIdMutability.NOT_NATURAL_ID;
final boolean isNaturalId = naturalIdMutability != NaturalIdMutability.NOT_NATURAL_ID;
final boolean isImmutableNaturalId = isNaturalId && (naturalIdMutability == NaturalIdMutability.IMMUTABLE);
final boolean reallyForceNonNullable = forceNonNullable || isNaturalId;
if ( valueSourceContainer.relationalValueSources().isEmpty() ) {
for ( DefaultNamingStrategy defaultNamingStrategy : defaultNamingStrategyList ) {
final String columnName =
quotedIdentifier( defaultNamingStrategy.defaultName() );
final Column column = defaultTable.locateOrCreateColumn( columnName );
column.setNullable( !isNaturalId && valueSourceContainer.areValuesNullableByDefault() );
column.setNullable( !reallyForceNonNullable && valueSourceContainer.areValuesNullableByDefault() );
if ( isNaturalId ) {
addUniqueConstraintForNaturalIdColumn( defaultTable, column );
}
@ -1905,7 +2088,14 @@ public class Binder {
toBoolean(
columnSource.isIncludedInUpdate(),
valueSourceContainer.areValuesIncludedInUpdateByDefault() );
Column column = createColumn( table, columnSource, name, isNaturalId, valueSourceContainer.areValuesNullableByDefault(), true );
Column column = createColumn(
table,
columnSource,
name,
reallyForceNonNullable,
valueSourceContainer.areValuesNullableByDefault(),
true
);
if(isNaturalId){
addUniqueConstraintForNaturalIdColumn( table, column );
}
@ -1962,9 +2152,9 @@ public class Binder {
.toString();
}
private TableSpecification createCollectionTable(
private TableSpecification createBasicCollectionTable(
final AbstractPluralAttributeBinding pluralAttributeBinding,
final PluralAttributeSource attributeSource ) {
final TableSpecificationSource tableSpecificationSource) {
final DefaultNamingStrategy defaultNamingStategy = new DefaultNamingStrategy() {
@Override
@ -1977,13 +2167,52 @@ public class Binder {
return bindingContexts.peek().getNamingStrategy().collectionTableName(
owner.getEntity().getName(),
ownerTableLogicalName,
null, // todo: here
null, // todo: and here
null,
null,
createAttributePath( pluralAttributeBinding )
);
}
};
return createTable( attributeSource.getCollectionTableSpecificationSource(), defaultNamingStategy );
return createTable( tableSpecificationSource, defaultNamingStategy );
}
private TableSpecification createManyToManyCollectionTable(
final AbstractPluralAttributeBinding pluralAttributeBinding,
final boolean isInverse,
final TableSpecificationSource tableSpecificationSource,
final EntityBinding associatedEntityBinding) {
final DefaultNamingStrategy defaultNamingStategy = new DefaultNamingStrategy() {
@Override
public String defaultName() {
final EntityBinding ownerEntityBinding;
final EntityBinding inverseEntityBinding;
if ( isInverse ) {
ownerEntityBinding = associatedEntityBinding;
inverseEntityBinding = pluralAttributeBinding.getContainer().seekEntityBinding();
}
else {
ownerEntityBinding = pluralAttributeBinding.getContainer().seekEntityBinding();
inverseEntityBinding = associatedEntityBinding;
}
final String ownerTableLogicalName =
Table.class.isInstance( ownerEntityBinding.getPrimaryTable() )
? ( ( Table ) ownerEntityBinding.getPrimaryTable() ).getPhysicalName().getText()
: null;
final String inverseTableLogicalName =
Table.class.isInstance( inverseEntityBinding.getPrimaryTable() )
? ( ( Table ) inverseEntityBinding.getPrimaryTable() ).getPhysicalName().getText()
: null;
return bindingContexts.peek().getNamingStrategy().collectionTableName(
ownerEntityBinding.getEntity().getName(),
ownerTableLogicalName,
inverseEntityBinding.getEntity().getName(),
inverseTableLogicalName,
createAttributePath( pluralAttributeBinding )
);
}
};
return createTable( tableSpecificationSource, defaultNamingStategy );
}
private Column createColumn(
@ -2168,7 +2397,7 @@ public class Binder {
TableSpecification tableSpec = null;
if ( tableSpecSource == null ) {
if ( defaultNamingStrategy == null ) {
bindingContext().makeMappingException( "An explicit name must be specified for the table" );
throw bindingContext().makeMappingException( "An explicit name must be specified for the table" );
}
String tableName = defaultNamingStrategy.defaultName();
tableSpec = createTableSpecification( bindingContext, schema, tableName );
@ -2178,7 +2407,7 @@ public class Binder {
String tableName = tableSource.getExplicitTableName();
if ( tableName == null ) {
if ( defaultNamingStrategy == null ) {
bindingContext().makeMappingException( "An explicit name must be specified for the table" );
throw bindingContext().makeMappingException( "An explicit name must be specified for the table" );
}
tableName = defaultNamingStrategy.defaultName();
}
@ -2353,11 +2582,11 @@ public class Binder {
referencedAttributeBinding = attributeBinding( entityBinding.getEntity().getName(), referencedAttributeName );
}
if ( referencedAttributeBinding == null ) {
bindingContext().makeMappingException( "Plural attribute key references an attribute binding that does not exist: "
throw bindingContext().makeMappingException( "Plural attribute key references an attribute binding that does not exist: "
+ referencedAttributeBinding );
}
if ( !referencedAttributeBinding.getAttribute().isSingular() ) {
bindingContext().makeMappingException( "Plural attribute key references a plural attribute; it must not be plural: "
throw bindingContext().makeMappingException( "Plural attribute key references a plural attribute; it must not be plural: "
+ referencedAttributeName );
}
return ( SingularAttributeBinding ) referencedAttributeBinding;

View File

@ -32,6 +32,7 @@ import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.metamodel.internal.source.annotations.attribute.Column;
import org.hibernate.metamodel.internal.source.annotations.attribute.PluralAssociationAttribute;
import org.hibernate.metamodel.spi.binding.CascadeType;
import org.hibernate.metamodel.spi.source.ForeignKeyContributingSource;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
@ -68,7 +69,7 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
}
@Override
public List<RelationalValueSource> getValueSources() {
public List<RelationalValueSource> relationalValueSources() {
List<RelationalValueSource> valueSources = new ArrayList<RelationalValueSource>();
// todo
return valueSources;
@ -93,6 +94,11 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
return associationAttribute.getInverseForeignKeyName();
}
@Override
public JoinColumnResolutionDelegate getForeignKeyTargetColumnResolutionDelegate() {
return null; //To change body of implemented methods use File | Settings | File Templates.
}
@Override
public boolean isUnique() {
return false; //To change body of implemented methods use File | Settings | File Templates.
@ -117,6 +123,21 @@ public class ManyToManyPluralAttributeElementSourceImpl implements ManyToManyPlu
public Nature getNature() {
return Nature.MANY_TO_MANY;
}
@Override
public boolean areValuesIncludedInInsertByDefault() {
return true;
}
@Override
public boolean areValuesIncludedInUpdateByDefault() {
return true;
}
@Override
public boolean areValuesNullableByDefault() {
return false;
}
}

View File

@ -287,9 +287,9 @@ public abstract class AbstractEntitySourceImpl
private Set<SecondaryTableSource> buildSecondaryTables() {
if ( ! JoinElementSource.class.isInstance( entityElement ) ) {
return Collections.emptySet();
}
//if ( ! JoinElementSource.class.isInstance( entityElement ) ) {
// return Collections.emptySet();
//}
final Set<SecondaryTableSource> secondaryTableSources = new HashSet<SecondaryTableSource>();
for ( JaxbJoinElement joinElement : ( (JoinElementSource) entityElement ).getJoin() ) {

View File

@ -31,11 +31,13 @@ import org.hibernate.engine.spi.CascadeStyle;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbColumnElement;
import org.hibernate.jaxb.spi.hbm.JaxbManyToManyElement;
import org.hibernate.metamodel.spi.relational.Value;
import org.hibernate.metamodel.spi.source.ManyToManyPluralAttributeElementSource;
import org.hibernate.metamodel.spi.source.RelationalValueSource;
/**
* @author Steve Ebersole
* @author Gail Badner
*/
public class ManyToManyPluralAttributeElementSourceImpl
extends AbstractHbmSourceNode
@ -113,7 +115,7 @@ public class ManyToManyPluralAttributeElementSourceImpl
}
@Override
public List<RelationalValueSource> getValueSources() {
public List<RelationalValueSource> relationalValueSources() {
return valueSources;
}
@ -127,6 +129,13 @@ public class ManyToManyPluralAttributeElementSourceImpl
return manyToManyElement.getForeignKey();
}
@Override
public JoinColumnResolutionDelegate getForeignKeyTargetColumnResolutionDelegate() {
return manyToManyElement.getPropertyRef() == null
? null
: new JoinColumnResolutionDelegateImpl();
}
@Override
public boolean isUnique() {
return manyToManyElement.isUnique();
@ -165,4 +174,32 @@ public class ManyToManyPluralAttributeElementSourceImpl
return "true".equals( value );
}
}
@Override
public boolean areValuesIncludedInInsertByDefault() {
return true;
}
@Override
public boolean areValuesIncludedInUpdateByDefault() {
return true;
}
@Override
public boolean areValuesNullableByDefault() {
return false;
}
public class JoinColumnResolutionDelegateImpl implements JoinColumnResolutionDelegate {
@Override
public String getReferencedAttributeName() {
return manyToManyElement.getPropertyRef();
}
@Override
public List<Value> getJoinColumns(JoinColumnResolutionContext context) {
return context.resolveRelationalValuesForAttribute( manyToManyElement.getPropertyRef() );
}
}
}

View File

@ -407,8 +407,7 @@ public class EntityBinding extends AbstractAttributeBindingContainer {
return hasSubselectLoadableCollections;
}
/* package-protected */
void setSubselectLoadableCollections(boolean hasSubselectLoadableCollections) {
public void setSubselectLoadableCollections(boolean hasSubselectLoadableCollections) {
this.hasSubselectLoadableCollections = hasSubselectLoadableCollections;
}

View File

@ -39,7 +39,7 @@ public class ManyToManyPluralAttributeElementBinding extends AbstractPluralAttri
private String manyToManyWhere;
private String manyToManyOrderBy;
// TODO: really should have value defined (which defines table), but may not know
private Value value;
List<RelationalValueBinding> relationalValueBindings;
ManyToManyPluralAttributeElementBinding(AbstractPluralAttributeBinding binding) {
super( binding );
@ -52,7 +52,11 @@ public class ManyToManyPluralAttributeElementBinding extends AbstractPluralAttri
@Override
public List<RelationalValueBinding> getRelationalValueBindings() {
return null; //To change body of implemented methods use File | Settings | File Templates.
return relationalValueBindings;
}
public void setRelationalValueBindings(List<RelationalValueBinding> relationalValueBindings) {
this.relationalValueBindings = relationalValueBindings;
}
public String getManyToManyWhere() {
@ -70,12 +74,4 @@ public class ManyToManyPluralAttributeElementBinding extends AbstractPluralAttri
public void setManyToManyOrderBy(String manyToManyOrderBy) {
this.manyToManyOrderBy = manyToManyOrderBy;
}
public Value getValue() {
return value;
}
public void setValue(Value value) {
this.value = value;
}
}

View File

@ -29,14 +29,15 @@ import java.util.List;
/**
* @author Steve Ebersole
*/
public interface ManyToManyPluralAttributeElementSource extends PluralAttributeElementSource, CascadeStyleSource {
public interface ManyToManyPluralAttributeElementSource
extends PluralAttributeElementSource, CascadeStyleSource, RelationalValueSourceContainer, ForeignKeyContributingSource {
public String getReferencedEntityName();
public String getReferencedEntityAttributeName();
public Collection<String> getReferencedColumnNames();
public List<RelationalValueSource> getValueSources(); // these describe the "outgoing" link
public List<RelationalValueSource> relationalValueSources(); // these describe the "outgoing" link
public boolean isNotFoundAnException();

View File

@ -35,7 +35,6 @@ import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.mapping.Collection;
import org.hibernate.mapping.Component;
import org.hibernate.mapping.Formula;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.StandardBasicTypes;

View File

@ -35,7 +35,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class DeleteTransientEntityTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -33,7 +33,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
*
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class BidirectionalManyToManyBagToSetCollectionEventTest extends AbstractAssociationCollectionEventTest {
@Override
public String[] getMappings() {

View File

@ -33,7 +33,7 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
*
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
//@FailureExpectedWithNewMetamodel
public class BidirectionalManyToManySetToSetCollectionEventTest extends AbstractAssociationCollectionEventTest {
@Override
public String[] getMappings() {

View File

@ -36,7 +36,7 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
//@FailureExpectedWithNewMetamodel
public class UnidirectionalManyToManyBagCollectionEventTest extends AbstractAssociationCollectionEventTest {
@Override
public String[] getMappings() {

View File

@ -45,7 +45,6 @@ import static org.junit.Assert.fail;
*
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class SQLExceptionConversionTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override
public String[] getMappings() {

View File

@ -23,14 +23,21 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.junit.Test;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.Skip;
/**
* @author Gail Badner
*/
// The overridden tests are known to pass because one-to-many on a join table
// is not built properly due to HHH-6391. These they are skipped for now.
// When HHH-6391 is fixed, the skipped (overridden) tests should be removed.
@FailureExpectedWithNewMetamodel
@SkipForDialect(
value = CUBRIDDialect.class,
@ -42,4 +49,28 @@ public class EntityWithInverseOneToManyJoinTest extends AbstractEntityWithOneToM
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationOneToManyJoin.hbm.xml" };
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testDeleteOneToManyOrphan() {
super.testDeleteOneToManyOrphan();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingMerge() {
super.testRemoveOneToManyOrphanUsingMerge();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingUpdate() {
super.testRemoveOneToManyOrphanUsingUpdate();
}
}

View File

@ -23,16 +23,24 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.junit.Test;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariation.hbm.xml" };
}
@Test
@Override
@FailureExpectedWithNewMetamodel
public void testOneToManyCollectionOptimisticLockingWithUpdate() {
super.testOneToManyCollectionOptimisticLockingWithUpdate();
}
}

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class VersionedEntityWithInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override
public String[] getMappings() {

View File

@ -34,7 +34,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
*
* These tests reproduce HHH-4992.
*/
@FailureExpectedWithNewMetamodel
public class VersionedEntityWithInverseOneToManyFailureExpectedTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {
@ -90,4 +89,11 @@ public class VersionedEntityWithInverseOneToManyFailureExpectedTest extends Abst
public void testRemoveOneToManyElementUsingMerge() {
super.testRemoveOneToManyElementUsingMerge();
}
@Test
@Override
@FailureExpectedWithNewMetamodel
public void testOneToManyCollectionOptimisticLockingWithUpdate() {
super.testOneToManyCollectionOptimisticLockingWithUpdate();
}
}

View File

@ -23,16 +23,21 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.junit.Test;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.junit.Test;
import org.hibernate.testing.Skip;
/**
* @author Gail Badner
*/
// There are overridden tests that are known to pass because one-to-many on a join table
// is not built properly due to HHH-6391. These they are skipped for now.
// When HHH-6391 is fixed, the skipped (overridden) tests should be removed.
@FailureExpectedWithNewMetamodel
@SkipForDialect(
value = CUBRIDDialect.class,
@ -94,4 +99,35 @@ public class VersionedEntityWithInverseOneToManyJoinFailureExpectedTest extends
public void testRemoveOneToManyElementUsingMerge() {
super.testRemoveOneToManyElementUsingMerge();
}
@Test
@Override
@FailureExpectedWithNewMetamodel
public void testOneToManyCollectionOptimisticLockingWithUpdate() {
super.testOneToManyCollectionOptimisticLockingWithUpdate();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testDeleteOneToManyOrphan() {
super.testDeleteOneToManyOrphan();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingMerge() {
super.testRemoveOneToManyOrphanUsingMerge();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingUpdate() {
super.testRemoveOneToManyOrphanUsingUpdate();
}
}

View File

@ -23,16 +23,21 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.junit.Test;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.Skip;
import org.hibernate.testing.TestForIssue;
/**
* @author Gail Badner
*/
// The overridden tests are known to pass because one-to-many on a join table
// is not built properly due to HHH-6391. These they are skipped for now.
// When HHH-6391 is fixed, the skipped (overridden) tests should be removed.
@TestForIssue( jiraKey = "HHH-4992" )
@FailureExpectedWithNewMetamodel
@SkipForDialect(
@ -46,6 +51,30 @@ public class VersionedEntityWithInverseOneToManyJoinTest extends AbstractEntityW
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testDeleteOneToManyOrphan() {
super.testDeleteOneToManyOrphan();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingMerge() {
super.testRemoveOneToManyOrphanUsingMerge();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingUpdate() {
super.testRemoveOneToManyOrphanUsingUpdate();
}
@Override
protected boolean checkUpdateCountsAfterAddingExistingElement() {
return false;

View File

@ -23,19 +23,27 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.junit.Test;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class VersionedEntityWithInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersioned.hbm.xml" };
}
@Test
@Override
@FailureExpectedWithNewMetamodel
public void testOneToManyCollectionOptimisticLockingWithUpdate() {
super.testOneToManyCollectionOptimisticLockingWithUpdate();
}
@Override
protected boolean checkUpdateCountsAfterAddingExistingElement() {
return false;

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override
public String[] getMappings() {

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithNonInverseManyToManyUnidirTest extends AbstractEntityWithManyToManyTest {
@Override
public String[] getMappings() {

View File

@ -23,14 +23,20 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.junit.Test;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.Skip;
/**
* @author Gail Badner
*/
// The overridden tests are known to pass because one-to-many on a join table
// is not built properly due to HHH-6391. These they are skipped for now.
// When HHH-6391 is fixed, the skipped (overridden) tests should be removed.
@FailureExpectedWithNewMetamodel
@SkipForDialect(
value = CUBRIDDialect.class,
@ -42,4 +48,28 @@ public class EntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOne
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml" };
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testDeleteOneToManyOrphan() {
super.testDeleteOneToManyOrphan();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingMerge() {
super.testRemoveOneToManyOrphanUsingMerge();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingUpdate() {
super.testRemoveOneToManyOrphanUsingUpdate();
}
}

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class EntityWithNonInverseOneToManyUnidirTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {

View File

@ -29,7 +29,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class VersionedEntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override
public String[] getMappings() {

View File

@ -23,14 +23,20 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.junit.Test;
import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.Skip;
/**
* @author Gail Badner
*/
// The overridden tests are known to pass because one-to-many on a join table
// is not built properly due to HHH-6391. These they are skipped for now.
// When HHH-6391 is fixed, the skipped (overridden) tests should be removed.
@FailureExpectedWithNewMetamodel
@SkipForDialect(
value = CUBRIDDialect.class,
@ -42,4 +48,28 @@ public class VersionedEntityWithNonInverseOneToManyJoinTest extends AbstractEnti
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testDeleteOneToManyOrphan() {
super.testDeleteOneToManyOrphan();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingMerge() {
super.testRemoveOneToManyOrphanUsingMerge();
}
// TODO: HHH-6391 is fixed, this (overridden) test should be removed.
@Test
@Override
@Skip( condition = Skip.AlwaysSkip.class,message = "skip until HHH-6391 is fixed.")
public void testRemoveOneToManyOrphanUsingUpdate() {
super.testRemoveOneToManyOrphanUsingUpdate();
}
}

View File

@ -23,16 +23,24 @@
*/
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.junit.Test;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Gail Badner
*/
@FailureExpectedWithNewMetamodel
public class VersionedEntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
@Override
public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" };
}
@Test
@Override
@FailureExpectedWithNewMetamodel
public void testOneToManyCollectionOptimisticLockingWithUpdate() {
super.testOneToManyCollectionOptimisticLockingWithUpdate();
}
}

View File

@ -45,7 +45,6 @@ import static org.junit.Assert.assertNotNull;
/**
* @author Gavin King, Gail Badner (adapted this from "ops" tests version)
*/
@FailureExpectedWithNewMetamodel
public class CreateTest extends AbstractOperationTestCase {
@Test
@SuppressWarnings( {"unchecked"})

View File

@ -35,7 +35,6 @@ import org.hibernate.testing.jta.TestingJtaPlatformImpl;
* @author Gail Badner
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class DeleteTest extends AbstractOperationTestCase {
@Test
@SuppressWarnings( {"unchecked"})

View File

@ -45,7 +45,6 @@ import static org.junit.Assert.assertTrue;
* @author Gail Badner
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class GetLoadTest extends AbstractOperationTestCase {
@Override
public void configure(Configuration cfg) {

View File

@ -28,7 +28,6 @@ import static org.junit.Assert.fail;
* @author Gail Badner
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class MergeTest extends AbstractOperationTestCase {
@Test
@ -68,6 +67,7 @@ public class MergeTest extends AbstractOperationTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
@SuppressWarnings( {"UnusedAssignment"})
public void testMergeBidiPrimayKeyOneToOne() throws Exception {
rebuildSessionFactory();

View File

@ -37,7 +37,6 @@ import static org.junit.Assert.assertEquals;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class OneToManyTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {
@ -46,11 +45,13 @@ public class OneToManyTest extends BaseCoreFunctionalTestCase {
@SuppressWarnings( {"unchecked", "UnusedAssignment"})
@Test
@SkipForDialect(
@SkipForDialect(
value = CUBRIDDialect.class,
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"
)
@FailureExpectedWithNewMetamodel
public void testOneToManyLinkTable() {
Session s = openSession();
Transaction t = s.beginTransaction();

View File

@ -42,7 +42,6 @@ import static org.junit.Assert.fail;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class CreateTest extends AbstractOperationTestCase {
@Test
@SuppressWarnings( {"unchecked"})

View File

@ -31,7 +31,6 @@ import org.hibernate.testing.FailureExpectedWithNewMetamodel;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class DeleteTest extends AbstractOperationTestCase {
@Test
@SuppressWarnings( {"unchecked"})

View File

@ -42,7 +42,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class GetLoadTest extends BaseCoreFunctionalTestCase {
@Override
public void configure(Configuration cfg) {

View File

@ -47,7 +47,6 @@ import static org.junit.Assert.fail;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class MergeTest extends AbstractOperationTestCase {
@Test
public void testMergeStaleVersionFails() throws Exception {
@ -84,6 +83,7 @@ public class MergeTest extends AbstractOperationTestCase {
}
@Test
@FailureExpectedWithNewMetamodel
public void testMergeBidiPrimayKeyOneToOne() throws Exception {
rebuildSessionFactory();
Session s = openSession();

View File

@ -44,7 +44,6 @@ import static org.junit.Assert.assertFalse;
* @author Valotasios Yoryos
*/
@TestForIssue( jiraKey = "HHH-5715" )
@FailureExpectedWithNewMetamodel
public class DistinctSelectTest extends BaseCoreFunctionalTestCase {
private static final int NUM_OF_USERS = 30;

View File

@ -45,7 +45,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Gavin King
*/
@FailureExpectedWithNewMetamodel
public class SubselectFetchTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {

View File

@ -39,7 +39,6 @@ import static org.junit.Assert.assertTrue;
/**
* @author Steve Ebersole
*/
@FailureExpectedWithNewMetamodel
public class DbVersionTest extends BaseCoreFunctionalTestCase {
@Override
public String[] getMappings() {