diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/HibernateTypeSourceImpl.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/HibernateTypeSourceImpl.java index 0844503a8f..4e2b75f8cb 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/HibernateTypeSourceImpl.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/HibernateTypeSourceImpl.java @@ -64,23 +64,9 @@ public class HibernateTypeSourceImpl implements HibernateTypeSource, JavaTypeDes } public HibernateTypeSourceImpl(final PluralAttributeElementDetails element) { - this.nameHolder = new ValueHolder( - new ValueHolder.DeferredInitializer() { - @Override - public String initialize() { - return element.getTypeResolver().getExplicitHibernateTypeName(); - } - } - ); - this.parameterHolder = new ValueHolder>( - new ValueHolder.DeferredInitializer>() { - @Override - public Map initialize() { - return element.getTypeResolver().getExplicitHibernateTypeParameters(); - } - } - ); - this.javaType = element.getJavaType(); + this.name = element.getTypeResolver().getExplicitHibernateTypeName(); + this.parameters = element.getTypeResolver().getExplicitHibernateTypeParameters(); + this.javaTypeDescriptor = element.getJavaType(); } @Override diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/util/HibernateDotNames.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/util/HibernateDotNames.java index a1267b288e..0c820362a1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/util/HibernateDotNames.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/annotations/util/HibernateDotNames.java @@ -43,6 +43,7 @@ import org.hibernate.annotations.DiscriminatorOptions; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.Fetch; +import org.hibernate.annotations.FetchMode; import org.hibernate.annotations.FetchProfile; import org.hibernate.annotations.FetchProfiles; import org.hibernate.annotations.Filter; @@ -138,6 +139,7 @@ public interface HibernateDotNames { DotName DYNAMIC_INSERT = DotName.createSimple( DynamicInsert.class.getName() ); DotName DYNAMIC_UPDATE = DotName.createSimple( DynamicUpdate.class.getName() ); DotName FETCH = DotName.createSimple( Fetch.class.getName() ); + DotName FETCH_MODE = DotName.createSimple( FetchMode.class.getName() ); DotName FETCH_PROFILE = DotName.createSimple( FetchProfile.class.getName() ); DotName FETCH_PROFILES = DotName.createSimple( FetchProfiles.class.getName() ); DotName FETCH_OVERRIDE = DotName.createSimple( FetchProfile.FetchOverride.class.getName() ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AbstractMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AbstractMocker.java index 7f0cde6742..7a7f7b3201 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AbstractMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AbstractMocker.java @@ -25,13 +25,13 @@ package org.hibernate.metamodel.source.internal.jandex; import java.util.ArrayList; import java.util.List; + import javax.persistence.AccessType; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames; import org.hibernate.metamodel.source.internal.jaxb.JaxbIndex; import org.hibernate.metamodel.source.internal.jaxb.JaxbUniqueConstraint; - import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationValue; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AnnotationMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AnnotationMocker.java index 1916ff6f02..25c65a65c8 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AnnotationMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AnnotationMocker.java @@ -162,7 +162,15 @@ public abstract class AnnotationMocker extends AbstractMocker { if ( column == null ) { return null; } + + // TODO: Not sure if this should be here... List annotationValueList = new ArrayList(); + MockHelper.stringValue( "forColumn", column.getName(), annotationValueList ); + MockHelper.stringValue( "read", column.getRead(), annotationValueList ); + MockHelper.stringValue( "write", column.getWrite(), annotationValueList ); + create( HibernateDotNames.COLUMN_TRANSFORMER, target, annotationValueList ); + + annotationValueList = new ArrayList(); MockHelper.stringValue( "name", column.getName(), annotationValueList ); MockHelper.stringValue( "columnDefinition", column.getColumnDefinition(), annotationValueList ); MockHelper.stringValue( "table", column.getTable(), annotationValueList ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AttributesBuilder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AttributesBuilder.java index 9dd00ee1f8..1911a339b9 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AttributesBuilder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/AttributesBuilder.java @@ -59,6 +59,10 @@ public class AttributesBuilder extends AbstractAttributesBuilder { @Override protected void parse() { + if (getAttributesContainer() == null) { + return; + } + super.parse(); if ( attributes.getNaturalId() != null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ElementCollectionMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ElementCollectionMocker.java index a6362f1c71..ed33d3451c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ElementCollectionMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ElementCollectionMocker.java @@ -84,6 +84,7 @@ public class ElementCollectionMocker extends PropertyMocker { parseMapKey( elementCollection.getMapKey(), getTarget() ); parseMapKeyColumn( elementCollection.getMapKeyColumn(), getTarget() ); parseMapKeyClass( elementCollection.getMapKeyClass(), getTarget() ); + parseMapKeyType( elementCollection.getMapKeyType(), getTarget() ); parseMapKeyEnumerated( elementCollection.getMapKeyEnumerated(), getTarget() ); parseMapKeyTemporal( elementCollection.getMapKeyTemporal(), getTarget() ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/EntityMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/EntityMocker.java index 5d1e42be9c..15e8fa45dc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/EntityMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/EntityMocker.java @@ -23,6 +23,7 @@ */ package org.hibernate.metamodel.source.internal.jandex; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -38,6 +39,7 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbCacheElement; import org.hibernate.metamodel.source.internal.jaxb.JaxbDiscriminatorColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilter; import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass; import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritance; import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad; @@ -103,7 +105,13 @@ public class EntityMocker extends AbstractEntityObjectMocker { parseSecondaryTableList( entity.getSecondaryTable(), getTarget() ); //@Cache - parseCache( entity.getCache() ); + parseCache( entity.getCache(), getTarget() ); + + // @Filters + parseFilters( entity.getFilter(), getTarget() ); + + // @BatchSize + parseBatchSize( entity.getBatchSize(), getTarget() ); } //@Table (entity only) @@ -295,7 +303,7 @@ public class EntityMocker extends AbstractEntityObjectMocker { } - private void parseCache(JaxbCacheElement cache) { + private void parseCache(JaxbCacheElement cache, AnnotationTarget target) { if ( cache == null ) { return; } @@ -304,6 +312,51 @@ public class EntityMocker extends AbstractEntityObjectMocker { MockHelper.stringValue( "include", cache.getInclude(), annotationValueList ); MockHelper.enumValue( "usage", HibernateDotNames.CACHE_CONCURRENCY_STRATEGY, CacheConcurrencyStrategy.parse( cache.getUsage() ), annotationValueList ); - create( HibernateDotNames.CACHE, annotationValueList ); + create( HibernateDotNames.CACHE, target, annotationValueList ); + } + + private void parseFilters(List filters, AnnotationTarget target) { + if (! filters.isEmpty() ) { + AnnotationValue[] filterAnnotations = new AnnotationValue[filters.size()]; + int i = 0; + for ( JaxbHbmFilter filter : filters ) { + List annotationValueList = new ArrayList(); + MockHelper.stringValue( "name", filter.getName(), annotationValueList ); + + String condition = ""; + if (! StringHelper.isEmpty( filter.getConditionAttribute() )) { + condition = filter.getConditionAttribute(); + } + + for (Serializable contentElement : filter.getContent()) { + if ( String.class.isInstance( contentElement ) ) { + String s = (String) contentElement; + condition = s.trim(); + } + // TODO: Could be aliases -- see xsd + } + + MockHelper.stringValue( "condition", condition, annotationValueList ); + + AnnotationInstance annotationInstance = create( + HibernateDotNames.FILTER, null, annotationValueList ); + filterAnnotations[i++] = MockHelper.nestedAnnotationValue( "", annotationInstance ); + } + + List annotationValueList = new ArrayList(); + MockHelper.addToCollectionIfNotNull( annotationValueList, + AnnotationValue.createArrayValue( "value", filterAnnotations ) ); + + create( HibernateDotNames.FILTERS, target, annotationValueList ); + } + } + + private void parseBatchSize(Integer batchSize, AnnotationTarget target) { + if ( batchSize == null ) { + return; + } + List annotationValueList = new ArrayList(); + MockHelper.integerValue( "size", batchSize, annotationValueList ); + create( HibernateDotNames.BATCH_SIZE, target, annotationValueList ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotationMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotationMocker.java index 1b6c24418d..a0704f261e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotationMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotationMocker.java @@ -27,8 +27,14 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.hibernate.annotations.FetchMode; +import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilterDef; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile.JaxbFetch; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilterDef.JaxbFilterParam; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryHint; @@ -39,6 +45,7 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingEntit import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingFieldResult; import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator; import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationValue; /** @@ -73,6 +80,12 @@ public class GlobalAnnotationMocker extends AbstractMocker { if ( !globalAnnotations.getSqlResultSetMappingMap().isEmpty() ) { parseSqlResultSetMappings( globalAnnotations.getSqlResultSetMappingMap().values() ); } + if ( !globalAnnotations.getFilterDefMap().isEmpty() ) { + parseFilterDefs( globalAnnotations.getFilterDefMap().values() ); + } + if ( !globalAnnotations.getFetchProfileMap().isEmpty() ) { + parseFetchProfiles( globalAnnotations.getFetchProfileMap().values() ); + } indexBuilder.finishGlobalConfigurationMocking( globalAnnotations ); } @@ -309,6 +322,100 @@ public class GlobalAnnotationMocker extends AbstractMocker { ); } + + private void parseFilterDefs(Collection filterDefs) { + if (! filterDefs.isEmpty() ) { + AnnotationValue[] filterDefAnnotations = new AnnotationValue[filterDefs.size()]; + int i = 0; + for ( JaxbHbmFilterDef filterDef : filterDefs ) { + List annotationValueList = new ArrayList(); + MockHelper.stringValue( "name", filterDef.getName(), annotationValueList ); + MockHelper.stringValue( "defaultCondition", filterDef.getCondition(), annotationValueList ); + nestedFilterParams( filterDef.getFilterParam(), annotationValueList ); + + AnnotationInstance annotationInstance = create( + HibernateDotNames.FILTER_DEF, null, annotationValueList ); + filterDefAnnotations[i++] = MockHelper.nestedAnnotationValue( "", annotationInstance ); + } + + List annotationValueList = new ArrayList(); + MockHelper.addToCollectionIfNotNull( annotationValueList, + AnnotationValue.createArrayValue( "value", filterDefAnnotations ) ); + + create( HibernateDotNames.FILTER_DEFS, null, annotationValueList ); + } + } + + private void nestedFilterParams(List filterParams, List annotationValueList) { + if (! filterParams.isEmpty() ) { + AnnotationValue[] filterParamAnnotations = new AnnotationValue[filterParams.size()]; + int i = 0; + for ( JaxbFilterParam filterParam : filterParams ) { + List filterParamannotationValueList = new ArrayList(); + MockHelper.stringValue( "name", filterParam.getName(), filterParamannotationValueList ); + MockHelper.stringValue( "type", filterParam.getType(), filterParamannotationValueList ); + + AnnotationInstance annotationInstance = create( + HibernateDotNames.PARAM_DEF, null, filterParamannotationValueList ); + filterParamAnnotations[i++] = MockHelper.nestedAnnotationValue( "", annotationInstance ); + } + MockHelper.addToCollectionIfNotNull( annotationValueList, + AnnotationValue.createArrayValue( "parameters", filterParamAnnotations ) ); + } + } + + private void parseFetchProfiles(Collection fetchProfiles) { + if (! fetchProfiles.isEmpty() ) { + AnnotationValue[] fetchProfileAnnotations = new AnnotationValue[fetchProfiles.size()]; + int i = 0; + for ( JaxbHbmFetchProfile fetchProfile : fetchProfiles ) { + AnnotationInstance annotationInstance = parseFetchProfile( fetchProfile ); + fetchProfileAnnotations[i++] = MockHelper.nestedAnnotationValue( "", annotationInstance ); + } + + List annotationValueList = new ArrayList(); + MockHelper.addToCollectionIfNotNull( annotationValueList, + AnnotationValue.createArrayValue( "value", fetchProfileAnnotations ) ); + + create( HibernateDotNames.FETCH_PROFILES, null, annotationValueList ); + } + } + + private AnnotationInstance parseFetchProfile(JaxbHbmFetchProfile fetchProfile) { + List annotationValueList = new ArrayList(); + MockHelper.stringValue( "name", fetchProfile.getName(), annotationValueList ); + + AnnotationValue[] fetchAnnotations = new AnnotationValue[fetchProfile.getFetch().size()]; + int i = 0; + for ( JaxbFetch fetch : fetchProfile.getFetch() ) { + List fetchAnnotationValueList = new ArrayList(); + MockHelper.stringValue( "association", fetch.getAssociation(), fetchAnnotationValueList ); + MockHelper.classValue( "entity", fetch.getEntity(), fetchAnnotationValueList, getDefaults(), + indexBuilder.getServiceRegistry() ); + MockHelper.enumValue( "mode", HibernateDotNames.FETCH_MODE, convertFetchMode( fetch.getStyle() ), + fetchAnnotationValueList ); + AnnotationInstance annotationInstance = create( + HibernateDotNames.FETCH_OVERRIDE, null, fetchAnnotationValueList ); + fetchAnnotations[i++] = MockHelper.nestedAnnotationValue( "", annotationInstance ); + } + + MockHelper.addToCollectionIfNotNull( annotationValueList, + AnnotationValue.createArrayValue( "fetchOverrides", fetchAnnotations ) ); + + return create(HibernateDotNames.FETCH_PROFILE, null, annotationValueList ); + } + + private FetchMode convertFetchMode(String fetchMode) { + if (fetchMode.equalsIgnoreCase( "join" )) { + return FetchMode.JOIN; + } + else if (fetchMode.equalsIgnoreCase( "subselect" )) { + return FetchMode.SUBSELECT; + } + else { + return FetchMode.SELECT; + } + } @Override protected AnnotationInstance push(AnnotationInstance annotationInstance) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotations.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotations.java index 4cd6d05d39..fbde17870e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotations.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/GlobalAnnotations.java @@ -35,10 +35,14 @@ import org.hibernate.internal.CoreLogging; import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.collections.CollectionHelper; +import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames; import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile.JaxbFetch; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilterDef; import org.hibernate.metamodel.source.internal.jaxb.JaxbId; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; @@ -47,7 +51,6 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping; import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator; import org.hibernate.metamodel.source.internal.jaxb.SchemaAware; import org.hibernate.metamodel.source.spi.MappingException; - import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.DotName; @@ -55,6 +58,7 @@ import org.jboss.jandex.DotName; /** * @author Strong Liu */ +// TODO: Much of this class is unnecessary -- use simple lists and let duplication be checked later on? public class GlobalAnnotations implements JPADotNames { private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GlobalAnnotations.class ); @@ -65,6 +69,8 @@ public class GlobalAnnotations implements JPADotNames { private final Map sqlResultSetMappingMap = new HashMap(); private final Map> annotationInstanceMap = new HashMap>(); private final List indexedAnnotationInstanceList = new ArrayList(); + private final Map filterDefMap = new HashMap(); + private final Map fetchProfileMap = new HashMap(); //--------------------------- private final Set defaultNamedNativeQueryNames = new HashSet(); private final Set defaultNamedQueryNames = new HashSet(); @@ -103,7 +109,9 @@ public class GlobalAnnotations implements JPADotNames { && namedNativeQueryMap.isEmpty() && sequenceGeneratorMap.isEmpty() && tableGeneratorMap.isEmpty() - && sqlResultSetMappingMap.isEmpty() ); + && sqlResultSetMappingMap.isEmpty() + && filterDefMap.isEmpty() + && fetchProfileMap.isEmpty() ); } Map getNamedNativeQueryMap() { @@ -126,6 +134,14 @@ public class GlobalAnnotations implements JPADotNames { return tableGeneratorMap; } + Map getFilterDefMap() { + return filterDefMap; + } + + Map getFetchProfileMap() { + return fetchProfileMap; + } + public void filterIndexedAnnotations() { for ( AnnotationInstance annotationInstance : indexedAnnotationInstanceList ) { @@ -150,7 +166,9 @@ public class GlobalAnnotations implements JPADotNames { ( annName.equals( SEQUENCE_GENERATOR ) && !sequenceGeneratorMap.containsKey( name ) ) || ( annName.equals( NAMED_QUERY ) && !namedQueryMap.containsKey( name ) ) || ( annName.equals( NAMED_NATIVE_QUERY ) && !namedNativeQueryMap.containsKey( name ) ) || - ( annName.equals( SQL_RESULT_SET_MAPPING ) && !sqlResultSetMappingMap.containsKey( name ) ); + ( annName.equals( SQL_RESULT_SET_MAPPING ) && !sqlResultSetMappingMap.containsKey( name ) ) || + ( annName.equals( HibernateDotNames.FILTER_DEF ) && !filterDefMap.containsKey( name ) ) || + ( annName.equals( HibernateDotNames.FETCH_PROFILE ) && !fetchProfileMap.containsKey( name ) ); } } if ( isNotExist ) { @@ -179,6 +197,14 @@ public class GlobalAnnotations implements JPADotNames { put( sqlResultSetMapping ); defaultSqlResultSetMappingNames.add( sqlResultSetMapping.getName() ); } + for ( JaxbHbmFilterDef filterDef : entityMappings.getFilterDef() ) { + if (filterDef != null) { + filterDefMap.put( filterDef.getName(), filterDef ); + } + } + for ( JaxbHbmFetchProfile fetchProfile : entityMappings.getFetchProfile() ) { + put( fetchProfile, entityMappings.getPackage(), null ); + } } void collectGlobalMappings(JaxbEntity entity, Default defaults) { @@ -228,6 +254,10 @@ public class GlobalAnnotations implements JPADotNames { } } } + + for (JaxbHbmFetchProfile fetchProfile : entity.getFetchProfile()) { + put( fetchProfile, defaults.getPackageName(), entity.getClazz() ); + } } /** @@ -290,4 +320,14 @@ public class GlobalAnnotations implements JPADotNames { } } } + + public void put(JaxbHbmFetchProfile fetchProfile, String packageName, String defaultClassName) { + if (fetchProfile != null) { + for (JaxbFetch fetch : fetchProfile.getFetch()) { + String entityName = StringHelper.isEmpty( fetch.getEntity() ) ? defaultClassName : fetch.getEntity(); + fetch.setEntity( MockHelper.buildSafeClassName( entityName, packageName ) ); + } + fetchProfileMap.put( fetchProfile.getName(), fetchProfile ); + } + } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToManyMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToManyMocker.java index 2bcc9343b2..94d4db005f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToManyMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToManyMocker.java @@ -62,6 +62,12 @@ public class ManyToManyMocker extends PropertyMocker { MockHelper.stringValue( "hbmKey", manyToMany.getHbmKey(), annotationValueList ); create( HibernateDotNames.INVERSE, getTarget(), annotationValueList ); } + if (manyToMany.getHbmFetchMode() != null) { + List annotationValueList = new ArrayList(); + MockHelper.enumValue( "value", HibernateDotNames.FETCH_MODE, manyToMany.getHbmFetchMode(), + annotationValueList ); + create( HibernateDotNames.FETCH, getTarget(), annotationValueList ); + } List annotationValueList = new ArrayList(); MockHelper.classValue( "targetEntity", manyToMany.getTargetEntity(), annotationValueList, getDefaults(), indexBuilder.getServiceRegistry() ); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToOneMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToOneMocker.java index 6b60a9ea1d..29ee3434bc 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToOneMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/ManyToOneMocker.java @@ -26,9 +26,10 @@ package org.hibernate.metamodel.source.internal.jandex; import java.util.ArrayList; import java.util.List; +import org.hibernate.internal.util.StringHelper; +import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToOne; import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute; - import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.ClassInfo; @@ -51,12 +52,14 @@ public class ManyToOneMocker extends PropertyMocker { @Override protected void doProcess() { List annotationValueList = new ArrayList(); - MockHelper.classValue( "targetEntity", manyToOne.getTargetEntity(), annotationValueList, getDefaults(), - indexBuilder.getServiceRegistry() ); + MockHelper.classValue( "targetEntity", + StringHelper.qualifyIfNot( getDefaults().getPackageName(), manyToOne.getTargetEntity() ), + annotationValueList, getDefaults(), indexBuilder.getServiceRegistry() ); MockHelper.enumValue( "fetch", FETCH_TYPE, manyToOne.getFetch(), annotationValueList ); MockHelper.booleanValue( "optional", manyToOne.isOptional(), annotationValueList ); MockHelper.cascadeValue( "cascade", manyToOne.getCascade(), isDefaultCascadePersist(), annotationValueList ); create( MANY_TO_ONE, annotationValueList ); + parseJoinColumnList( manyToOne.getJoinColumn(), getTarget() ); parseJoinTable( manyToOne.getJoinTable(), getTarget() ); if ( manyToOne.getMapsId() != null ) { @@ -65,5 +68,9 @@ public class ManyToOneMocker extends PropertyMocker { if ( manyToOne.isId() != null && manyToOne.isId() ) { create( ID ); } + + annotationValueList = new ArrayList(); + MockHelper.cascadeValue( "value", manyToOne.getHbmCascade(), annotationValueList ); + create( HibernateDotNames.CASCADE, getTarget(), annotationValueList ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/MockHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/MockHelper.java index 21175a8619..0ad5a6476f 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/MockHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/MockHelper.java @@ -43,9 +43,9 @@ import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames; import org.hibernate.metamodel.source.internal.jaxb.JaxbCacheModeType; import org.hibernate.metamodel.source.internal.jaxb.JaxbCascadeType; -import org.hibernate.metamodel.source.internal.jaxb.JaxbEmptyType; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCascadeType; import org.hibernate.service.ServiceRegistry; +import org.hibernate.type.ArrayType; import org.hibernate.type.BagType; import org.hibernate.type.ListType; import org.hibernate.type.MapType; @@ -232,6 +232,7 @@ public class MockHelper { addIfNotNull( cascadeType.getCascadeSaveUpdate(), enumList , org.hibernate.annotations.CascadeType.SAVE_UPDATE ); addIfNotNull( cascadeType.getCascadeReplicate(), enumList , org.hibernate.annotations.CascadeType.REPLICATE ); addIfNotNull( cascadeType.getCascadeLock(), enumList , org.hibernate.annotations.CascadeType.LOCK ); + addIfNotNull( cascadeType.getCascadeDelete(), enumList , org.hibernate.annotations.CascadeType.DELETE ); } if ( !enumList.isEmpty() ) { MockHelper.enumArrayValue( name, JPADotNames.CASCADE_TYPE, enumList, annotationValueList ); @@ -545,6 +546,9 @@ public class MockHelper { if (collectionTypeName.equalsIgnoreCase( "map" )) { collectionTypeName = MapType.class.getName(); } + if (collectionTypeName.equalsIgnoreCase( "array" )) { + collectionTypeName = ArrayType.class.getName(); + } return collectionTypeName; } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/OneToManyMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/OneToManyMocker.java index dbfa3c8a4b..595d9e1618 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/OneToManyMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/OneToManyMocker.java @@ -57,10 +57,16 @@ public class OneToManyMocker extends PropertyMocker { MockHelper.stringValue( "type", collectionTypeName, annotationValueList ); create( HibernateDotNames.COLLECTION_TYPE, annotationValueList ); } - if (oneToMany.isInverse()) { + if (oneToMany.isInverse() != null && oneToMany.isInverse()) { List annotationValueList = new ArrayList(); create( HibernateDotNames.INVERSE, getTarget(), annotationValueList ); } + if (oneToMany.getHbmFetchMode() != null) { + List annotationValueList = new ArrayList(); + MockHelper.enumValue( "value", HibernateDotNames.FETCH_MODE, oneToMany.getHbmFetchMode(), + annotationValueList ); + create( HibernateDotNames.FETCH, getTarget(), annotationValueList ); + } List annotationValueList = new ArrayList(); MockHelper.classValue( "targetEntity", oneToMany.getTargetEntity(), annotationValueList, getDefaults(), indexBuilder.getServiceRegistry() ); @@ -80,6 +86,7 @@ public class OneToManyMocker extends PropertyMocker { parseJoinColumnList( oneToMany.getJoinColumn(), getTarget() ); parseOrderColumn( oneToMany.getOrderColumn(), getTarget() ); parseJoinTable( oneToMany.getJoinTable(), getTarget() ); + parseOnDelete( oneToMany.getOnDelete(), getTarget() ); if ( oneToMany.getOrderBy() != null ) { create( ORDER_BY, getTarget(), MockHelper.stringValueArray( "value", oneToMany.getOrderBy() ) ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/PropertyMocker.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/PropertyMocker.java index aeecee9570..d918f4d2fa 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/PropertyMocker.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jandex/PropertyMocker.java @@ -31,6 +31,7 @@ import javax.persistence.EnumType; import javax.persistence.TemporalType; import org.hibernate.HibernateException; +import org.hibernate.annotations.OnDeleteAction; import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmType; @@ -38,6 +39,7 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKey; import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyClass; import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyJoinColumn; +import org.hibernate.metamodel.source.internal.jaxb.JaxbOnDeleteType; import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute; import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; @@ -264,8 +266,26 @@ public abstract class PropertyMocker extends AnnotationMocker { //@Type protected AnnotationInstance parseType(String name, AnnotationTarget target) { - List typeAnnotationValueList = new ArrayList(); - MockHelper.stringValue( "type", name, typeAnnotationValueList ); - return create( HibernateDotNames.TYPE, target, typeAnnotationValueList ); + List annotationValueList = new ArrayList(); + MockHelper.stringValue( "type", name, annotationValueList ); + return create( HibernateDotNames.TYPE, target, annotationValueList ); + } + + //@OnDelete + protected void parseOnDelete(JaxbOnDeleteType onDelete, AnnotationTarget target) { + if (onDelete != null) { + List annotationValueList = new ArrayList(); + OnDeleteAction action; + switch (onDelete) { + case CASCADE: + action = OnDeleteAction.CASCADE; + break; + default: + action = OnDeleteAction.NO_ACTION; + } + MockHelper.enumValue( "action", DotName.createSimple( OnDeleteAction.class.getName() ), action, + annotationValueList ); + create( HibernateDotNames.ON_DELETE, target, annotationValueList ); + } } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/MapAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/CollectionAttribute.java similarity index 89% rename from hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/MapAttribute.java rename to hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/CollectionAttribute.java index abdba02f52..09f5a0c5e1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/MapAttribute.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/CollectionAttribute.java @@ -29,11 +29,19 @@ import javax.persistence.EnumType; import javax.persistence.TemporalType; /** - * Common interface for JAXB bindings that represent persistent attributes supporting Map collection types. + * Common interface for JAXB bindings that represent persistent collection attributes. * * @author Brett Meyer */ -public interface MapAttribute { +public interface CollectionAttribute extends FetchableAttribute { + + public String getOrderBy(); + + public void setOrderBy(String value); + + public JaxbOrderColumn getOrderColumn(); + + public void setOrderColumn(JaxbOrderColumn value); public JaxbMapKey getMapKey(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/FetchableAttribute.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/FetchableAttribute.java new file mode 100644 index 0000000000..4af06b0181 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/FetchableAttribute.java @@ -0,0 +1,44 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2014, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.source.internal.jaxb; + +import javax.persistence.FetchType; + +import org.hibernate.annotations.FetchMode; + +/** + * Common interface for JAXB bindings that represent attributes with laziness and fetch style. + * + * @author Brett Meyer + */ +public interface FetchableAttribute { + + public FetchType getFetch(); + + public void setFetch(FetchType value); + + public FetchMode getHbmFetchMode(); + + public void setHbmFetchMode(FetchMode value); +} diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/hbm/HbmXmlTransformer.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/hbm/HbmXmlTransformer.java index 526359c505..4d2ccef3ba 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/hbm/HbmXmlTransformer.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/hbm/HbmXmlTransformer.java @@ -23,6 +23,7 @@ */ package org.hibernate.metamodel.source.internal.jaxb.hbm; +import java.io.Serializable; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -32,9 +33,12 @@ import javax.xml.bind.JAXBElement; import org.hibernate.FlushMode; import org.hibernate.MappingException; +import org.hibernate.annotations.FetchMode; import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.StringHelper; import org.hibernate.mapping.Collection; +import org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute; +import org.hibernate.metamodel.source.internal.jaxb.FetchableAttribute; import org.hibernate.metamodel.source.internal.jaxb.JaxbAny; import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes; import org.hibernate.metamodel.source.internal.jaxb.JaxbBasic; @@ -55,6 +59,7 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCascadeType; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCustomSql; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCustomSqlCheckEnum; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile; +import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilter; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilterDef; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGenerator; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGeneratorDef; @@ -66,6 +71,8 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmType; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmTypeDef; import org.hibernate.metamodel.source.internal.jaxb.JaxbId; import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass; +import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritance; +import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritanceType; import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinTable; import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToMany; @@ -74,16 +81,19 @@ import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNaturalId; +import org.hibernate.metamodel.source.internal.jaxb.JaxbOnDeleteType; import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToMany; import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne; +import org.hibernate.metamodel.source.internal.jaxb.JaxbOrderColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitMetadata; +import org.hibernate.metamodel.source.internal.jaxb.JaxbPrimaryKeyJoinColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryParamType; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingEntityResult; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingFieldResult; import org.hibernate.metamodel.source.internal.jaxb.JaxbSynchronizeType; import org.hibernate.metamodel.source.internal.jaxb.JaxbTable; -import org.hibernate.metamodel.source.internal.jaxb.MapAttribute; +import org.hibernate.metamodel.source.internal.jaxb.JaxbVersion; import org.hibernate.metamodel.source.internal.jaxb.hbm.JaxbReturnPropertyElement.JaxbReturnColumn; import org.hibernate.metamodel.spi.ClassLoaderAccess; import org.hibernate.xml.spi.Origin; @@ -198,8 +208,12 @@ public class HbmXmlTransformer { boolean foundCondition = false; for ( Object content : hbmFilterDef.getContent() ) { if ( String.class.isInstance( content ) ) { - foundCondition = true; - filterDef.setCondition( (String) content ); + String condition = (String) content; + condition = condition.trim(); + if (! StringHelper.isEmpty( condition )) { + foundCondition = true; + filterDef.setCondition( condition ); + } } else { JaxbFilterParamElement hbmFilterParam = ( (JAXBElement) content ).getValue(); @@ -285,24 +299,23 @@ public class HbmXmlTransformer { } for ( JaxbFetchProfileElement hbmFetchProfile : hbmXmlMapping.getFetchProfile() ) { - final JaxbHbmFetchProfile fetchProfile = new JaxbHbmFetchProfile(); - ormRoot.getFetchProfile().add( fetchProfile ); - fetchProfile.setName( hbmFetchProfile.getName() ); - - if ( hbmFetchProfile.getFetch().isEmpty() ) { - // really this should be an error, right? - continue; - } - for ( JaxbFetchProfileElement.JaxbFetch hbmFetch : hbmFetchProfile.getFetch() ) { - final JaxbHbmFetchProfile.JaxbFetch fetch = new JaxbHbmFetchProfile.JaxbFetch(); - fetchProfile.getFetch().add( fetch ); - fetch.setEntity( hbmFetch.getEntity() ); - fetch.setAssociation( hbmFetch.getAssociation() ); - fetch.setStyle( hbmFetch.getStyle().value() ); - } + ormRoot.getFetchProfile().add( transferFetchProfile( hbmFetchProfile ) ); } } + private JaxbHbmFetchProfile transferFetchProfile(JaxbFetchProfileElement hbmFetchProfile) { + final JaxbHbmFetchProfile fetchProfile = new JaxbHbmFetchProfile(); + fetchProfile.setName( hbmFetchProfile.getName() ); + for ( JaxbFetchProfileElement.JaxbFetch hbmFetch : hbmFetchProfile.getFetch() ) { + final JaxbHbmFetchProfile.JaxbFetch fetch = new JaxbHbmFetchProfile.JaxbFetch(); + fetchProfile.getFetch().add( fetch ); + fetch.setEntity( hbmFetch.getEntity() ); + fetch.setAssociation( hbmFetch.getAssociation() ); + fetch.setStyle( hbmFetch.getStyle().value() ); + } + return fetchProfile; + } + private void transferNamedQuery(JaxbHibernateMapping hbmXmlMapping, JaxbEntityMappings ormRoot) { if ( hbmXmlMapping.getQuery().isEmpty() ) { return; @@ -329,7 +342,9 @@ public class HbmXmlTransformer { // JaxbQueryElement#content elements can be either the query or parameters for ( Object content : hbmQuery.getContent() ) { if ( String.class.isInstance( content ) ) { - query.setQuery( (String) content ); + String s = (String) content; + s = s.trim(); + query.setQuery( s ); } else { final JaxbQueryParamElement hbmQueryParam = (JaxbQueryParamElement) content; @@ -387,7 +402,9 @@ public class HbmXmlTransformer { // JaxbQueryElement#content elements can be either the query or parameters for ( Object content : hbmQuery.getContent() ) { if ( String.class.isInstance( content ) ) { - query.setQuery( (String) content ); + String s = (String) content; + s = s.trim(); + query.setQuery( s ); } else if (content instanceof JAXBElement) { final JAXBElement element = (JAXBElement) content; @@ -465,15 +482,9 @@ public class HbmXmlTransformer { } private void transferEntity(JaxbClassElement hbmClass, JaxbEntity entity) { - entity.setMetadataComplete( true ); - entity.setName( hbmClass.getEntityName() ); - entity.setClazz( hbmClass.getName() ); - entity.setAbstract( hbmClass.isAbstract() ); + transferEntityElement( hbmClass, entity ); + entity.setMutable( hbmClass.isMutable() ); - entity.setLazy( hbmClass.isLazy() ); - entity.setProxy( hbmClass.getProxy() ); - - entity.setBatchSize( hbmClass.getBatchSize() ); entity.setTable( new JaxbTable() ); entity.getTable().setCatalog( hbmClass.getCatalog() ); @@ -490,10 +501,6 @@ public class HbmXmlTransformer { } } - entity.setDynamicInsert( hbmClass.isDynamicInsert() ); - entity.setDynamicUpdate( hbmClass.isDynamicUpdate() ); - entity.setSelectBeforeUpdate( hbmClass.isSelectBeforeUpdate() ); - if ( hbmClass.getLoader() != null ) { entity.setLoader( new JaxbHbmLoader() ); entity.getLoader().setQueryRef( hbmClass.getLoader().getQueryRef() ); @@ -519,7 +526,6 @@ public class HbmXmlTransformer { entity.setRowid( hbmClass.getRowid() ); entity.setWhere( hbmClass.getWhere() ); - entity.setPersister( hbmClass.getPersister() ); if ( !hbmClass.getTuplizer().isEmpty() ) { if ( hbmClass.getTuplizer().size() > 1 ) { throw new MappingException( "HBM transformation: More than one entity-mode per entity not supported" ); @@ -530,14 +536,6 @@ public class HbmXmlTransformer { } entity.setOptimisticLock( hbmClass.getOptimisticLock().value() ); - if ( hbmClass.getOptimisticLock() == JaxbOptimisticLockAttribute.VERSION ) { - // todo : transfer version/timestamp - //final JaxbVersionElement hbmVersion = hbmClass.getVersion(); - //final JaxbTimestampElement hbmTimestamp = hbmClass.getTimestamp(); - - // oddly the jpa xsd allows multiple elements :? - } - transferDiscriminator( entity, hbmClass ); entity.setDiscriminatorValue( hbmClass.getDiscriminatorValue() ); @@ -575,11 +573,121 @@ public class HbmXmlTransformer { entity.getNamedNativeQuery().add( convert( hbmQuery, entity.getName() + "." + hbmQuery.getName() ) ); } } - - // todo : transfer filters - // todo : transfer fetch-profiles + + if (! hbmClass.getFilter().isEmpty()) { + for (JaxbFilterElement hbmFilter : hbmClass.getFilter()) { + entity.getFilter().add( convert( hbmFilter ) ); + } + } + + if (! hbmClass.getFetchProfile().isEmpty()) { + for (JaxbFetchProfileElement hbmFetchProfile : hbmClass.getFetchProfile()) { + entity.getFetchProfile().add( transferFetchProfile( hbmFetchProfile ) ); + } + } transferAttributes( entity, hbmClass ); + + if (! hbmClass.getJoinedSubclass().isEmpty()) { + for (JaxbJoinedSubclassElement hbmSubclass : hbmClass.getJoinedSubclass()) { + entity.setInheritance( new JaxbInheritance() ); + entity.getInheritance().setStrategy( JaxbInheritanceType.JOINED ); + + final JaxbEntity subclassEntity = new JaxbEntity(); + ormRoot.getEntity().add( subclassEntity ); + transferJoinedSubclass( hbmSubclass, subclassEntity ); + } + } + + if (! hbmClass.getUnionSubclass().isEmpty()) { + for (JaxbUnionSubclassElement hbmSubclass : hbmClass.getUnionSubclass()) { + entity.setInheritance( new JaxbInheritance() ); + entity.getInheritance().setStrategy( JaxbInheritanceType.UNION_SUBCLASS ); + + final JaxbEntity subclassEntity = new JaxbEntity(); + ormRoot.getEntity().add( subclassEntity ); + transferUnionSubclass( hbmSubclass, subclassEntity ); + } + } + + if (! hbmClass.getSubclass().isEmpty()) { + for (JaxbSubclassElement hbmSubclass : hbmClass.getSubclass()) { + final JaxbEntity subclassEntity = new JaxbEntity(); + ormRoot.getEntity().add( subclassEntity ); + transferDiscriminatorSubclass( hbmSubclass, subclassEntity ); + } + } + + for ( JaxbQueryElement hbmQuery : hbmClass.getQuery() ) { + // Tests implied this was the case... + final String name = hbmClass.getName() + "." + hbmQuery.getName(); + ormRoot.getNamedQuery().add( convert( hbmQuery, name ) ); + } + + for ( JaxbSqlQueryElement hbmQuery : hbmClass.getSqlQuery() ) { + // Tests implied this was the case... + final String name = hbmClass.getName() + "." + hbmQuery.getName(); + ormRoot.getNamedNativeQuery().add( convert( hbmQuery, name ) ); + } + } + + private void transferEntityElement(JaxbEntityElement hbmClass, JaxbEntity entity) { + entity.setMetadataComplete( true ); + entity.setName( hbmClass.getEntityName() ); + entity.setClazz( hbmClass.getName() ); + entity.setAbstract( hbmClass.isAbstract() ); + entity.setLazy( hbmClass.isLazy() ); + entity.setProxy( hbmClass.getProxy() ); + + entity.setBatchSize( hbmClass.getBatchSize() ); + + entity.setDynamicInsert( hbmClass.isDynamicInsert() ); + entity.setDynamicUpdate( hbmClass.isDynamicUpdate() ); + entity.setSelectBeforeUpdate( hbmClass.isSelectBeforeUpdate() ); + + entity.setPersister( hbmClass.getPersister() ); + } + + private void transferDiscriminatorSubclass(JaxbSubclassElement hbmSubclass, JaxbEntity subclassEntity) { + transferEntityElement( hbmSubclass, subclassEntity ); + if (! StringHelper.isEmpty( hbmSubclass.getDiscriminatorValue() )) { + subclassEntity.setDiscriminatorValue( hbmSubclass.getDiscriminatorValue() ); + } + transferEntityElementAttributes( subclassEntity, hbmSubclass ); + } + + private void transferJoinedSubclass(JaxbJoinedSubclassElement hbmSubclass, JaxbEntity subclassEntity) { + if (! StringHelper.isEmpty( hbmSubclass.getProxy() )) { + // TODO + throw new MappingException( "HBM transformation: proxy attributes not yet supported" ); + } + + transferEntityElement( hbmSubclass, subclassEntity ); + transferEntityElementAttributes( subclassEntity, hbmSubclass ); + + subclassEntity.setTable( new JaxbTable() ); + subclassEntity.getTable().setCatalog( hbmSubclass.getCatalog() ); + subclassEntity.getTable().setSchema( hbmSubclass.getSchema() ); + subclassEntity.getTable().setName( hbmSubclass.getTable() ); + subclassEntity.getTable().setComment( hbmSubclass.getComment() ); + subclassEntity.getTable().setCheck( hbmSubclass.getCheck() ); + + if (hbmSubclass.getKey() != null) { + final JaxbPrimaryKeyJoinColumn joinColumn = new JaxbPrimaryKeyJoinColumn(); + // TODO: multiple columns? + joinColumn.setName( hbmSubclass.getKey().getColumnAttribute() ); + subclassEntity.getPrimaryKeyJoinColumn().add( joinColumn ); + } + + if (! hbmSubclass.getJoinedSubclass().isEmpty()) { + subclassEntity.setInheritance( new JaxbInheritance() ); + subclassEntity.getInheritance().setStrategy( JaxbInheritanceType.JOINED ); + for (JaxbJoinedSubclassElement nestedHbmSubclass : hbmSubclass.getJoinedSubclass()) { + final JaxbEntity nestedSubclassEntity = new JaxbEntity(); + ormRoot.getEntity().add( nestedSubclassEntity ); + transferJoinedSubclass( nestedHbmSubclass, nestedSubclassEntity ); + } + } } private JaxbHbmCustomSqlCheckEnum convert(JaxbCheckAttribute check) { @@ -637,9 +745,18 @@ public class HbmXmlTransformer { } private void transferAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { - entity.setAttributes( new JaxbAttributes() ); + transferEntityElementAttributes( entity, hbmClass ); transferIdentifier( entity, hbmClass ); + transferNaturalIdentifiers( entity, hbmClass ); + transferVersion( entity, hbmClass ); + transferTimestamp( entity, hbmClass ); + transferJoins( entity, hbmClass ); + } + + private void transferEntityElementAttributes(JaxbEntity entity, EntityElement hbmClass) { + entity.setAttributes( new JaxbAttributes() ); + transferBasicAttributes( entity, hbmClass ); transferEmbeddedAttributes( entity, hbmClass ); transferOneToOneAttributes( entity, hbmClass ); @@ -648,8 +765,7 @@ public class HbmXmlTransformer { transferManyToAnyAttributes( entity, hbmClass ); transferPrimitiveArrayAttributes( entity, hbmClass ); transferPropertiesGrouping( entity, hbmClass ); - transferNaturalIdentifiers( entity, hbmClass ); - transferPluralAttribute( entity, hbmClass ); + transferCollectionAttributes( entity, hbmClass ); } private void transferIdentifier(JaxbEntity entity, JaxbClassElement hbmClass) { @@ -756,33 +872,7 @@ public class HbmXmlTransformer { } else { final JaxbKeyManyToOneElement keyManyToOne = (JaxbKeyManyToOneElement) hbmCompositeAttribute; - final JaxbManyToOne manyToOne = new JaxbManyToOne(); - manyToOne.setName( keyManyToOne.getName() ); - manyToOne.setAttributeAccessor( keyManyToOne.getAccess() ); - if ( StringHelper.isNotEmpty( keyManyToOne.getEntityName() ) ) { - manyToOne.setTargetEntity( keyManyToOne.getEntityName() ); - } - else { - manyToOne.setTargetEntity( keyManyToOne.getClazz() ); - } - // todo : cascade - manyToOne.setFetch( convert( keyManyToOne.getLazy() ) ); - manyToOne.setForeignKey( new JaxbForeignKey() ); - manyToOne.getForeignKey().setName( keyManyToOne.getForeignKey() ); - if ( StringHelper.isNotEmpty( keyManyToOne.getColumnAttribute() ) ) { - final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); - joinColumn.setName( keyManyToOne.getColumnAttribute() ); - manyToOne.getJoinColumn().add( joinColumn ); - } - else { - for ( JaxbColumnElement hbmColumn : keyManyToOne.getColumn() ) { - final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); - joinColumn.setName( hbmColumn.getName() ); - joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() ); - joinColumn.setUnique( hbmColumn.isUnique() ); - manyToOne.getJoinColumn().add( joinColumn ); - } - } + final JaxbManyToOne manyToOne = transferManyToOneAttribute( keyManyToOne ); embeddable.getAttributes().getManyToOne().add( manyToOne ); } } @@ -821,7 +911,7 @@ public class HbmXmlTransformer { } } - private void transferBasicAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferBasicAttributes(JaxbEntity entity, EntityElement hbmClass) { for ( JaxbPropertyElement hbmProp : hbmClass.getProperty() ) { entity.getAttributes().getBasic().add( transferBasicAttribute( hbmProp ) ); } @@ -849,6 +939,39 @@ public class HbmXmlTransformer { naturalId.setMutable( hbmClass.getNaturalId().isMutable() ); entity.getAttributes().setNaturalId( naturalId ); } + + private void transferVersion(JaxbEntity entity, JaxbClassElement hbmClass) { + if ( hbmClass.getOptimisticLock() == JaxbOptimisticLockAttribute.VERSION ) { + final JaxbVersionElement hbmVersion = hbmClass.getVersion(); + if (hbmVersion != null) { + final JaxbVersion version = new JaxbVersion(); + version.setName( hbmVersion.getName() ); + // TODO: multiple columns? + if (! StringHelper.isEmpty( hbmVersion.getColumnAttribute() )) { + version.setColumn( new JaxbColumn() ); + version.getColumn().setName( hbmVersion.getColumnAttribute() ); + } + entity.getAttributes().getVersion().add( version ); + } + + // oddly the jpa xsd allows multiple elements? + } + } + + private void transferTimestamp(JaxbEntity entity, JaxbClassElement hbmClass) { + final JaxbTimestampElement hbmTimestamp = hbmClass.getTimestamp(); + if (hbmTimestamp != null) { + // TODO + throw new MappingException( "HBM transformation: HBM timestamps are not yet supported." ); + } + } + + private void transferJoins(JaxbEntity entity, JaxbClassElement hbmClass) { + for ( JaxbJoinElement hbmJoin : hbmClass.getJoin() ) { + // TODO + throw new MappingException( "HBM transformation: HBM joins are not yet supported." ); + } + } private JaxbBasic transferBasicAttribute(JaxbPropertyElement hbmProp) { final JaxbBasic basic = new JaxbBasic(); @@ -880,10 +1003,12 @@ public class HbmXmlTransformer { if ( StringHelper.isNotEmpty( hbmProp.getFormulaAttribute() ) ) { basic.getColumnOrFormula().add( hbmProp.getFormulaAttribute() ); } - else if ( StringHelper.isNotEmpty( hbmProp.getColumnAttribute() ) ) { - final JaxbColumn column = new JaxbColumn(); - column.setName( hbmProp.getColumnAttribute() ); - basic.getColumnOrFormula().add( column ); + else if (! hbmProp.getColumn().isEmpty()) { + for ( JaxbColumnElement hbmColumn : hbmProp.getColumn() ) { + final JaxbColumn column = new JaxbColumn(); + transferColumn( column, hbmColumn, null, hbmProp.isInsert(), hbmProp.isUpdate() ); + basic.getColumnOrFormula().add( column ); + } } else if ( !hbmProp.getFormula().isEmpty() ) { for ( String formula : hbmProp.getFormula() ) { @@ -891,17 +1016,20 @@ public class HbmXmlTransformer { } } else { - for ( JaxbColumnElement hbmColumn : hbmProp.getColumn() ) { - final JaxbColumn column = new JaxbColumn(); - transferColumn( column, hbmColumn, null, hbmProp.isInsert(), hbmProp.isUpdate() ); - basic.getColumnOrFormula().add( column ); - } + final JaxbColumn column = new JaxbColumn(); + column.setName( hbmProp.getColumnAttribute() ); + column.setLength( hbmProp.getLength() ); + column.setNullable( hbmProp.isNotNull() == null ? null : !hbmProp.isNotNull() ); + column.setUnique( hbmProp.isUnique() ); + column.setInsertable( hbmProp.isInsert() ); + column.setUpdatable( hbmProp.isUpdate() ); + basic.getColumnOrFormula().add( column ); } return basic; } - private void transferEmbeddedAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferEmbeddedAttributes(JaxbEntity entity, EntityElement hbmClass) { for (JaxbComponentElement hbmComponent : hbmClass.getComponent()) { entity.getAttributes().getEmbedded().add( transferEmbeddedAttribute( hbmComponent ) ); ormRoot.getEmbeddable().add( transferEmbeddable( entity, hbmComponent ) ); @@ -941,18 +1069,21 @@ public class HbmXmlTransformer { return embedded; } - private void transferOneToOneAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferOneToOneAttributes(JaxbEntity entity, EntityElement hbmClass) { for (JaxbOneToOneElement hbmO2O : hbmClass.getOneToOne()) { entity.getAttributes().getOneToOne().add( transferOneToOneAttribute( hbmO2O ) ); } } private JaxbOneToOne transferOneToOneAttribute(JaxbOneToOneElement hbmO2O) { + if (!hbmO2O.getFormula().isEmpty() || !StringHelper.isEmpty( hbmO2O.getFormulaAttribute() )) { + throw new MappingException( "HBM transformation: Formulas within one-to-ones are not yet supported." ); + } + final JaxbOneToOne o2o = new JaxbOneToOne(); o2o.setAttributeAccessor( hbmO2O.getAccess() ); o2o.setHbmCascade( convertCascadeType( hbmO2O.getCascade() ) ); o2o.setOrphanRemoval( isOrphanRemoval( hbmO2O.getCascade() ) ); - o2o.setFetch( convert( hbmO2O.getFetch() ) ); o2o.setForeignKey( new JaxbForeignKey() ); o2o.getForeignKey().setName( hbmO2O.getForeignKey() ); if (! StringHelper.isEmpty( hbmO2O.getPropertyRef() )) { @@ -967,23 +1098,39 @@ public class HbmXmlTransformer { else { o2o.setTargetEntity( hbmO2O.getClazz() ); } + + transferFetchable( hbmO2O.getLazy(), hbmO2O.getFetch(), hbmO2O.getOuterJoin(), hbmO2O.isConstrained(), o2o ); + return o2o; } - private void transferManyToOneAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferManyToOneAttributes(JaxbEntity entity, EntityElement hbmClass) { for (JaxbManyToOneElement hbmM2O : hbmClass.getManyToOne()) { entity.getAttributes().getManyToOne().add( transferManyToOneAttribute( hbmM2O ) ); } } private JaxbManyToOne transferManyToOneAttribute(JaxbManyToOneElement hbmM2O) { + if (!hbmM2O.getFormula().isEmpty() || !StringHelper.isEmpty( hbmM2O.getFormulaAttribute() )) { + throw new MappingException( "HBM transformation: Formulas within many-to-ones are not yet supported." ); + } final JaxbManyToOne m2o = new JaxbManyToOne(); m2o.setAttributeAccessor( hbmM2O.getAccess() ); m2o.setHbmCascade( convertCascadeType( hbmM2O.getCascade() ) ); - m2o.setFetch( convert( hbmM2O.getFetch() ) ); m2o.setForeignKey( new JaxbForeignKey() ); m2o.getForeignKey().setName( hbmM2O.getForeignKey() ); - if (hbmM2O.getColumn().isEmpty()) { + if (! hbmM2O.getColumn().isEmpty()) { + for ( JaxbColumnElement hbmColumn : hbmM2O.getColumn() ) { + final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); + joinColumn.setName( hbmColumn.getName() ); + joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() ); + joinColumn.setUnique( hbmColumn.isUnique() ); + joinColumn.setInsertable( hbmM2O.isInsert() ); + joinColumn.setUpdatable( hbmM2O.isUpdate() ); + m2o.getJoinColumn().add( joinColumn ); + } + } + else { final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) { // AbstractBasicBindingTests seems to imply this was the case @@ -997,17 +1144,10 @@ public class HbmXmlTransformer { } joinColumn.setNullable( hbmM2O.isNotNull() == null ? null : !hbmM2O.isNotNull() ); joinColumn.setUnique( hbmM2O.isUnique() ); + joinColumn.setInsertable( hbmM2O.isInsert() ); + joinColumn.setUpdatable( hbmM2O.isUpdate() ); m2o.getJoinColumn().add( joinColumn ); } - else { - for ( JaxbColumnElement hbmColumn : hbmM2O.getColumn() ) { - final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); - joinColumn.setName( hbmColumn.getName() ); - joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() ); - joinColumn.setUnique( hbmColumn.isUnique() ); - m2o.getJoinColumn().add( joinColumn ); - } - } m2o.setName( hbmM2O.getName() ); m2o.setOptional( hbmM2O.isNotNull() == null ? true : !hbmM2O.isNotNull() ); if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) { @@ -1016,6 +1156,7 @@ public class HbmXmlTransformer { else { m2o.setTargetEntity( hbmM2O.getClazz() ); } + transferFetchable( hbmM2O.getLazy(), hbmM2O.getFetch(), hbmM2O.getOuterJoin(), null, m2o ); return m2o; } @@ -1027,7 +1168,16 @@ public class HbmXmlTransformer { m2o.setFetch( convert( hbmM2O.getLazy() ) ); m2o.setForeignKey( new JaxbForeignKey() ); m2o.getForeignKey().setName( hbmM2O.getForeignKey() ); - if (hbmM2O.getColumn().isEmpty()) { + if (! hbmM2O.getColumn().isEmpty()) { + for ( JaxbColumnElement hbmColumn : hbmM2O.getColumn() ) { + final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); + joinColumn.setName( hbmColumn.getName() ); + joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() ); + joinColumn.setUnique( hbmColumn.isUnique() ); + m2o.getJoinColumn().add( joinColumn ); + } + } + else { final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) { // AbstractBasicBindingTests seems to imply this was the case @@ -1038,15 +1188,6 @@ public class HbmXmlTransformer { } m2o.getJoinColumn().add( joinColumn ); } - else { - for ( JaxbColumnElement hbmColumn : hbmM2O.getColumn() ) { - final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); - joinColumn.setName( hbmColumn.getName() ); - joinColumn.setNullable( hbmColumn.isNotNull() == null ? null : !hbmColumn.isNotNull() ); - joinColumn.setUnique( hbmColumn.isUnique() ); - m2o.getJoinColumn().add( joinColumn ); - } - } m2o.setName( hbmM2O.getName() ); if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) { m2o.setTargetEntity( hbmM2O.getEntityName() ); @@ -1054,10 +1195,13 @@ public class HbmXmlTransformer { else { m2o.setTargetEntity( hbmM2O.getClazz() ); } + if (hbmM2O.getOnDelete() != null) { + m2o.setOnDelete( convert( hbmM2O.getOnDelete() ) ); + } return m2o; } - private void transferAnyAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferAnyAttributes(JaxbEntity entity, EntityElement hbmClass) { } @@ -1066,11 +1210,11 @@ public class HbmXmlTransformer { return new JaxbAny(); } - private void transferManyToAnyAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferManyToAnyAttributes(JaxbEntity entity, EntityElement hbmClass) { } - private void transferPrimitiveArrayAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferPrimitiveArrayAttributes(JaxbEntity entity, EntityElement hbmClass) { if ( !hbmClass.getPrimitiveArray().isEmpty() ) { throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : " + hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used construct " + @@ -1078,7 +1222,7 @@ public class HbmXmlTransformer { } } - private void transferPropertiesGrouping(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferPropertiesGrouping(JaxbEntity entity, EntityElement hbmClass) { if ( !hbmClass.getProperties().isEmpty() ) { throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : " + hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used construct " + @@ -1086,70 +1230,106 @@ public class HbmXmlTransformer { } } - private void transferDiscriminatorSubclass(JaxbSubclassElement hbmSubclass, JaxbEntity entity) { - // todo : implement - } - - private void transferJoinedSubclass(JaxbJoinedSubclassElement hbmSubclass, JaxbEntity entity) { - // todo : implement - } - - private void transferUnionSubclass(JaxbUnionSubclassElement hbmSubclass, JaxbEntity entity) { - // todo : implement + private void transferUnionSubclass(JaxbUnionSubclassElement hbmSubclass, JaxbEntity subclassEntity) { + if (! StringHelper.isEmpty( hbmSubclass.getProxy() )) { + // TODO + throw new MappingException( "HBM transformation: proxy attributes not yet supported" ); + } + transferEntityElement( hbmSubclass, subclassEntity ); + transferEntityElementAttributes( subclassEntity, hbmSubclass ); + + subclassEntity.setTable( new JaxbTable() ); + subclassEntity.getTable().setCatalog( hbmSubclass.getCatalog() ); + subclassEntity.getTable().setSchema( hbmSubclass.getSchema() ); + subclassEntity.getTable().setName( hbmSubclass.getTable() ); + subclassEntity.getTable().setComment( hbmSubclass.getComment() ); + subclassEntity.getTable().setCheck( hbmSubclass.getCheck() ); + + if (! hbmSubclass.getUnionSubclass().isEmpty()) { + subclassEntity.setInheritance( new JaxbInheritance() ); + subclassEntity.getInheritance().setStrategy( JaxbInheritanceType.UNION_SUBCLASS ); + for (JaxbUnionSubclassElement nestedHbmSubclass : hbmSubclass.getUnionSubclass()) { + final JaxbEntity nestedSubclassEntity = new JaxbEntity(); + ormRoot.getEntity().add( nestedSubclassEntity ); + transferUnionSubclass( nestedHbmSubclass, nestedSubclassEntity ); + } + } } - private void transferPluralAttribute(JaxbEntity entity, JaxbClassElement hbmClass) { + private void transferCollectionAttributes(JaxbEntity entity, EntityElement hbmClass) { for (JaxbSetElement hbmSet : hbmClass.getSet()) { - transferPluralAttribute( entity, hbmSet, "set" ); + transferCollectionAttribute( entity, hbmSet, "set", hbmSet.getOrderBy() ); } for (JaxbBagElement hbmBag : hbmClass.getBag()) { - transferPluralAttribute( entity, hbmBag, "bag" ); + transferCollectionAttribute( entity, hbmBag, "bag", hbmBag.getOrderBy() ); } for (JaxbListElement hbmList : hbmClass.getList()) { - transferPluralAttribute( entity, hbmList, "list" ); + final CollectionAttribute list = transferCollectionAttribute( entity, hbmList, "list", null ); + transferListIndex( list, hbmList.getListIndex() ); } for (JaxbMapElement hbmMap : hbmClass.getMap()) { - transferMapAttribute( entity, hbmMap ); + final CollectionAttribute map = transferCollectionAttribute( entity, hbmMap, "map", hbmMap.getOrderBy() ); + transferMapKey( map, hbmMap ); + } + + for (JaxbArrayElement hbmArray : hbmClass.getArray()) { + final CollectionAttribute array = transferCollectionAttribute( entity, hbmArray, "array", null ); + transferListIndex( array, hbmArray.getListIndex() ); } } - private void transferPluralAttribute(JaxbEntity entity, PluralAttributeElement pluralAttribute, - String collectionTypeName) { + private CollectionAttribute transferCollectionAttribute(JaxbEntity entity, PluralAttributeElement pluralAttribute, + String collectionTypeName, String orderBy) { + if (pluralAttribute.getBatchSize() > 0) { + // TODO: New schema only defines batch-size at the class level, not collections. + throw new MappingException( "HBM transformation: 'batch-size' not yet supported." ); + } + if (! StringHelper.isEmpty( pluralAttribute.getWhere() )) { + // TODO: New schema only defines where at the class level, not collections. + throw new MappingException( "HBM transformation: 'where' not yet supported." ); + } + + CollectionAttribute collection = null; if (pluralAttribute.getElement() != null) { - entity.getAttributes().getElementCollection().add( transferElementCollection( - pluralAttribute.getName(), collectionTypeName, pluralAttribute.getElement() ) ); + final JaxbElementCollection elementCollection = transferElementCollection( + pluralAttribute, collectionTypeName, orderBy ); + entity.getAttributes().getElementCollection().add( elementCollection ); + collection = elementCollection; } - if (pluralAttribute.getOneToMany() != null) { - entity.getAttributes().getOneToMany().add( transferOneToManyAttribute( - pluralAttribute, collectionTypeName ) ); - } - if (pluralAttribute.getManyToMany() != null) { - entity.getAttributes().getManyToMany().add( transferManyToManyAttribute( - pluralAttribute, collectionTypeName ) ); - } - } - - private void transferMapAttribute(JaxbEntity entity, JaxbMapElement pluralAttribute) { - if (pluralAttribute.getElement() != null) { - entity.getAttributes().getElementCollection().add( transferElementCollection( - pluralAttribute.getName(), "map", pluralAttribute.getElement() ) ); - } - if (pluralAttribute.getOneToMany() != null) { - final JaxbOneToMany o2m = transferOneToManyAttribute( pluralAttribute, "map" ); - transferMapKey( o2m, pluralAttribute ); + else if (pluralAttribute.getOneToMany() != null) { + final JaxbOneToMany o2m = transferOneToManyAttribute( pluralAttribute, collectionTypeName, orderBy ); entity.getAttributes().getOneToMany().add( o2m ); + collection = o2m; } - if (pluralAttribute.getManyToMany() != null) { - final JaxbManyToMany m2m = transferManyToManyAttribute( pluralAttribute, "map" ); - transferMapKey( m2m, pluralAttribute ); + else if (pluralAttribute.getManyToMany() != null) { + final JaxbManyToMany m2m = transferManyToManyAttribute( pluralAttribute, collectionTypeName ); entity.getAttributes().getManyToMany().add( m2m ); + collection = m2m; + } + + if (collection != null) { + for (JaxbFilterElement hbmFilter : pluralAttribute.getFilter()) { + // TODO: How to set filter on collections in unified xml? + throw new MappingException( "HBM transformation: Filters within collections are not yet supported." ); + } + } + + return collection; + } + + private void transferListIndex(CollectionAttribute list, JaxbListIndexElement hbmListIndex) { + if (hbmListIndex != null) { + final JaxbOrderColumn orderColumn = new JaxbOrderColumn(); + // TODO: multiple columns? + orderColumn.setName( hbmListIndex.getColumnAttribute() ); + list.setOrderColumn( orderColumn ); } } - private void transferMapKey(MapAttribute map, JaxbMapElement pluralAttribute) { + private void transferMapKey(CollectionAttribute map, JaxbMapElement pluralAttribute) { if (pluralAttribute.getIndex() != null) { final JaxbMapKeyColumn mapKey = new JaxbMapKeyColumn(); // TODO: multiple columns? @@ -1163,7 +1343,7 @@ public class HbmXmlTransformer { } if (pluralAttribute.getMapKey() != null) { if (! StringHelper.isEmpty( pluralAttribute.getMapKey().getFormulaAttribute() )) { - throw new MappingException( "HBM transformation: Formulas within map keys are not supported." ); + throw new MappingException( "HBM transformation: Formulas within map keys are not yet supported." ); } final JaxbMapKeyColumn mapKey = new JaxbMapKeyColumn(); // TODO: multiple columns? @@ -1178,10 +1358,11 @@ public class HbmXmlTransformer { } } - private JaxbElementCollection transferElementCollection(String propertyName, String collectionTypeName, - JaxbElementElement hbmElement) { + private JaxbElementCollection transferElementCollection( + PluralAttributeElement pluralAttribute, String collectionTypeName, String orderBy) { + final JaxbElementElement hbmElement = pluralAttribute.getElement(); final JaxbElementCollection element = new JaxbElementCollection(); - element.setName( propertyName ); + element.setName( pluralAttribute.getName() ); final JaxbColumn column = new JaxbColumn(); column.setName( hbmElement.getColumnAttribute() ); element.setColumn( column ); @@ -1191,10 +1372,13 @@ public class HbmXmlTransformer { final JaxbHbmType collectionType = new JaxbHbmType(); collectionType.setName( collectionTypeName ); element.setCollectionType( collectionType ); + element.setOrderBy( orderBy ); + transferFetchable( pluralAttribute.getLazy(), pluralAttribute.getFetch(), pluralAttribute.getOuterJoin(), element ); return element; } - private JaxbOneToMany transferOneToManyAttribute(PluralAttributeElement pluralAttribute, String collectionTypeName) { + private JaxbOneToMany transferOneToManyAttribute( + PluralAttributeElement pluralAttribute, String collectionTypeName, String orderBy) { final JaxbOneToManyElement hbmO2M = pluralAttribute.getOneToMany(); final JaxbOneToMany o2m = new JaxbOneToMany(); final JaxbHbmType collectionType = new JaxbHbmType(); @@ -1203,21 +1387,13 @@ public class HbmXmlTransformer { o2m.setAttributeAccessor( pluralAttribute.getAccess() ); o2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) ); o2m.setOrphanRemoval( isOrphanRemoval( pluralAttribute.getCascade() ) ); - o2m.setFetch( convert( pluralAttribute.getFetch() ) ); + transferFetchable( pluralAttribute.getLazy(), pluralAttribute.getFetch(), pluralAttribute.getOuterJoin(), o2m ); o2m.setName( pluralAttribute.getName() ); o2m.setTargetEntity( hbmO2M.getClazz() ); o2m.setInverse( pluralAttribute.isInverse() ); if (pluralAttribute.getKey() != null) { final JaxbKeyElement hbmKey = pluralAttribute.getKey(); - if (hbmKey.getColumn().isEmpty()) { - final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); - joinColumn.setName( hbmKey.getColumnAttribute() ); - if (! StringHelper.isEmpty( hbmKey.getPropertyRef() )) { - joinColumn.setReferencedColumnName( hbmKey.getPropertyRef() ); - } - o2m.getJoinColumn().add( joinColumn ); - } - else { + if (! hbmKey.getColumn().isEmpty()) { for ( JaxbColumnElement hbmColumn : hbmKey.getColumn() ) { final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); joinColumn.setName( hbmColumn.getName() ); @@ -1226,20 +1402,43 @@ public class HbmXmlTransformer { o2m.getJoinColumn().add( joinColumn ); } } + else { + final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); + joinColumn.setName( hbmKey.getColumnAttribute() ); + joinColumn.setNullable( hbmKey.isNotNull() == null ? null : !hbmKey.isNotNull() ); + joinColumn.setUnique( hbmKey.isUnique() ); + if (! StringHelper.isEmpty( hbmKey.getPropertyRef() )) { + joinColumn.setReferencedColumnName( hbmKey.getPropertyRef() ); + } + o2m.getJoinColumn().add( joinColumn ); + } + if (hbmKey.getOnDelete() != null) { + o2m.setOnDelete( convert( hbmKey.getOnDelete() ) ); + } } + o2m.setOrderBy( orderBy ); return o2m; } private JaxbManyToMany transferManyToManyAttribute(PluralAttributeElement pluralAttribute, String collectionTypeName) { final JaxbManyToManyElement hbmM2M = pluralAttribute.getManyToMany(); + + if (!hbmM2M.getFormula().isEmpty() || !StringHelper.isEmpty( hbmM2M.getFormulaAttribute() )) { + throw new MappingException( "HBM transformation: Formulas within many-to-manys are not yet supported." ); + } + if (isOrphanRemoval( pluralAttribute.getCascade() )) { + // TODO: JPA doesn't provide an orphan-removal field -- another way to do it? + throw new MappingException( "HBM transformation: many-to-manys w/ orphan removal not yet supported." ); + } + final JaxbManyToMany m2m = new JaxbManyToMany(); final JaxbHbmType collectionType = new JaxbHbmType(); collectionType.setName( collectionTypeName ); m2m.setCollectionType( collectionType ); m2m.setAttributeAccessor( pluralAttribute.getAccess() ); m2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) ); - m2m.setFetch( convert( pluralAttribute.getFetch() ) ); + transferFetchable( pluralAttribute.getLazy(), pluralAttribute.getFetch(), pluralAttribute.getOuterJoin(), m2m ); m2m.setName( pluralAttribute.getName() ); m2m.setTargetEntity( hbmM2M.getClazz() ); m2m.setOrderBy( hbmM2M.getOrderBy() ); @@ -1259,10 +1458,8 @@ public class HbmXmlTransformer { } } else { - // TODO: handle other JaxbKeyElement props final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); joinColumn.setName( columnName ); - // TODO: Handle other JaxbJoinColumn props final JaxbJoinColumn inverseJoinColumn = new JaxbJoinColumn(); if (StringHelper.isEmpty( hbmM2M.getColumnAttribute() )) { inverseJoinColumn.setName( Collection.DEFAULT_ELEMENT_COLUMN_NAME ); @@ -1315,6 +1512,9 @@ public class HbmXmlTransformer { if (hbmCascade.contains( "lock" )) { cascadeType.setCascadeLock( new JaxbEmptyType() ); } + if (hbmCascade.contains( "delete" )) { + cascadeType.setCascadeDelete( new JaxbEmptyType() ); + } } } return cascadeType; @@ -1328,43 +1528,119 @@ public class HbmXmlTransformer { return false; } - private FetchType convert(JaxbFetchStyleAttribute hbmFetch) { - if (hbmFetch != null) { - switch (hbmFetch) { - case JOIN: - return FetchType.EAGER; - case SELECT: - return FetchType.LAZY; + // ToOne + private void transferFetchable(JaxbLazyAttributeWithNoProxy hbmLazy, JaxbFetchStyleAttribute hbmFetch, + JaxbOuterJoinAttribute hbmOuterJoin, Boolean constrained, FetchableAttribute fetchable) { + FetchType laziness = FetchType.LAZY; + FetchMode fetch = FetchMode.SELECT; + + if (hbmLazy != null) { + if (hbmLazy.equals( JaxbLazyAttributeWithNoProxy.FALSE )) { + laziness = FetchType.EAGER; + } + else if (hbmLazy.equals( JaxbLazyAttributeWithNoProxy.NO_PROXY )) { + // TODO: @LazyToOne(LazyToOneOption.PROXY) or @LazyToOne(LazyToOneOption.NO_PROXY) } } - return null; - } - - private FetchType convert(JaxbFetchAttributeWithSubselect hbmFetch) { - if (hbmFetch != null) { - switch (hbmFetch) { - case JOIN: - return FetchType.EAGER; - case SELECT: - return FetchType.LAZY; + + // allow fetch style to override laziness, if necessary + if (constrained != null && ! constrained) { + // NOTE SPECIAL CASE: one-to-one constrained=false cannot be proxied, so default to join and non-lazy + laziness = FetchType.EAGER; + fetch = FetchMode.JOIN; + } + else { + if (hbmFetch == null) { + if (hbmOuterJoin != null && hbmOuterJoin.equals( JaxbOuterJoinAttribute.TRUE )) { + laziness = FetchType.EAGER; + fetch = FetchMode.JOIN; + } + } + else { + if (hbmFetch.equals( JaxbFetchStyleAttribute.JOIN )) { + laziness = FetchType.EAGER; + fetch = FetchMode.JOIN; + } } } - return null; + + fetchable.setFetch( laziness ); + fetchable.setHbmFetchMode( fetch ); } + // ToMany + private void transferFetchable(JaxbLazyAttributeWithExtra hbmLazy, JaxbFetchAttributeWithSubselect hbmFetch, + JaxbOuterJoinAttribute hbmOuterJoin, FetchableAttribute fetchable) { + FetchType laziness = FetchType.LAZY; + FetchMode fetch = FetchMode.SELECT; + + if (hbmLazy != null) { + if (hbmLazy.equals( JaxbLazyAttributeWithExtra.EXTRA )) { + throw new MappingException( "HBM transformation: extra lazy not yet supported." ); + } + else if (hbmLazy.equals( JaxbLazyAttributeWithExtra.FALSE )) { + laziness = FetchType.EAGER; + } + } + + // allow fetch style to override laziness, if necessary + if (hbmFetch == null) { + if (hbmOuterJoin != null && hbmOuterJoin.equals( JaxbOuterJoinAttribute.TRUE )) { + laziness = FetchType.EAGER; + fetch = FetchMode.JOIN; + } + } + else { + if (hbmFetch.equals( JaxbFetchAttributeWithSubselect.JOIN )) { + laziness = FetchType.EAGER; + fetch = FetchMode.JOIN; + } + else if (hbmFetch.equals( JaxbFetchAttributeWithSubselect.SUBSELECT )) { + fetch = FetchMode.SUBSELECT; + } + } + + fetchable.setFetch( laziness ); + fetchable.setHbmFetchMode( fetch ); + } + + // KeyManyToOne private FetchType convert(JaxbLazyAttribute hbmLazy) { // TODO: no-proxy? - if ( hbmLazy != null && "proxy".equalsIgnoreCase( hbmLazy.value() ) ) { + if ( hbmLazy != null || "proxy".equalsIgnoreCase( hbmLazy.value() ) ) { return FetchType.LAZY; } else if ( hbmLazy != null && "false".equalsIgnoreCase( hbmLazy.value() ) ) { return FetchType.EAGER; } else { - return null; + // proxy is HBM default + return FetchType.LAZY; } } + private JaxbOnDeleteType convert(JaxbOnDeleteAttribute hbmOnDelete) { + switch (hbmOnDelete) { + case CASCADE: + return JaxbOnDeleteType.CASCADE; + default: + return JaxbOnDeleteType.NO_ACTION; + } + } + + private JaxbHbmFilter convert(JaxbFilterElement hbmFilter) { + final JaxbHbmFilter filter = new JaxbHbmFilter(); + final boolean autoAliasInjection = hbmFilter.getAutoAliasInjection() == null ? true + : hbmFilter.getAutoAliasInjection().equalsIgnoreCase( "true" ); + filter.setAutoAliasInjection( autoAliasInjection ); + filter.setConditionAttribute( hbmFilter.getCondition() ); + filter.setName( hbmFilter.getName() ); + for (Serializable content : hbmFilter.getContent()) { + filter.getContent().add( content ); + } + return filter; + } + private String getFqClassName(String className) { final String defaultPackageName = ormRoot.getPackage(); if ( StringHelper.isNotEmpty( className ) && className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/marshalling/FetchModeMarshalling.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/marshalling/FetchModeMarshalling.java new file mode 100644 index 0000000000..bb34cdc1f8 --- /dev/null +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/jaxb/marshalling/FetchModeMarshalling.java @@ -0,0 +1,41 @@ +/* + * Hibernate, Relational Persistence for Idiomatic Java + * + * Copyright (c) 2014, Red Hat Inc. or third-party contributors as + * indicated by the @author tags or express copyright attribution + * statements applied by the authors. All third-party contributions are + * distributed under license by Red Hat Inc. + * + * This copyrighted material is made available to anyone wishing to use, modify, + * copy, or redistribute it subject to the terms and conditions of the GNU + * Lesser General Public License, as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License + * for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this distribution; if not, write to: + * Free Software Foundation, Inc. + * 51 Franklin Street, Fifth Floor + * Boston, MA 02110-1301 USA + */ +package org.hibernate.metamodel.source.internal.jaxb.marshalling; + +import org.hibernate.annotations.FetchMode; + +/** + * Marshalling support for dealing with Hibernate FetchMode enums. Plugged into JAXB for binding + * + * @author Brett Meyer + */ +public class FetchModeMarshalling { + public static FetchMode fromXml(String name) { + return FetchMode.valueOf( name ); + } + + public static String toXml(FetchMode fetchMode) { + return fetchMode.name(); + } +} diff --git a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java index 65e0436841..fe8f892e62 100644 --- a/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java +++ b/hibernate-core/src/main/java/org/hibernate/persister/entity/AbstractPropertyMapping.java @@ -173,7 +173,7 @@ public abstract class AbstractPropertyMapping implements PropertyMapping { final String[] formulaTemplates, final Mapping factory) throws MappingException { - + if ( columns.length != type.getColumnSpan(factory) ) { throw new MappingException( "broken column mapping [" + getEntityName() + '#' + path diff --git a/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd b/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd index 748e2f8778..2133a88394 100644 --- a/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd +++ b/hibernate-core/src/main/resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd @@ -498,6 +498,20 @@ + + + + + + + org.hibernate.annotations.OnDeleteAction enum values + + + + + + + @@ -702,6 +716,7 @@ + @@ -1024,6 +1039,22 @@ + + + + + + org.hibernate.annotations.FetchMode enum values + + + + + + + + + + @@ -1357,11 +1388,13 @@ + - + + @@ -1386,11 +1419,13 @@ + + @@ -1736,12 +1771,14 @@ + + @@ -1778,6 +1815,7 @@ + @@ -2333,6 +2371,7 @@ + diff --git a/hibernate-core/src/main/xjb/mapping-bindings.xjb b/hibernate-core/src/main/xjb/mapping-bindings.xjb index dd28eda498..762c57eebe 100644 --- a/hibernate-core/src/main/xjb/mapping-bindings.xjb +++ b/hibernate-core/src/main/xjb/mapping-bindings.xjb @@ -41,6 +41,12 @@ printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchTypeMarshalling.toXml" /> + + + + org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute + org.hibernate.metamodel.source.internal.jaxb.FetchableAttribute org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute - org.hibernate.metamodel.source.internal.jaxb.MapAttribute + org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute + org.hibernate.metamodel.source.internal.jaxb.FetchableAttribute org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute @@ -164,11 +172,11 @@ org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute - org.hibernate.metamodel.source.internal.jaxb.MapAttribute + org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute - org.hibernate.metamodel.source.internal.jaxb.MapAttribute + org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java index 46e41b4d02..be91062345 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnidirectionalManyToManyBindingTests.java @@ -32,6 +32,7 @@ import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.internal.MetadataImpl; import org.hibernate.metamodel.spi.relational.Column; import org.hibernate.metamodel.spi.relational.Identifier; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.After; @@ -41,6 +42,7 @@ import org.junit.Test; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema") public class UnidirectionalManyToManyBindingTests extends BaseUnitTestCase { private StandardServiceRegistryImpl serviceRegistry; diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnsavedValueHbmTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnsavedValueHbmTests.java index da720d49ae..4d5576b493 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnsavedValueHbmTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/UnsavedValueHbmTests.java @@ -27,6 +27,7 @@ import org.junit.Test; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.internal.MetadataImpl; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; @@ -35,6 +36,7 @@ import static org.junit.Assert.assertEquals; * * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class UnsavedValueHbmTests extends AbstractUnsavedValueTests { @Test diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/HbmBasicCollectionBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/HbmBasicCollectionBindingTests.java index 2dd51780b2..e24acdeac2 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/HbmBasicCollectionBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/basiccollections/HbmBasicCollectionBindingTests.java @@ -24,10 +24,12 @@ package org.hibernate.metamodel.spi.binding.basiccollections; import org.hibernate.metamodel.MetadataSources; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Hardy Ferentschik */ +@FailureExpectedWithNewUnifiedXsd(message = "extra lazy") public class HbmBasicCollectionBindingTests extends AbstractBasicCollectionBindingTests { public void addSources(MetadataSources sources) { sources.addResource( "org/hibernate/metamodel/spi/binding/basiccollections/EntityWithBasicCollections.hbm.xml" ); diff --git a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/HbmUnidirectionalOneToManyBindingTests.java b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/HbmUnidirectionalOneToManyBindingTests.java index f723da3fec..e99f656e6c 100644 --- a/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/HbmUnidirectionalOneToManyBindingTests.java +++ b/hibernate-core/src/test/java/org/hibernate/metamodel/spi/binding/onetomany/HbmUnidirectionalOneToManyBindingTests.java @@ -24,10 +24,12 @@ package org.hibernate.metamodel.spi.binding.onetomany; import org.hibernate.metamodel.MetadataSources; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Hardy Ferentschik */ +@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema") public class HbmUnidirectionalOneToManyBindingTests extends AbstractUnidirectionalOneToManyBindingTests { @Override public void addSources(MetadataSources sources) { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/ejb3/NonExistentOrmVersionTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/ejb3/NonExistentOrmVersionTest.java index 0658a17e30..397fd31a95 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/ejb3/NonExistentOrmVersionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/ejb3/NonExistentOrmVersionTest.java @@ -27,6 +27,7 @@ import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder; import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.source.spi.InvalidMappingException; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -34,6 +35,7 @@ import org.junit.Test; import static org.junit.Assert.fail; @TestForIssue(jiraKey = "HHH-6271") +@FailureExpectedWithNewUnifiedXsd public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase { @Test public void testNonExistentOrmVersion() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java b/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java index 9da7cd5634..0b282dec18 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/annotations/xml/hbm/HbmWithIdentityTest.java @@ -23,17 +23,18 @@ */ package org.hibernate.test.annotations.xml.hbm; -import org.junit.Test; - import org.hibernate.Session; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; +import org.junit.Test; /** * @author Emmanuel Bernard */ @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) +@FailureExpectedWithNewUnifiedXsd(message = "proxy attributes") public class HbmWithIdentityTest extends BaseCoreFunctionalTestCase { @Test public void testManyToOneAndInterface() throws Exception { diff --git a/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchTest.java b/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchTest.java index 994ca6cf46..45dd9e71b9 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/batchfetch/BatchFetchTest.java @@ -35,6 +35,7 @@ import org.hibernate.cfg.AvailableSettings; import org.hibernate.cfg.Configuration; import org.hibernate.loader.BatchFetchStyle; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -44,6 +45,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.") public class BatchFetchTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java b/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java index 2c5b10c417..9f4e05706c 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/cid/CompositeIdTest.java @@ -40,12 +40,14 @@ import org.hibernate.Transaction; import org.hibernate.engine.query.spi.HQLQueryPlan; import org.hibernate.exception.SQLGrammarException; import org.hibernate.hql.spi.QueryTranslator; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "MultipleBagFetchException") public class CompositeIdTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/component/basic/ComponentTest.java b/hibernate-core/src/test/java/org/hibernate/test/component/basic/ComponentTest.java index 6367f0cde1..9c790d1e79 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/component/basic/ComponentTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/component/basic/ComponentTest.java @@ -22,12 +22,13 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.component.basic; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; + import java.util.ArrayList; import java.util.Date; import java.util.List; -import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; @@ -43,17 +44,17 @@ import org.hibernate.mapping.Component; import org.hibernate.mapping.Formula; import org.hibernate.mapping.PersistentClass; import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.StandardBasicTypes; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.Test; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class ComponentTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { @@ -172,6 +173,7 @@ public class ComponentTest extends BaseCoreFunctionalTestCase { } @Test + @FailureExpectedWithNewUnifiedXsd public void testComponentQueries() { Session s = openSession(); Transaction t = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/JoinFetchProfileTest.java b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/JoinFetchProfileTest.java index 116eea5c72..459eb01dd9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/JoinFetchProfileTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/fetchprofiles/join/JoinFetchProfileTest.java @@ -22,9 +22,12 @@ * Boston, MA 02110-1301 USA */ package org.hibernate.test.fetchprofiles.join; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; -import org.junit.Test; +import java.util.List; import org.hibernate.Hibernate; import org.hibernate.Session; @@ -32,18 +35,16 @@ import org.hibernate.UnknownProfileException; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.engine.spi.SessionImplementor; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; +import org.junit.Test; /** * Various tests related to join-style fetch profiles. * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "appears using component.field as the association path is failing") public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "fetchprofiles/join/Mappings.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java index 8c96009d8d..60e60abcd2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/filter/DynamicFilterTest.java @@ -49,11 +49,10 @@ import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.transform.DistinctRootEntityResultTransformer; - +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; - import org.jboss.logging.Logger; import static org.junit.Assert.assertEquals; @@ -66,6 +65,7 @@ import static org.junit.Assert.assertTrue; * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd( message = " within a collection not supported by schema" ) @SkipForDialect( value = SybaseASE15Dialect.class, jiraKey = "HHH-3637") public class DynamicFilterTest extends BaseCoreFunctionalTestCase { private static final Logger log = Logger.getLogger( DynamicFilterTest.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java b/hibernate-core/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java index 7494fa5e64..3514de26ba 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/filter/hql/JoinedFilteredBulkManipulationTest.java @@ -25,6 +25,7 @@ package org.hibernate.test.filter.hql; import java.util.Date; import org.hibernate.dialect.CUBRIDDialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.junit.Test; @@ -41,6 +42,7 @@ import static org.junit.Assert.assertEquals; 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" ) +@FailureExpectedWithNewUnifiedXsd(message = "joined subclass not getting columns defined by superclass") public class JoinedFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingOrderByTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingOrderByTest.java index 83ab99f135..9b45b480e5 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingOrderByTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/ASTParserLoadingOrderByTest.java @@ -28,7 +28,6 @@ import java.util.Map; import java.util.Set; import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; @@ -36,6 +35,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory; import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -46,6 +46,7 @@ import static org.junit.Assert.assertTrue; * * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase { StateProvince stateProvince; private Zoo zoo1; diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java index d548afd1a3..7159afa3a9 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/CriteriaHQLAlignmentTest.java @@ -30,7 +30,6 @@ import java.util.Collections; import org.junit.After; import org.junit.Before; import org.junit.Test; - import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Projections; @@ -40,6 +39,7 @@ import org.hibernate.hql.internal.ast.tree.SelectClause; import org.hibernate.hql.internal.classic.ClassicQueryTranslatorFactory; import org.hibernate.hql.spi.QueryTranslator; import org.hibernate.hql.spi.QueryTranslatorFactory; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.type.BigDecimalType; import org.hibernate.type.BigIntegerType; @@ -55,6 +55,7 @@ import static org.junit.Assert.fail; * * @author Max Rydahl Andersen */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase { private boolean initialVersion2SqlFlagValue; diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java index 90e6fb0789..7db558f58f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/ScrollableCollectionFetchingTest.java @@ -39,6 +39,7 @@ import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialects; @@ -51,6 +52,7 @@ import org.junit.Test; * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "hql/Animal.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/hql/WithClauseTest.java b/hibernate-core/src/test/java/org/hibernate/test/hql/WithClauseTest.java index 52b3815cd1..2facf5b328 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/hql/WithClauseTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/hql/WithClauseTest.java @@ -37,6 +37,7 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.hql.internal.ast.InvalidWithClauseException; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -46,6 +47,7 @@ import org.junit.Test; * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class WithClauseTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "hql/Animal.hbm.xml", "hql/SimpleEntityWithAssociation.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/idgen/enhanced/sequence/BasicSequenceTest.java b/hibernate-core/src/test/java/org/hibernate/test/idgen/enhanced/sequence/BasicSequenceTest.java index 4973ac1111..da720a4d85 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/idgen/enhanced/sequence/BasicSequenceTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/idgen/enhanced/sequence/BasicSequenceTest.java @@ -29,6 +29,7 @@ import org.hibernate.Session; import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder; import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.persister.entity.EntityPersister; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -76,6 +77,7 @@ public class BasicSequenceTest extends BaseCoreFunctionalTestCase { @Test @TestForIssue(jiraKey = "HHH-6790") + @FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table") public void testSequencePerEntity() { final String overriddenEntityName = "SpecialEntity"; EntityPersister persister = sessionFactory().getEntityPersister( overriddenEntityName ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/VersionedEntityWithInverseOneToManyJoinFailureExpectedTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/VersionedEntityWithInverseOneToManyJoinFailureExpectedTest.java index ef1642834f..fb916cbee4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/VersionedEntityWithInverseOneToManyJoinFailureExpectedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/inverse/VersionedEntityWithInverseOneToManyJoinFailureExpectedTest.java @@ -24,9 +24,9 @@ package org.hibernate.test.immutable.entitywithmutablecollection.inverse; import org.hibernate.dialect.CUBRIDDialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.junit.Test; - import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.testing.FailureExpected; @@ -38,6 +38,7 @@ import org.hibernate.testing.FailureExpected; 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" ) +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class VersionedEntityWithInverseOneToManyJoinFailureExpectedTest extends AbstractEntityWithOneToManyTest { public String[] getMappings() { return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseManyToManyTest.java index 2d74e3caa9..d157ffd17b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseManyToManyTest.java @@ -24,10 +24,12 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?") public class EntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyJoinTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyJoinTest.java index 7f13f72c87..0b16955de2 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyJoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyJoinTest.java @@ -25,6 +25,7 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; /** @@ -35,6 +36,7 @@ import org.hibernate.testing.SkipForDialect; 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" ) +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class EntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest { public String[] getMappings() { return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyTest.java index 84d2170aaa..5a83522d31 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/EntityWithNonInverseOneToManyTest.java @@ -24,10 +24,12 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?") public class EntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest { public String[] getMappings() { return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseManyToManyTest.java index 2dfbf5d0e4..8d35ea62ed 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseManyToManyTest.java @@ -24,10 +24,12 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?") public class VersionedEntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyJoinTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyJoinTest.java index 7f504bbcdc..4aa6d4f4ec 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyJoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyJoinTest.java @@ -25,6 +25,7 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; /** @@ -35,6 +36,7 @@ import org.hibernate.testing.SkipForDialect; 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" ) +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class VersionedEntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest { public String[] getMappings() { return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyTest.java index f4f239e1b0..5f6af6b8a4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/immutable/entitywithmutablecollection/noninverse/VersionedEntityWithNonInverseOneToManyTest.java @@ -24,10 +24,12 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?") public class VersionedEntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest { public String[] getMappings() { return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java index 590691265b..67ae23d70c 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/interceptor/InterceptorTest.java @@ -35,6 +35,7 @@ import org.hibernate.Interceptor; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.TransactionException; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.Type; @@ -50,6 +51,7 @@ import static org.junit.Assert.fail; * @author Gavin King * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ +@FailureExpectedWithNewUnifiedXsd(message = "select-before-update") public class InterceptorTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java b/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java index cfb74ad1f8..d03e3a4bcb 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/interfaceproxy/InterfaceProxyTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -55,6 +56,7 @@ public class InterfaceProxyTest extends BaseCoreFunctionalTestCase { value = DialectChecks.SupportsExpectedLobUsagePattern.class, comment = "database/driver does not support expected LOB usage pattern" ) + @FailureExpectedWithNewUnifiedXsd(message = "proxy attributes") public void testInterfaceProxies() { Session s = openSession( new DocumentInterceptor() ); Transaction t = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/join/JoinTest.java b/hibernate-core/src/test/java/org/hibernate/test/join/JoinTest.java index f6ca2cf75a..a2e3612458 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/join/JoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/join/JoinTest.java @@ -39,12 +39,14 @@ import org.hibernate.Transaction; import org.hibernate.criterion.Restrictions; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jdbc.AbstractWork; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class JoinTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/join/OptionalJoinTest.java b/hibernate-core/src/test/java/org/hibernate/test/join/OptionalJoinTest.java index 27303a7df1..7ca5d56d49 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/join/OptionalJoinTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/join/OptionalJoinTest.java @@ -23,20 +23,21 @@ */ package org.hibernate.test.join; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNull; -import org.junit.Test; +import java.util.List; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNull; +import org.junit.Test; /** * @author Chris Jones and Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class OptionalJoinTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/jpa/fetch/FetchingTest.java b/hibernate-core/src/test/java/org/hibernate/test/jpa/fetch/FetchingTest.java index ce1376b9f4..2be2137048 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/jpa/fetch/FetchingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/jpa/fetch/FetchingTest.java @@ -25,11 +25,11 @@ package org.hibernate.test.jpa.fetch; import java.util.Date; import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.test.jpa.AbstractJPATest; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue; /** * @author Emmanuel Bernard */ +@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema") public class FetchingTest extends AbstractJPATest { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/unidir/ondelete/KeyManyToOneCascadeDeleteTest.java b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/unidir/ondelete/KeyManyToOneCascadeDeleteTest.java index f69dc98e9e..90b2f83461 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/unidir/ondelete/KeyManyToOneCascadeDeleteTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/keymanytoone/unidir/ondelete/KeyManyToOneCascadeDeleteTest.java @@ -29,6 +29,7 @@ import org.junit.Assert; import org.junit.Test; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -37,6 +38,7 @@ import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) */ @RequiresDialectFeature(DialectChecks.SupportsCascadeDeleteCheck.class) +@FailureExpectedWithNewUnifiedXsd(message = "metamodel doesn't appear to be able to handle the composite-id key-many-to-one's on-delete (translated to @OnDelete)") public class KeyManyToOneCascadeDeleteTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java index 016a9fe46b..3b0f2da2fc 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/OneToOneCacheTest.java @@ -125,7 +125,7 @@ public class OneToOneCacheTest extends LegacyTestCase { Serializable id = generatedId; - MainObject mo = ( MainObject ) session.load( MainObject.class, id ); + MainObject mo = ( MainObject ) session.get( MainObject.class, id ); tx.commit(); session.close(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java b/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java index fce2e357fc..c49ded47e4 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/legacy/SQLFunctionsTest.java @@ -52,12 +52,14 @@ import org.hibernate.dialect.SybaseDialect; import org.hibernate.dialect.TimesTenDialect; import org.hibernate.dialect.function.SQLFunction; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class SQLFunctionsTest extends LegacyTestCase { private static final Logger log = Logger.getLogger( SQLFunctionsTest.class ); diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java index 4341ddf3b6..80ca74cc04 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/plans/LoadPlanStructureAssertionTest.java @@ -33,8 +33,8 @@ import org.hibernate.loader.plan.spi.EntityReturn; import org.hibernate.loader.plan.spi.FetchSource; import org.hibernate.loader.plan.spi.LoadPlan; import org.hibernate.persister.entity.OuterJoinLoadable; - import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.test.annotations.Country; import org.hibernate.test.annotations.cid.keymanytoone.Card; @@ -61,6 +61,7 @@ import static org.junit.Assert.assertTrue; * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "one-to-one refers to entity-name") public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { @Test public void testJoinedOneToOne() { @@ -82,6 +83,7 @@ public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { } @Test + @FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public void testSpecialOneToOne() { // tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java index 388233493b..09c4bc2a5b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/process/NonEncapsulatedCompositeIdResultSetProcessorTest.java @@ -42,9 +42,8 @@ import org.hibernate.loader.plan.exec.spi.LoadQueryDetails; import org.hibernate.loader.plan.spi.LoadPlan; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.type.Type; - import org.junit.Test; - +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.test.onetoone.formula.Address; import org.hibernate.test.onetoone.formula.Person; @@ -55,6 +54,7 @@ import static org.junit.Assert.assertNotNull; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class NonEncapsulatedCompositeIdResultSetProcessorTest extends BaseCoreFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/KeyManyToOneWalkingTest.java b/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/KeyManyToOneWalkingTest.java index d47e424c45..2c5cf8d073 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/KeyManyToOneWalkingTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/loadplans/walking/KeyManyToOneWalkingTest.java @@ -25,15 +25,15 @@ package org.hibernate.test.loadplans.walking; import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.walking.spi.MetamodelGraphWalker; - import org.junit.Test; - +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.test.onetoone.formula.Address; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class KeyManyToOneWalkingTest extends BaseCoreFunctionalTestCase { @Override protected String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/manytomany/ManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/manytomany/ManyToManyTest.java index 33b6ef3151..811f6b9d00 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/manytomany/ManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/manytomany/ManyToManyTest.java @@ -24,13 +24,13 @@ package org.hibernate.test.manytomany; import org.junit.Test; - import org.hibernate.FetchMode; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -40,6 +40,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class ManyToManyTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java index 5ee397b82b..fa26c52540 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/manytomany/batchload/BatchedManyToManyTest.java @@ -23,8 +23,13 @@ */ package org.hibernate.test.manytomany.batchload; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; + import java.util.List; +import junit.framework.Assert; + import org.hibernate.EmptyInterceptor; import org.hibernate.Hibernate; import org.hibernate.Interceptor; @@ -37,14 +42,9 @@ import org.hibernate.engine.jdbc.batch.spi.Batch; import org.hibernate.engine.jdbc.batch.spi.BatchKey; import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.stat.CollectionStatistics; - -import org.junit.Test; -import junit.framework.Assert; - +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * Tests loading of many-to-many collection which should trigger @@ -52,6 +52,7 @@ import static org.junit.Assert.assertTrue; * * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.") public class BatchedManyToManyTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/Membership.java b/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/Membership.java index 7a95ea769a..ebb05ca0dc 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/Membership.java +++ b/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/Membership.java @@ -23,6 +23,7 @@ * */ package org.hibernate.test.manytomanyassociationclass; + import java.io.Serializable; /** diff --git a/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/surrogateid/generated/ManyToManyAssociationClassGeneratedIdTest.java b/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/surrogateid/generated/ManyToManyAssociationClassGeneratedIdTest.java index 6d56207750..c6ed1d0a0b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/surrogateid/generated/ManyToManyAssociationClassGeneratedIdTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/manytomanyassociationclass/surrogateid/generated/ManyToManyAssociationClassGeneratedIdTest.java @@ -31,6 +31,7 @@ import org.hibernate.exception.ConstraintViolationException; import org.hibernate.test.manytomanyassociationclass.AbstractManyToManyAssociationClassTest; import org.hibernate.test.manytomanyassociationclass.Membership; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.fail; @@ -39,6 +40,7 @@ import static org.junit.Assert.fail; * * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off: Membership and subclass have Serializable id, but mapping uses type=long") public class ManyToManyAssociationClassGeneratedIdTest extends AbstractManyToManyAssociationClassTest { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/mapelemformula/MapElementFormulaTest.java b/hibernate-core/src/test/java/org/hibernate/test/mapelemformula/MapElementFormulaTest.java index 2f4d2b839d..1d4621eff4 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/mapelemformula/MapElementFormulaTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mapelemformula/MapElementFormulaTest.java @@ -24,9 +24,9 @@ package org.hibernate.test.mapelemformula; import org.junit.Test; - import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -34,6 +34,7 @@ import static org.junit.Assert.assertEquals; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class MapElementFormulaTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "mapelemformula/UserGroup.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java b/hibernate-core/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java index 2f217646ef..c8831dd52f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mappingexception/MappingExceptionTest.java @@ -19,6 +19,7 @@ import org.hibernate.metamodel.source.spi.InvalidMappingException; import org.hibernate.metamodel.source.spi.MappingNotFoundException; import org.hibernate.xml.spi.SourceType; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; @@ -34,6 +35,7 @@ import static org.junit.Assert.fail; */ public class MappingExceptionTest extends BaseUnitTestCase { @Test + @FailureExpectedWithNewUnifiedXsd public void testNotFound() throws MappingException, MalformedURLException { Configuration cfg = new Configuration(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/mixed/MixedTest.java b/hibernate-core/src/test/java/org/hibernate/test/mixed/MixedTest.java index 387b65c308..125398296a 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/mixed/MixedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/mixed/MixedTest.java @@ -23,22 +23,23 @@ */ package org.hibernate.test.mixed; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.dialect.SybaseASE15Dialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipLog; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.Test; /** * @author Gavin King */ @SkipForDialect( SybaseASE15Dialect.class ) +@FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table") public class MixedTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/ondelete/OnDeleteTest.java b/hibernate-core/src/test/java/org/hibernate/test/ondelete/OnDeleteTest.java index 82b8ec2de5..bb3cd7002f 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/ondelete/OnDeleteTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ondelete/OnDeleteTest.java @@ -33,6 +33,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; import org.hibernate.stat.Statistics; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -43,6 +44,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd public class OnDeleteTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/onetomany/OneToManyTest.java b/hibernate-core/src/test/java/org/hibernate/test/onetomany/OneToManyTest.java index e1120d185b..0d538248fd 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/onetomany/OneToManyTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/onetomany/OneToManyTest.java @@ -24,9 +24,9 @@ package org.hibernate.test.onetomany; import org.hibernate.dialect.CUBRIDDialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.junit.Test; - import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -36,6 +36,7 @@ import static org.junit.Assert.assertEquals; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class OneToManyTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "onetomany/Parent.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java b/hibernate-core/src/test/java/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java index c7925a0cee..05ca8381eb 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/onetoone/formula/OneToOneFormulaTest.java @@ -24,7 +24,6 @@ package org.hibernate.test.onetoone.formula; import org.junit.Test; - import org.hibernate.FetchMode; import org.hibernate.Hibernate; import org.hibernate.Session; @@ -34,6 +33,7 @@ import org.hibernate.cfg.Environment; import org.hibernate.criterion.Property; import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.TextType; @@ -49,6 +49,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase { private static class TextAsMaterializedClobType extends AbstractSingleColumnStandardBasicType { public final static TextAsMaterializedClobType INSTANCE = new TextAsMaterializedClobType(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/onetoone/link/OneToOneLinkTest.java b/hibernate-core/src/test/java/org/hibernate/test/onetoone/link/OneToOneLinkTest.java index 4a2f2b02ba..435af1940f 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/onetoone/link/OneToOneLinkTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/onetoone/link/OneToOneLinkTest.java @@ -26,10 +26,10 @@ package org.hibernate.test.onetoone.link; import java.util.Date; import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -41,6 +41,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported") public class OneToOneLinkTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/onetoone/optional/Person.java b/hibernate-core/src/test/java/org/hibernate/test/onetoone/optional/Person.java index a166b02fd7..69e94562db 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/onetoone/optional/Person.java +++ b/hibernate-core/src/test/java/org/hibernate/test/onetoone/optional/Person.java @@ -6,5 +6,4 @@ package org.hibernate.test.onetoone.optional; */ public class Person extends Entity { public Address address; - public Address mailingAddress; } diff --git a/hibernate-core/src/test/java/org/hibernate/test/ops/CreateTest.java b/hibernate-core/src/test/java/org/hibernate/test/ops/CreateTest.java index 8a266493f7..ef17b6bbfa 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/ops/CreateTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ops/CreateTest.java @@ -32,6 +32,7 @@ import org.hibernate.PersistentObjectException; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.exception.ConstraintViolationException; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -41,6 +42,7 @@ import static org.junit.Assert.fail; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class CreateTest extends AbstractOperationTestCase { @Test @SuppressWarnings( {"unchecked"}) diff --git a/hibernate-core/src/test/java/org/hibernate/test/ops/DeleteTest.java b/hibernate-core/src/test/java/org/hibernate/test/ops/DeleteTest.java index 4e9e55250a..00358198cf 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/ops/DeleteTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ops/DeleteTest.java @@ -26,10 +26,12 @@ package org.hibernate.test.ops; import org.junit.Test; import org.hibernate.Session; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class DeleteTest extends AbstractOperationTestCase { @Test @SuppressWarnings( {"unchecked"}) diff --git a/hibernate-core/src/test/java/org/hibernate/test/ops/MergeTest.java b/hibernate-core/src/test/java/org/hibernate/test/ops/MergeTest.java index b06fcfba2b..bf5d36a0a0 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/ops/MergeTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/ops/MergeTest.java @@ -36,6 +36,7 @@ import org.hibernate.StaleObjectStateException; import org.hibernate.Transaction; import org.hibernate.criterion.Projections; import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; @@ -47,6 +48,7 @@ import static org.junit.Assert.fail; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class MergeTest extends AbstractOperationTestCase { @Test public void testMergeStaleVersionFails() throws Exception { diff --git a/hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java b/hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java index 5c236d1a80..6386ee5bf7 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/optlock/OptimisticLockTest.java @@ -24,7 +24,7 @@ package org.hibernate.test.optlock; -import org.junit.Test; +import static org.junit.Assert.fail; import org.hibernate.JDBCException; import org.hibernate.Session; @@ -32,10 +32,10 @@ import org.hibernate.StaleObjectStateException; import org.hibernate.StaleStateException; import org.hibernate.dialect.SQLServerDialect; import org.hibernate.testing.DialectChecks; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.fail; +import org.junit.Test; /** * Tests relating to the optimistic-lock mapping option. @@ -47,6 +47,7 @@ import static org.junit.Assert.fail; value = DialectChecks.DoesRepeatableReadNotCauseReadersToBlockWritersCheck.class, comment = "potential deadlock" ) +@FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table") public class OptimisticLockTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/orphan/manytomany/ManyToManyOrphanTest.java b/hibernate-core/src/test/java/org/hibernate/test/orphan/manytomany/ManyToManyOrphanTest.java index 692cbf066f..985203338b 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/orphan/manytomany/ManyToManyOrphanTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/orphan/manytomany/ManyToManyOrphanTest.java @@ -29,10 +29,12 @@ import java.util.List; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; +@FailureExpectedWithNewUnifiedXsd(message = "many-to-manys w/ orphan removal not yet supported") public class ManyToManyOrphanTest extends BaseCoreFunctionalTestCase { @Override diff --git a/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/composite/DeleteOneToOneOrphansTest.java b/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/composite/DeleteOneToOneOrphansTest.java index c28cb4be8a..e36b03ef71 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/composite/DeleteOneToOneOrphansTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/composite/DeleteOneToOneOrphansTest.java @@ -28,6 +28,7 @@ import java.util.List; import org.junit.Test; import org.hibernate.Session; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; @@ -38,6 +39,7 @@ import static org.junit.Assert.assertNull; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "m2o with orphan removal") public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/reversed/unidirectional/DeleteOneToOneOrphansTest.java b/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/reversed/unidirectional/DeleteOneToOneOrphansTest.java index 504770f8b8..72d8dfa40d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/reversed/unidirectional/DeleteOneToOneOrphansTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/orphan/one2one/fk/reversed/unidirectional/DeleteOneToOneOrphansTest.java @@ -30,6 +30,7 @@ import static org.junit.Assert.assertNull; import java.util.List; import org.hibernate.Session; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -37,6 +38,7 @@ import org.junit.Test; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "m2o with orphan removal") public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "orphan/one2one/fk/reversed/unidirectional/Mapping.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java b/hibernate-core/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java index 135f9d24fc..68490edf0e 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/readonly/ReadOnlyVersionedNodesTest.java @@ -24,9 +24,9 @@ package org.hibernate.test.readonly; import org.junit.Test; - import org.hibernate.Session; import org.hibernate.testing.FailureExpected; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -36,6 +36,7 @@ import static org.junit.Assert.assertSame; /** * @author Gail Badner */ +@FailureExpectedWithNewUnifiedXsd(message = "statistics are failing") public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java b/hibernate-core/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java index 2eda11ea74..00ff31f87d 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/resulttransformer/ResultTransformerTest.java @@ -26,26 +26,26 @@ */ package org.hibernate.test.resulttransformer; -import java.sql.ResultSet; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; -import org.junit.Test; +import java.util.List; import org.hibernate.Query; import org.hibernate.ScrollableResults; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.dialect.AbstractHANADialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.transform.ResultTransformer; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Sharath Reddy */ +@FailureExpectedWithNewUnifiedXsd(message = "named query return-join") public class ResultTransformerTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java b/hibernate-core/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java index 7d714e20eb..83317002f7 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/stateless/StatelessSessionTest.java @@ -31,6 +31,7 @@ import org.hibernate.ScrollMode; import org.hibernate.ScrollableResults; import org.hibernate.StatelessSession; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -40,6 +41,7 @@ import static org.junit.Assert.assertNotSame; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class StatelessSessionTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "stateless/Document.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/stats/StatsTest.java b/hibernate-core/src/test/java/org/hibernate/test/stats/StatsTest.java index e8f8ea4bfa..d630f9220f 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/stats/StatsTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/stats/StatsTest.java @@ -36,6 +36,7 @@ import org.hibernate.cfg.Configuration; import org.hibernate.stat.QueryStatistics; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseUnitTestCase; import org.junit.Test; @@ -48,6 +49,7 @@ import static org.junit.Assert.assertNotNull; * * @author Emmanuel Bernard */ +@FailureExpectedWithNewUnifiedXsd(message = "What does translate to in annotations?") public class StatsTest extends BaseUnitTestCase { public String[] getMappings() { return new String[] { "stats/Continent.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java index 1101da6a72..24d8a804dc 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/DiscrimSubclassFilterTest.java @@ -29,9 +29,9 @@ import java.util.Iterator; import java.util.List; import org.junit.Test; - import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -39,6 +39,7 @@ import static org.junit.Assert.assertEquals; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd( message = " within a collection not supported by schema" ) public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase { public final String[] getMappings() { return new String[] { "subclassfilter/discrim-subclass.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java index 7e077d4baf..cd3e28bcd0 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/subclassfilter/JoinedSubclassFilterTest.java @@ -29,6 +29,7 @@ import java.util.Iterator; import java.util.List; import org.hibernate.dialect.CUBRIDDialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.SkipForDialect; import org.junit.Test; @@ -46,6 +47,7 @@ import static org.junit.Assert.assertEquals; 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" ) +@FailureExpectedWithNewUnifiedXsd(message = "single filter used across joined-subclasses") public class JoinedSubclassFilterTest extends BaseCoreFunctionalTestCase { public final String[] getMappings() { return new String[] { "subclassfilter/joined-subclass.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/timestamp/TimestampTest.java b/hibernate-core/src/test/java/org/hibernate/test/timestamp/TimestampTest.java index 35c9b96156..e3e20dd128 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/timestamp/TimestampTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/timestamp/TimestampTest.java @@ -31,6 +31,7 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Environment; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -38,6 +39,7 @@ import static org.junit.Assert.assertEquals; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "timestamps") public class TimestampTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "timestamp/User.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java b/hibernate-core/src/test/java/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java index 7f095263ec..4736227d4a 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/typedmanytoone/TypedManyToOneTest.java @@ -26,11 +26,11 @@ package org.hibernate.test.typedmanytoone; import java.util.List; import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.testing.FailureExpectedWithNewMetamodel; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -41,6 +41,7 @@ import static org.junit.Assert.assertTrue; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class TypedManyToOneTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "typedmanytoone/Customer.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/typeparameters/TypeParameterTest.java b/hibernate-core/src/test/java/org/hibernate/test/typeparameters/TypeParameterTest.java index 4ac8c9b213..9588021570 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/typeparameters/TypeParameterTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/typeparameters/TypeParameterTest.java @@ -35,6 +35,7 @@ import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.jdbc.Work; +import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; @@ -43,6 +44,7 @@ import org.junit.Test; * * @author Michael Gloegl */ +@FailureExpectedWithNewMetamodel public class TypeParameterTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { diff --git a/hibernate-core/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java b/hibernate-core/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java index db11771289..704927b077 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/unconstrained/UnconstrainedTest.java @@ -32,12 +32,14 @@ import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Restrictions; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.junit.Test; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations") public class UnconstrainedTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java index 42a63fc9d5..f78ecddc15 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/UnionSubclassTest.java @@ -23,9 +23,13 @@ */ package org.hibernate.test.unionsubclass; -import java.util.List; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; -import org.junit.Test; +import java.util.List; import org.hibernate.FetchMode; import org.hibernate.Hibernate; @@ -33,18 +37,15 @@ import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Order; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Gavin King */ @SuppressWarnings("unchecked") +@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS") public class UnionSubclassTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java index 18961c3bc6..6f7efc0e51 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass/alias/SellCarTest.java @@ -23,21 +23,22 @@ */ package org.hibernate.test.unionsubclass.alias; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.TestForIssue; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; +import org.junit.Test; /** * @author Strong Liu */ @TestForIssue( jiraKey = "HHH-4825" ) +@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS") public class SellCarTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "unionsubclass/alias/mapping.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java index 9059834764..0220e86a09 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/unionsubclass2/UnionSubclassTest.java @@ -23,27 +23,28 @@ */ package org.hibernate.test.unionsubclass2; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertSame; +import static org.junit.Assert.assertTrue; + import java.math.BigDecimal; import java.util.List; -import org.junit.Test; - import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; import org.hibernate.criterion.Property; import org.hibernate.criterion.Restrictions; import org.hibernate.dialect.HSQLDialect; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertSame; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Gavin King */ +@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS") public class UnionSubclassTest extends BaseCoreFunctionalTestCase { protected String[] getMappings() { return new String[] { "unionsubclass2/Person.hbm.xml" }; diff --git a/hibernate-core/src/test/java/org/hibernate/test/version/VersionTest.java b/hibernate-core/src/test/java/org/hibernate/test/version/VersionTest.java index 82fb0aa866..b7c1d7f1a4 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/version/VersionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/version/VersionTest.java @@ -23,16 +23,16 @@ */ package org.hibernate.test.version; -import org.junit.Test; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; import org.hibernate.Hibernate; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import org.junit.Test; /** * @author Max Rydahl Andersen @@ -74,6 +74,7 @@ public class VersionTest extends BaseCoreFunctionalTestCase { } @Test + @FailureExpectedWithNewUnifiedXsd public void testCollectionVersion() { Session s = openSession(); Transaction t = s.beginTransaction(); diff --git a/hibernate-core/src/test/java/org/hibernate/test/version/db/DbVersionTest.java b/hibernate-core/src/test/java/org/hibernate/test/version/db/DbVersionTest.java index 98f320ac35..6afa736841 100644 --- a/hibernate-core/src/test/java/org/hibernate/test/version/db/DbVersionTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/version/db/DbVersionTest.java @@ -29,6 +29,7 @@ import org.junit.Test; import org.hibernate.Session; import org.hibernate.Transaction; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.type.StandardBasicTypes; @@ -38,6 +39,7 @@ import static org.junit.Assert.assertTrue; /** * @author Steve Ebersole */ +@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.") public class DbVersionTest extends BaseCoreFunctionalTestCase { @Override public String[] getMappings() { diff --git a/hibernate-core/src/test/java/org/hibernate/test/where/WhereTest.java b/hibernate-core/src/test/java/org/hibernate/test/where/WhereTest.java index 175b8ee12a..c1c8e29be3 100755 --- a/hibernate-core/src/test/java/org/hibernate/test/where/WhereTest.java +++ b/hibernate-core/src/test/java/org/hibernate/test/where/WhereTest.java @@ -28,6 +28,7 @@ import org.junit.Test; import org.hibernate.FetchMode; import org.hibernate.Session; import org.hibernate.criterion.Restrictions; +import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import static org.junit.Assert.assertEquals; @@ -35,6 +36,7 @@ import static org.junit.Assert.assertEquals; /** * @author Max Rydahl Andersen */ +@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines where at the class level, not collections.") public class WhereTest extends BaseCoreFunctionalTestCase { public String[] getMappings() { return new String[] { "where/File.hbm.xml" }; diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java index d4b1ed7cce..efa5cc4131 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/configuration/internal/RevisionInfoConfiguration.java @@ -26,6 +26,9 @@ package org.hibernate.envers.configuration.internal; import java.sql.Date; import java.util.Collection; +import org.dom4j.Document; +import org.dom4j.DocumentFactory; +import org.dom4j.Element; import org.hibernate.MappingException; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.envers.DefaultRevisionEntity; @@ -46,21 +49,17 @@ import org.hibernate.envers.internal.revisioninfo.RevisionInfoNumberReader; import org.hibernate.envers.internal.revisioninfo.RevisionInfoQueryCreator; import org.hibernate.envers.internal.tools.MutableBoolean; import org.hibernate.envers.internal.tools.Tools; -import org.hibernate.internal.util.xml.XMLHelper; import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames; import org.hibernate.metamodel.source.internal.annotations.util.JandexHelper; +import org.hibernate.metamodel.spi.AdditionalJaxbRootProducer.AdditionalJaxbRootProducerContext; import org.hibernate.metamodel.spi.InFlightMetadataCollector; -import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.AttributeBinding; +import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor; import org.hibernate.metamodel.spi.binding.SetBinding; import org.hibernate.type.IntegerType; import org.hibernate.type.LongType; import org.hibernate.type.Type; - -import org.dom4j.Document; -import org.dom4j.Element; - import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.ClassInfo; @@ -68,8 +67,6 @@ import org.jboss.jandex.FieldInfo; import org.jboss.jandex.IndexView; import org.jboss.jandex.MethodInfo; -import static org.hibernate.metamodel.spi.AdditionalJaxbRootProducer.AdditionalJaxbRootProducerContext; - /** * @author Adam Warski (adam at warski dot org) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) @@ -102,7 +99,7 @@ public class RevisionInfoConfiguration { } private Document generateDefaultRevisionInfoXmlMapping() { - final Document document = XMLHelper.getDocumentFactory().createDocument(); + final Document document = DocumentFactory.getInstance().createDocument(); final Element classMapping = MetadataTools.createEntity( document, @@ -185,7 +182,7 @@ public class RevisionInfoConfiguration { } private Element generateRevisionInfoRelationMapping() { - final Document document = XMLHelper.getDocumentFactory().createDocument(); + final Document document = DocumentFactory.getInstance().createDocument(); final Element revRelMapping = document.addElement( "key-many-to-one" ); // TODO: this does not belong here; does it belong somewhere else???? //revRelMapping.addAttribute( "type", revisionPropType ); diff --git a/hibernate-envers/src/main/java/org/hibernate/envers/event/spi/EnversJaxbRootProducer.java b/hibernate-envers/src/main/java/org/hibernate/envers/event/spi/EnversJaxbRootProducer.java index 1488af1908..33fc75d8c2 100644 --- a/hibernate-envers/src/main/java/org/hibernate/envers/event/spi/EnversJaxbRootProducer.java +++ b/hibernate-envers/src/main/java/org/hibernate/envers/event/spi/EnversJaxbRootProducer.java @@ -1,28 +1,12 @@ package org.hibernate.envers.event.spi; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.TransformerConfigurationException; -import javax.xml.transform.TransformerException; -import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; -import org.jboss.jandex.AnnotationInstance; -import org.jboss.jandex.ClassInfo; -import org.jboss.jandex.DotName; -import org.jboss.jandex.IndexView; -import org.jboss.logging.Logger; - -import org.hibernate.MappingException; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.envers.configuration.internal.AnnotationProxyBuilder; import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration; @@ -38,10 +22,14 @@ import org.hibernate.metamodel.spi.InFlightMetadataCollector; import org.hibernate.metamodel.spi.binding.EntityBinding; import org.hibernate.metamodel.spi.domain.Attribute; import org.hibernate.metamodel.spi.domain.AttributeContainer; -import org.hibernate.xml.internal.jaxb.MappingXmlBinder; import org.hibernate.xml.spi.BindResult; import org.hibernate.xml.spi.Origin; import org.hibernate.xml.spi.SourceType; +import org.jboss.jandex.AnnotationInstance; +import org.jboss.jandex.ClassInfo; +import org.jboss.jandex.DotName; +import org.jboss.jandex.IndexView; +import org.jboss.logging.Logger; /** * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) @@ -72,7 +60,6 @@ public class EnversJaxbRootProducer implements AdditionalJaxbRootProducer { private final InFlightMetadataCollector metadataCollector; private final AdditionalJaxbRootProducerContext additionalJaxbRootProducerContext; private final AnnotationProxyBuilder annotationProxyBuilder = new AnnotationProxyBuilder(); - private final MappingXmlBinder jaxbProcessor; private final List bindResults = new ArrayList(); private final Origin origin = new Origin( SourceType.DOM, Origin.UNKNOWN_FILE_PATH ); private final GlobalConfiguration globalCfg; @@ -88,9 +75,6 @@ public class EnversJaxbRootProducer implements AdditionalJaxbRootProducer { final RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration( globalCfg ); this.revInfoCfgResult = revInfoCfg.configure( metadataCollector, additionalJaxbRootProducerContext ); this.auditEntCfg = new AuditEntitiesConfiguration( additionalJaxbRootProducerContext.getServiceRegistry(), revInfoCfgResult.getRevisionInfoEntityName() ); - jaxbProcessor = new MappingXmlBinder( - additionalJaxbRootProducerContext.getServiceRegistry() - ); } @Override @@ -175,22 +159,7 @@ public class EnversJaxbRootProducer implements AdditionalJaxbRootProducer { @Override public void addDocument(org.w3c.dom.Document document) { - - ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); - Source xmlSource = new DOMSource( document ); - Result outputTarget = new StreamResult( outputStream ); - try { - TransformerFactory.newInstance().newTransformer().transform(xmlSource, outputTarget); - } - catch ( TransformerConfigurationException ex ){ - throw new MappingException( ex ); - } - catch ( TransformerException ex ) { - throw new MappingException( ex ); - } - InputStream is = new ByteArrayInputStream(outputStream.toByteArray()); - bindResults.add( jaxbProcessor.bind( is, origin ) ); - + // TODO } private List getBindResults() {