HHH-8893 HBM transform/mock

asdf
This commit is contained in:
Brett Meyer 2014-05-05 14:52:02 -04:00
parent 3e1d73cae8
commit 51d09c53cb
93 changed files with 1093 additions and 362 deletions

View File

@ -64,23 +64,9 @@ public class HibernateTypeSourceImpl implements HibernateTypeSource, JavaTypeDes
} }
public HibernateTypeSourceImpl(final PluralAttributeElementDetails element) { public HibernateTypeSourceImpl(final PluralAttributeElementDetails element) {
this.nameHolder = new ValueHolder<String>( this.name = element.getTypeResolver().getExplicitHibernateTypeName();
new ValueHolder.DeferredInitializer<String>() { this.parameters = element.getTypeResolver().getExplicitHibernateTypeParameters();
@Override this.javaTypeDescriptor = element.getJavaType();
public String initialize() {
return element.getTypeResolver().getExplicitHibernateTypeName();
}
}
);
this.parameterHolder = new ValueHolder<Map<String, String>>(
new ValueHolder.DeferredInitializer<Map<String, String>>() {
@Override
public Map<String, String> initialize() {
return element.getTypeResolver().getExplicitHibernateTypeParameters();
}
}
);
this.javaType = element.getJavaType();
} }
@Override @Override

View File

@ -43,6 +43,7 @@ import org.hibernate.annotations.DiscriminatorOptions;
import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.Fetch; import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;
import org.hibernate.annotations.FetchProfile; import org.hibernate.annotations.FetchProfile;
import org.hibernate.annotations.FetchProfiles; import org.hibernate.annotations.FetchProfiles;
import org.hibernate.annotations.Filter; import org.hibernate.annotations.Filter;
@ -138,6 +139,7 @@ public interface HibernateDotNames {
DotName DYNAMIC_INSERT = DotName.createSimple( DynamicInsert.class.getName() ); DotName DYNAMIC_INSERT = DotName.createSimple( DynamicInsert.class.getName() );
DotName DYNAMIC_UPDATE = DotName.createSimple( DynamicUpdate.class.getName() ); DotName DYNAMIC_UPDATE = DotName.createSimple( DynamicUpdate.class.getName() );
DotName FETCH = DotName.createSimple( Fetch.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_PROFILE = DotName.createSimple( FetchProfile.class.getName() );
DotName FETCH_PROFILES = DotName.createSimple( FetchProfiles.class.getName() ); DotName FETCH_PROFILES = DotName.createSimple( FetchProfiles.class.getName() );
DotName FETCH_OVERRIDE = DotName.createSimple( FetchProfile.FetchOverride.class.getName() ); DotName FETCH_OVERRIDE = DotName.createSimple( FetchProfile.FetchOverride.class.getName() );

View File

@ -25,13 +25,13 @@ package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import javax.persistence.AccessType; import javax.persistence.AccessType;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames; import org.hibernate.metamodel.source.internal.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIndex; import org.hibernate.metamodel.source.internal.jaxb.JaxbIndex;
import org.hibernate.metamodel.source.internal.jaxb.JaxbUniqueConstraint; import org.hibernate.metamodel.source.internal.jaxb.JaxbUniqueConstraint;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;

View File

@ -162,7 +162,15 @@ public abstract class AnnotationMocker extends AbstractMocker {
if ( column == null ) { if ( column == null ) {
return null; return null;
} }
// TODO: Not sure if this should be here...
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
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<AnnotationValue>();
MockHelper.stringValue( "name", column.getName(), annotationValueList ); MockHelper.stringValue( "name", column.getName(), annotationValueList );
MockHelper.stringValue( "columnDefinition", column.getColumnDefinition(), annotationValueList ); MockHelper.stringValue( "columnDefinition", column.getColumnDefinition(), annotationValueList );
MockHelper.stringValue( "table", column.getTable(), annotationValueList ); MockHelper.stringValue( "table", column.getTable(), annotationValueList );

View File

@ -59,6 +59,10 @@ public class AttributesBuilder extends AbstractAttributesBuilder {
@Override @Override
protected void parse() { protected void parse() {
if (getAttributesContainer() == null) {
return;
}
super.parse(); super.parse();
if ( attributes.getNaturalId() != null ) { if ( attributes.getNaturalId() != null ) {

View File

@ -84,6 +84,7 @@ public class ElementCollectionMocker extends PropertyMocker {
parseMapKey( elementCollection.getMapKey(), getTarget() ); parseMapKey( elementCollection.getMapKey(), getTarget() );
parseMapKeyColumn( elementCollection.getMapKeyColumn(), getTarget() ); parseMapKeyColumn( elementCollection.getMapKeyColumn(), getTarget() );
parseMapKeyClass( elementCollection.getMapKeyClass(), getTarget() ); parseMapKeyClass( elementCollection.getMapKeyClass(), getTarget() );
parseMapKeyType( elementCollection.getMapKeyType(), getTarget() );
parseMapKeyEnumerated( elementCollection.getMapKeyEnumerated(), getTarget() ); parseMapKeyEnumerated( elementCollection.getMapKeyEnumerated(), getTarget() );
parseMapKeyTemporal( elementCollection.getMapKeyTemporal(), getTarget() ); parseMapKeyTemporal( elementCollection.getMapKeyTemporal(), getTarget() );
} }

View File

@ -23,6 +23,7 @@
*/ */
package org.hibernate.metamodel.source.internal.jandex; package org.hibernate.metamodel.source.internal.jandex;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; 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.JaxbDiscriminatorColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners; 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.JaxbIdClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritance; import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritance;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad; import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad;
@ -103,7 +105,13 @@ public class EntityMocker extends AbstractEntityObjectMocker {
parseSecondaryTableList( entity.getSecondaryTable(), getTarget() ); parseSecondaryTableList( entity.getSecondaryTable(), getTarget() );
//@Cache //@Cache
parseCache( entity.getCache() ); parseCache( entity.getCache(), getTarget() );
// @Filters
parseFilters( entity.getFilter(), getTarget() );
// @BatchSize
parseBatchSize( entity.getBatchSize(), getTarget() );
} }
//@Table (entity only) //@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 ) { if ( cache == null ) {
return; return;
} }
@ -304,6 +312,51 @@ public class EntityMocker extends AbstractEntityObjectMocker {
MockHelper.stringValue( "include", cache.getInclude(), annotationValueList ); MockHelper.stringValue( "include", cache.getInclude(), annotationValueList );
MockHelper.enumValue( "usage", HibernateDotNames.CACHE_CONCURRENCY_STRATEGY, MockHelper.enumValue( "usage", HibernateDotNames.CACHE_CONCURRENCY_STRATEGY,
CacheConcurrencyStrategy.parse( cache.getUsage() ), annotationValueList ); CacheConcurrencyStrategy.parse( cache.getUsage() ), annotationValueList );
create( HibernateDotNames.CACHE, annotationValueList ); create( HibernateDotNames.CACHE, target, annotationValueList );
}
private void parseFilters(List<JaxbHbmFilter> filters, AnnotationTarget target) {
if (! filters.isEmpty() ) {
AnnotationValue[] filterAnnotations = new AnnotationValue[filters.size()];
int i = 0;
for ( JaxbHbmFilter filter : filters ) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
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<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.addToCollectionIfNotNull( annotationValueList,
AnnotationValue.createArrayValue( "value", filterAnnotations ) );
create( HibernateDotNames.FILTERS, target, annotationValueList );
}
}
private void parseBatchSize(Integer batchSize, AnnotationTarget target) {
if ( batchSize == null ) {
return;
}
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.integerValue( "size", batchSize, annotationValueList );
create( HibernateDotNames.BATCH_SIZE, target, annotationValueList );
} }
} }

View File

@ -27,8 +27,14 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.List; 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.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; 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.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryHint; 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.JaxbSqlResultSetMappingFieldResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator; import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;
/** /**
@ -73,6 +80,12 @@ public class GlobalAnnotationMocker extends AbstractMocker {
if ( !globalAnnotations.getSqlResultSetMappingMap().isEmpty() ) { if ( !globalAnnotations.getSqlResultSetMappingMap().isEmpty() ) {
parseSqlResultSetMappings( globalAnnotations.getSqlResultSetMappingMap().values() ); parseSqlResultSetMappings( globalAnnotations.getSqlResultSetMappingMap().values() );
} }
if ( !globalAnnotations.getFilterDefMap().isEmpty() ) {
parseFilterDefs( globalAnnotations.getFilterDefMap().values() );
}
if ( !globalAnnotations.getFetchProfileMap().isEmpty() ) {
parseFetchProfiles( globalAnnotations.getFetchProfileMap().values() );
}
indexBuilder.finishGlobalConfigurationMocking( globalAnnotations ); indexBuilder.finishGlobalConfigurationMocking( globalAnnotations );
} }
@ -310,6 +323,100 @@ public class GlobalAnnotationMocker extends AbstractMocker {
); );
} }
private void parseFilterDefs(Collection<JaxbHbmFilterDef> filterDefs) {
if (! filterDefs.isEmpty() ) {
AnnotationValue[] filterDefAnnotations = new AnnotationValue[filterDefs.size()];
int i = 0;
for ( JaxbHbmFilterDef filterDef : filterDefs ) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
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<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.addToCollectionIfNotNull( annotationValueList,
AnnotationValue.createArrayValue( "value", filterDefAnnotations ) );
create( HibernateDotNames.FILTER_DEFS, null, annotationValueList );
}
}
private void nestedFilterParams(List<JaxbFilterParam> filterParams, List<AnnotationValue> annotationValueList) {
if (! filterParams.isEmpty() ) {
AnnotationValue[] filterParamAnnotations = new AnnotationValue[filterParams.size()];
int i = 0;
for ( JaxbFilterParam filterParam : filterParams ) {
List<AnnotationValue> filterParamannotationValueList = new ArrayList<AnnotationValue>();
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<JaxbHbmFetchProfile> 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<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.addToCollectionIfNotNull( annotationValueList,
AnnotationValue.createArrayValue( "value", fetchProfileAnnotations ) );
create( HibernateDotNames.FETCH_PROFILES, null, annotationValueList );
}
}
private AnnotationInstance parseFetchProfile(JaxbHbmFetchProfile fetchProfile) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.stringValue( "name", fetchProfile.getName(), annotationValueList );
AnnotationValue[] fetchAnnotations = new AnnotationValue[fetchProfile.getFetch().size()];
int i = 0;
for ( JaxbFetch fetch : fetchProfile.getFetch() ) {
List<AnnotationValue> fetchAnnotationValueList = new ArrayList<AnnotationValue>();
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 @Override
protected AnnotationInstance push(AnnotationInstance annotationInstance) { protected AnnotationInstance push(AnnotationInstance annotationInstance) {
if ( annotationInstance != null ) { if ( annotationInstance != null ) {

View File

@ -35,10 +35,14 @@ import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger; import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper; 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.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes; import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity; import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings; 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.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; 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.JaxbTableGenerator;
import org.hibernate.metamodel.source.internal.jaxb.SchemaAware; import org.hibernate.metamodel.source.internal.jaxb.SchemaAware;
import org.hibernate.metamodel.source.spi.MappingException; import org.hibernate.metamodel.source.spi.MappingException;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName; import org.jboss.jandex.DotName;
@ -55,6 +58,7 @@ import org.jboss.jandex.DotName;
/** /**
* @author Strong Liu * @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 { public class GlobalAnnotations implements JPADotNames {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GlobalAnnotations.class ); private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GlobalAnnotations.class );
@ -65,6 +69,8 @@ public class GlobalAnnotations implements JPADotNames {
private final Map<String, JaxbSqlResultSetMapping> sqlResultSetMappingMap = new HashMap<String, JaxbSqlResultSetMapping>(); private final Map<String, JaxbSqlResultSetMapping> sqlResultSetMappingMap = new HashMap<String, JaxbSqlResultSetMapping>();
private final Map<DotName, List<AnnotationInstance>> annotationInstanceMap = new HashMap<DotName, List<AnnotationInstance>>(); private final Map<DotName, List<AnnotationInstance>> annotationInstanceMap = new HashMap<DotName, List<AnnotationInstance>>();
private final List<AnnotationInstance> indexedAnnotationInstanceList = new ArrayList<AnnotationInstance>(); private final List<AnnotationInstance> indexedAnnotationInstanceList = new ArrayList<AnnotationInstance>();
private final Map<String, JaxbHbmFilterDef> filterDefMap = new HashMap<String, JaxbHbmFilterDef>();
private final Map<String, JaxbHbmFetchProfile> fetchProfileMap = new HashMap<String, JaxbHbmFetchProfile>();
//--------------------------- //---------------------------
private final Set<String> defaultNamedNativeQueryNames = new HashSet<String>(); private final Set<String> defaultNamedNativeQueryNames = new HashSet<String>();
private final Set<String> defaultNamedQueryNames = new HashSet<String>(); private final Set<String> defaultNamedQueryNames = new HashSet<String>();
@ -103,7 +109,9 @@ public class GlobalAnnotations implements JPADotNames {
&& namedNativeQueryMap.isEmpty() && namedNativeQueryMap.isEmpty()
&& sequenceGeneratorMap.isEmpty() && sequenceGeneratorMap.isEmpty()
&& tableGeneratorMap.isEmpty() && tableGeneratorMap.isEmpty()
&& sqlResultSetMappingMap.isEmpty() ); && sqlResultSetMappingMap.isEmpty()
&& filterDefMap.isEmpty()
&& fetchProfileMap.isEmpty() );
} }
Map<String, JaxbNamedNativeQuery> getNamedNativeQueryMap() { Map<String, JaxbNamedNativeQuery> getNamedNativeQueryMap() {
@ -126,6 +134,14 @@ public class GlobalAnnotations implements JPADotNames {
return tableGeneratorMap; return tableGeneratorMap;
} }
Map<String, JaxbHbmFilterDef> getFilterDefMap() {
return filterDefMap;
}
Map<String, JaxbHbmFetchProfile> getFetchProfileMap() {
return fetchProfileMap;
}
public void filterIndexedAnnotations() { public void filterIndexedAnnotations() {
for ( AnnotationInstance annotationInstance : indexedAnnotationInstanceList ) { for ( AnnotationInstance annotationInstance : indexedAnnotationInstanceList ) {
@ -150,7 +166,9 @@ public class GlobalAnnotations implements JPADotNames {
( annName.equals( SEQUENCE_GENERATOR ) && !sequenceGeneratorMap.containsKey( name ) ) || ( annName.equals( SEQUENCE_GENERATOR ) && !sequenceGeneratorMap.containsKey( name ) ) ||
( annName.equals( NAMED_QUERY ) && !namedQueryMap.containsKey( name ) ) || ( annName.equals( NAMED_QUERY ) && !namedQueryMap.containsKey( name ) ) ||
( annName.equals( NAMED_NATIVE_QUERY ) && !namedNativeQueryMap.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 ) { if ( isNotExist ) {
@ -179,6 +197,14 @@ public class GlobalAnnotations implements JPADotNames {
put( sqlResultSetMapping ); put( sqlResultSetMapping );
defaultSqlResultSetMappingNames.add( sqlResultSetMapping.getName() ); 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) { 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 );
}
}
} }

View File

@ -62,6 +62,12 @@ public class ManyToManyMocker extends PropertyMocker {
MockHelper.stringValue( "hbmKey", manyToMany.getHbmKey(), annotationValueList ); MockHelper.stringValue( "hbmKey", manyToMany.getHbmKey(), annotationValueList );
create( HibernateDotNames.INVERSE, getTarget(), annotationValueList ); create( HibernateDotNames.INVERSE, getTarget(), annotationValueList );
} }
if (manyToMany.getHbmFetchMode() != null) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.enumValue( "value", HibernateDotNames.FETCH_MODE, manyToMany.getHbmFetchMode(),
annotationValueList );
create( HibernateDotNames.FETCH, getTarget(), annotationValueList );
}
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.classValue( "targetEntity", manyToMany.getTargetEntity(), annotationValueList, getDefaults(), MockHelper.classValue( "targetEntity", manyToMany.getTargetEntity(), annotationValueList, getDefaults(),
indexBuilder.getServiceRegistry() ); indexBuilder.getServiceRegistry() );

View File

@ -26,9 +26,10 @@ package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; 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.JaxbManyToOne;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute; import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue; import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
@ -51,12 +52,14 @@ public class ManyToOneMocker extends PropertyMocker {
@Override @Override
protected void doProcess() { protected void doProcess() {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.classValue( "targetEntity", manyToOne.getTargetEntity(), annotationValueList, getDefaults(), MockHelper.classValue( "targetEntity",
indexBuilder.getServiceRegistry() ); StringHelper.qualifyIfNot( getDefaults().getPackageName(), manyToOne.getTargetEntity() ),
annotationValueList, getDefaults(), indexBuilder.getServiceRegistry() );
MockHelper.enumValue( "fetch", FETCH_TYPE, manyToOne.getFetch(), annotationValueList ); MockHelper.enumValue( "fetch", FETCH_TYPE, manyToOne.getFetch(), annotationValueList );
MockHelper.booleanValue( "optional", manyToOne.isOptional(), annotationValueList ); MockHelper.booleanValue( "optional", manyToOne.isOptional(), annotationValueList );
MockHelper.cascadeValue( "cascade", manyToOne.getCascade(), isDefaultCascadePersist(), annotationValueList ); MockHelper.cascadeValue( "cascade", manyToOne.getCascade(), isDefaultCascadePersist(), annotationValueList );
create( MANY_TO_ONE, annotationValueList ); create( MANY_TO_ONE, annotationValueList );
parseJoinColumnList( manyToOne.getJoinColumn(), getTarget() ); parseJoinColumnList( manyToOne.getJoinColumn(), getTarget() );
parseJoinTable( manyToOne.getJoinTable(), getTarget() ); parseJoinTable( manyToOne.getJoinTable(), getTarget() );
if ( manyToOne.getMapsId() != null ) { if ( manyToOne.getMapsId() != null ) {
@ -65,5 +68,9 @@ public class ManyToOneMocker extends PropertyMocker {
if ( manyToOne.isId() != null && manyToOne.isId() ) { if ( manyToOne.isId() != null && manyToOne.isId() ) {
create( ID ); create( ID );
} }
annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.cascadeValue( "value", manyToOne.getHbmCascade(), annotationValueList );
create( HibernateDotNames.CASCADE, getTarget(), annotationValueList );
} }
} }

View File

@ -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.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbCacheModeType; import org.hibernate.metamodel.source.internal.jaxb.JaxbCacheModeType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbCascadeType; 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.metamodel.source.internal.jaxb.JaxbHbmCascadeType;
import org.hibernate.service.ServiceRegistry; import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.ArrayType;
import org.hibernate.type.BagType; import org.hibernate.type.BagType;
import org.hibernate.type.ListType; import org.hibernate.type.ListType;
import org.hibernate.type.MapType; import org.hibernate.type.MapType;
@ -232,6 +232,7 @@ public class MockHelper {
addIfNotNull( cascadeType.getCascadeSaveUpdate(), enumList , org.hibernate.annotations.CascadeType.SAVE_UPDATE ); addIfNotNull( cascadeType.getCascadeSaveUpdate(), enumList , org.hibernate.annotations.CascadeType.SAVE_UPDATE );
addIfNotNull( cascadeType.getCascadeReplicate(), enumList , org.hibernate.annotations.CascadeType.REPLICATE ); addIfNotNull( cascadeType.getCascadeReplicate(), enumList , org.hibernate.annotations.CascadeType.REPLICATE );
addIfNotNull( cascadeType.getCascadeLock(), enumList , org.hibernate.annotations.CascadeType.LOCK ); addIfNotNull( cascadeType.getCascadeLock(), enumList , org.hibernate.annotations.CascadeType.LOCK );
addIfNotNull( cascadeType.getCascadeDelete(), enumList , org.hibernate.annotations.CascadeType.DELETE );
} }
if ( !enumList.isEmpty() ) { if ( !enumList.isEmpty() ) {
MockHelper.enumArrayValue( name, JPADotNames.CASCADE_TYPE, enumList, annotationValueList ); MockHelper.enumArrayValue( name, JPADotNames.CASCADE_TYPE, enumList, annotationValueList );
@ -545,6 +546,9 @@ public class MockHelper {
if (collectionTypeName.equalsIgnoreCase( "map" )) { if (collectionTypeName.equalsIgnoreCase( "map" )) {
collectionTypeName = MapType.class.getName(); collectionTypeName = MapType.class.getName();
} }
if (collectionTypeName.equalsIgnoreCase( "array" )) {
collectionTypeName = ArrayType.class.getName();
}
return collectionTypeName; return collectionTypeName;
} }
} }

View File

@ -57,10 +57,16 @@ public class OneToManyMocker extends PropertyMocker {
MockHelper.stringValue( "type", collectionTypeName, annotationValueList ); MockHelper.stringValue( "type", collectionTypeName, annotationValueList );
create( HibernateDotNames.COLLECTION_TYPE, annotationValueList ); create( HibernateDotNames.COLLECTION_TYPE, annotationValueList );
} }
if (oneToMany.isInverse()) { if (oneToMany.isInverse() != null && oneToMany.isInverse()) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
create( HibernateDotNames.INVERSE, getTarget(), annotationValueList ); create( HibernateDotNames.INVERSE, getTarget(), annotationValueList );
} }
if (oneToMany.getHbmFetchMode() != null) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.enumValue( "value", HibernateDotNames.FETCH_MODE, oneToMany.getHbmFetchMode(),
annotationValueList );
create( HibernateDotNames.FETCH, getTarget(), annotationValueList );
}
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.classValue( "targetEntity", oneToMany.getTargetEntity(), annotationValueList, getDefaults(), MockHelper.classValue( "targetEntity", oneToMany.getTargetEntity(), annotationValueList, getDefaults(),
indexBuilder.getServiceRegistry() ); indexBuilder.getServiceRegistry() );
@ -80,6 +86,7 @@ public class OneToManyMocker extends PropertyMocker {
parseJoinColumnList( oneToMany.getJoinColumn(), getTarget() ); parseJoinColumnList( oneToMany.getJoinColumn(), getTarget() );
parseOrderColumn( oneToMany.getOrderColumn(), getTarget() ); parseOrderColumn( oneToMany.getOrderColumn(), getTarget() );
parseJoinTable( oneToMany.getJoinTable(), getTarget() ); parseJoinTable( oneToMany.getJoinTable(), getTarget() );
parseOnDelete( oneToMany.getOnDelete(), getTarget() );
if ( oneToMany.getOrderBy() != null ) { if ( oneToMany.getOrderBy() != null ) {
create( ORDER_BY, getTarget(), MockHelper.stringValueArray( "value", oneToMany.getOrderBy() ) ); create( ORDER_BY, getTarget(), MockHelper.stringValueArray( "value", oneToMany.getOrderBy() ) );
} }

View File

@ -31,6 +31,7 @@ import javax.persistence.EnumType;
import javax.persistence.TemporalType; import javax.persistence.TemporalType;
import org.hibernate.HibernateException; import org.hibernate.HibernateException;
import org.hibernate.annotations.OnDeleteAction;
import org.hibernate.internal.util.collections.CollectionHelper; import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames; import org.hibernate.metamodel.source.internal.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmType; 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.JaxbMapKeyClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyColumn; import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyJoinColumn; 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.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationTarget;
@ -264,8 +266,26 @@ public abstract class PropertyMocker extends AnnotationMocker {
//@Type //@Type
protected AnnotationInstance parseType(String name, AnnotationTarget target) { protected AnnotationInstance parseType(String name, AnnotationTarget target) {
List<AnnotationValue> typeAnnotationValueList = new ArrayList<AnnotationValue>(); List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.stringValue( "type", name, typeAnnotationValueList ); MockHelper.stringValue( "type", name, annotationValueList );
return create( HibernateDotNames.TYPE, target, typeAnnotationValueList ); return create( HibernateDotNames.TYPE, target, annotationValueList );
}
//@OnDelete
protected void parseOnDelete(JaxbOnDeleteType onDelete, AnnotationTarget target) {
if (onDelete != null) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
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 );
}
} }
} }

View File

@ -29,11 +29,19 @@ import javax.persistence.EnumType;
import javax.persistence.TemporalType; 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 * @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(); public JaxbMapKey getMapKey();

View File

@ -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);
}

View File

@ -23,6 +23,7 @@
*/ */
package org.hibernate.metamodel.source.internal.jaxb.hbm; package org.hibernate.metamodel.source.internal.jaxb.hbm;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -32,9 +33,12 @@ import javax.xml.bind.JAXBElement;
import org.hibernate.FlushMode; import org.hibernate.FlushMode;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.annotations.FetchMode;
import org.hibernate.internal.util.ReflectHelper; import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.StringHelper; import org.hibernate.internal.util.StringHelper;
import org.hibernate.mapping.Collection; 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.JaxbAny;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes; import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbBasic; 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.JaxbHbmCustomSql;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCustomSqlCheckEnum; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmCustomSqlCheckEnum;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile; 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.JaxbHbmFilterDef;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGenerator; import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGenerator;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGeneratorDef; 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.JaxbHbmTypeDef;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId; import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass; 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.JaxbJoinColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinTable; import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinTable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToMany; 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.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery; import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNaturalId; 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.JaxbOneToMany;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne; 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.JaxbPersistenceUnitMetadata;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrimaryKeyJoinColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryParamType; import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryParamType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingEntityResult; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingEntityResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingFieldResult; import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingFieldResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSynchronizeType; import org.hibernate.metamodel.source.internal.jaxb.JaxbSynchronizeType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTable; 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.source.internal.jaxb.hbm.JaxbReturnPropertyElement.JaxbReturnColumn;
import org.hibernate.metamodel.spi.ClassLoaderAccess; import org.hibernate.metamodel.spi.ClassLoaderAccess;
import org.hibernate.xml.spi.Origin; import org.hibernate.xml.spi.Origin;
@ -198,8 +208,12 @@ public class HbmXmlTransformer {
boolean foundCondition = false; boolean foundCondition = false;
for ( Object content : hbmFilterDef.getContent() ) { for ( Object content : hbmFilterDef.getContent() ) {
if ( String.class.isInstance( content ) ) { if ( String.class.isInstance( content ) ) {
String condition = (String) content;
condition = condition.trim();
if (! StringHelper.isEmpty( condition )) {
foundCondition = true; foundCondition = true;
filterDef.setCondition( (String) content ); filterDef.setCondition( condition );
}
} }
else { else {
JaxbFilterParamElement hbmFilterParam = ( (JAXBElement<JaxbFilterParamElement>) content ).getValue(); JaxbFilterParamElement hbmFilterParam = ( (JAXBElement<JaxbFilterParamElement>) content ).getValue();
@ -285,14 +299,13 @@ public class HbmXmlTransformer {
} }
for ( JaxbFetchProfileElement hbmFetchProfile : hbmXmlMapping.getFetchProfile() ) { for ( JaxbFetchProfileElement hbmFetchProfile : hbmXmlMapping.getFetchProfile() ) {
final JaxbHbmFetchProfile fetchProfile = new JaxbHbmFetchProfile(); ormRoot.getFetchProfile().add( transferFetchProfile( hbmFetchProfile ) );
ormRoot.getFetchProfile().add( fetchProfile );
fetchProfile.setName( hbmFetchProfile.getName() );
if ( hbmFetchProfile.getFetch().isEmpty() ) {
// really this should be an error, right?
continue;
} }
}
private JaxbHbmFetchProfile transferFetchProfile(JaxbFetchProfileElement hbmFetchProfile) {
final JaxbHbmFetchProfile fetchProfile = new JaxbHbmFetchProfile();
fetchProfile.setName( hbmFetchProfile.getName() );
for ( JaxbFetchProfileElement.JaxbFetch hbmFetch : hbmFetchProfile.getFetch() ) { for ( JaxbFetchProfileElement.JaxbFetch hbmFetch : hbmFetchProfile.getFetch() ) {
final JaxbHbmFetchProfile.JaxbFetch fetch = new JaxbHbmFetchProfile.JaxbFetch(); final JaxbHbmFetchProfile.JaxbFetch fetch = new JaxbHbmFetchProfile.JaxbFetch();
fetchProfile.getFetch().add( fetch ); fetchProfile.getFetch().add( fetch );
@ -300,7 +313,7 @@ public class HbmXmlTransformer {
fetch.setAssociation( hbmFetch.getAssociation() ); fetch.setAssociation( hbmFetch.getAssociation() );
fetch.setStyle( hbmFetch.getStyle().value() ); fetch.setStyle( hbmFetch.getStyle().value() );
} }
} return fetchProfile;
} }
private void transferNamedQuery(JaxbHibernateMapping hbmXmlMapping, JaxbEntityMappings ormRoot) { private void transferNamedQuery(JaxbHibernateMapping hbmXmlMapping, JaxbEntityMappings ormRoot) {
@ -329,7 +342,9 @@ public class HbmXmlTransformer {
// JaxbQueryElement#content elements can be either the query or parameters // JaxbQueryElement#content elements can be either the query or parameters
for ( Object content : hbmQuery.getContent() ) { for ( Object content : hbmQuery.getContent() ) {
if ( String.class.isInstance( content ) ) { if ( String.class.isInstance( content ) ) {
query.setQuery( (String) content ); String s = (String) content;
s = s.trim();
query.setQuery( s );
} }
else { else {
final JaxbQueryParamElement hbmQueryParam = (JaxbQueryParamElement) content; final JaxbQueryParamElement hbmQueryParam = (JaxbQueryParamElement) content;
@ -387,7 +402,9 @@ public class HbmXmlTransformer {
// JaxbQueryElement#content elements can be either the query or parameters // JaxbQueryElement#content elements can be either the query or parameters
for ( Object content : hbmQuery.getContent() ) { for ( Object content : hbmQuery.getContent() ) {
if ( String.class.isInstance( content ) ) { if ( String.class.isInstance( content ) ) {
query.setQuery( (String) content ); String s = (String) content;
s = s.trim();
query.setQuery( s );
} }
else if (content instanceof JAXBElement) { else if (content instanceof JAXBElement) {
final JAXBElement element = (JAXBElement) content; final JAXBElement element = (JAXBElement) content;
@ -465,15 +482,9 @@ public class HbmXmlTransformer {
} }
private void transferEntity(JaxbClassElement hbmClass, JaxbEntity entity) { private void transferEntity(JaxbClassElement hbmClass, JaxbEntity entity) {
entity.setMetadataComplete( true ); transferEntityElement( hbmClass, entity );
entity.setName( hbmClass.getEntityName() );
entity.setClazz( hbmClass.getName() );
entity.setAbstract( hbmClass.isAbstract() );
entity.setMutable( hbmClass.isMutable() );
entity.setLazy( hbmClass.isLazy() );
entity.setProxy( hbmClass.getProxy() );
entity.setBatchSize( hbmClass.getBatchSize() ); entity.setMutable( hbmClass.isMutable() );
entity.setTable( new JaxbTable() ); entity.setTable( new JaxbTable() );
entity.getTable().setCatalog( hbmClass.getCatalog() ); 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 ) { if ( hbmClass.getLoader() != null ) {
entity.setLoader( new JaxbHbmLoader() ); entity.setLoader( new JaxbHbmLoader() );
entity.getLoader().setQueryRef( hbmClass.getLoader().getQueryRef() ); entity.getLoader().setQueryRef( hbmClass.getLoader().getQueryRef() );
@ -519,7 +526,6 @@ public class HbmXmlTransformer {
entity.setRowid( hbmClass.getRowid() ); entity.setRowid( hbmClass.getRowid() );
entity.setWhere( hbmClass.getWhere() ); entity.setWhere( hbmClass.getWhere() );
entity.setPersister( hbmClass.getPersister() );
if ( !hbmClass.getTuplizer().isEmpty() ) { if ( !hbmClass.getTuplizer().isEmpty() ) {
if ( hbmClass.getTuplizer().size() > 1 ) { if ( hbmClass.getTuplizer().size() > 1 ) {
throw new MappingException( "HBM transformation: More than one entity-mode per entity not supported" ); 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() ); 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 <version/> elements :?
}
transferDiscriminator( entity, hbmClass ); transferDiscriminator( entity, hbmClass );
entity.setDiscriminatorValue( hbmClass.getDiscriminatorValue() ); entity.setDiscriminatorValue( hbmClass.getDiscriminatorValue() );
@ -576,10 +574,120 @@ public class HbmXmlTransformer {
} }
} }
// todo : transfer filters if (! hbmClass.getFilter().isEmpty()) {
// todo : transfer fetch-profiles 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 ); 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) { private JaxbHbmCustomSqlCheckEnum convert(JaxbCheckAttribute check) {
@ -637,9 +745,18 @@ public class HbmXmlTransformer {
} }
private void transferAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { private void transferAttributes(JaxbEntity entity, JaxbClassElement hbmClass) {
entity.setAttributes( new JaxbAttributes() ); transferEntityElementAttributes( entity, hbmClass );
transferIdentifier( 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 ); transferBasicAttributes( entity, hbmClass );
transferEmbeddedAttributes( entity, hbmClass ); transferEmbeddedAttributes( entity, hbmClass );
transferOneToOneAttributes( entity, hbmClass ); transferOneToOneAttributes( entity, hbmClass );
@ -648,8 +765,7 @@ public class HbmXmlTransformer {
transferManyToAnyAttributes( entity, hbmClass ); transferManyToAnyAttributes( entity, hbmClass );
transferPrimitiveArrayAttributes( entity, hbmClass ); transferPrimitiveArrayAttributes( entity, hbmClass );
transferPropertiesGrouping( entity, hbmClass ); transferPropertiesGrouping( entity, hbmClass );
transferNaturalIdentifiers( entity, hbmClass ); transferCollectionAttributes( entity, hbmClass );
transferPluralAttribute( entity, hbmClass );
} }
private void transferIdentifier(JaxbEntity entity, JaxbClassElement hbmClass) { private void transferIdentifier(JaxbEntity entity, JaxbClassElement hbmClass) {
@ -756,33 +872,7 @@ public class HbmXmlTransformer {
} }
else { else {
final JaxbKeyManyToOneElement keyManyToOne = (JaxbKeyManyToOneElement) hbmCompositeAttribute; final JaxbKeyManyToOneElement keyManyToOne = (JaxbKeyManyToOneElement) hbmCompositeAttribute;
final JaxbManyToOne manyToOne = new JaxbManyToOne(); final JaxbManyToOne manyToOne = transferManyToOneAttribute( keyManyToOne );
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 );
}
}
embeddable.getAttributes().getManyToOne().add( manyToOne ); 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() ) { for ( JaxbPropertyElement hbmProp : hbmClass.getProperty() ) {
entity.getAttributes().getBasic().add( transferBasicAttribute( hbmProp ) ); entity.getAttributes().getBasic().add( transferBasicAttribute( hbmProp ) );
} }
@ -850,6 +940,39 @@ public class HbmXmlTransformer {
entity.getAttributes().setNaturalId( naturalId ); 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 <version/> 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) { private JaxbBasic transferBasicAttribute(JaxbPropertyElement hbmProp) {
final JaxbBasic basic = new JaxbBasic(); final JaxbBasic basic = new JaxbBasic();
basic.setName( hbmProp.getName() ); basic.setName( hbmProp.getName() );
@ -880,28 +1003,33 @@ public class HbmXmlTransformer {
if ( StringHelper.isNotEmpty( hbmProp.getFormulaAttribute() ) ) { if ( StringHelper.isNotEmpty( hbmProp.getFormulaAttribute() ) ) {
basic.getColumnOrFormula().add( hbmProp.getFormulaAttribute() ); basic.getColumnOrFormula().add( hbmProp.getFormulaAttribute() );
} }
else if ( StringHelper.isNotEmpty( hbmProp.getColumnAttribute() ) ) { else if (! hbmProp.getColumn().isEmpty()) {
for ( JaxbColumnElement hbmColumn : hbmProp.getColumn() ) {
final JaxbColumn column = new JaxbColumn(); final JaxbColumn column = new JaxbColumn();
column.setName( hbmProp.getColumnAttribute() ); transferColumn( column, hbmColumn, null, hbmProp.isInsert(), hbmProp.isUpdate() );
basic.getColumnOrFormula().add( column ); basic.getColumnOrFormula().add( column );
} }
}
else if ( !hbmProp.getFormula().isEmpty() ) { else if ( !hbmProp.getFormula().isEmpty() ) {
for ( String formula : hbmProp.getFormula() ) { for ( String formula : hbmProp.getFormula() ) {
basic.getColumnOrFormula().add( formula ); basic.getColumnOrFormula().add( formula );
} }
} }
else { else {
for ( JaxbColumnElement hbmColumn : hbmProp.getColumn() ) {
final JaxbColumn column = new JaxbColumn(); final JaxbColumn column = new JaxbColumn();
transferColumn( column, hbmColumn, null, hbmProp.isInsert(), hbmProp.isUpdate() ); 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 ); basic.getColumnOrFormula().add( column );
} }
}
return basic; return basic;
} }
private void transferEmbeddedAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { private void transferEmbeddedAttributes(JaxbEntity entity, EntityElement hbmClass) {
for (JaxbComponentElement hbmComponent : hbmClass.getComponent()) { for (JaxbComponentElement hbmComponent : hbmClass.getComponent()) {
entity.getAttributes().getEmbedded().add( transferEmbeddedAttribute( hbmComponent ) ); entity.getAttributes().getEmbedded().add( transferEmbeddedAttribute( hbmComponent ) );
ormRoot.getEmbeddable().add( transferEmbeddable( entity, hbmComponent ) ); ormRoot.getEmbeddable().add( transferEmbeddable( entity, hbmComponent ) );
@ -941,18 +1069,21 @@ public class HbmXmlTransformer {
return embedded; return embedded;
} }
private void transferOneToOneAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { private void transferOneToOneAttributes(JaxbEntity entity, EntityElement hbmClass) {
for (JaxbOneToOneElement hbmO2O : hbmClass.getOneToOne()) { for (JaxbOneToOneElement hbmO2O : hbmClass.getOneToOne()) {
entity.getAttributes().getOneToOne().add( transferOneToOneAttribute( hbmO2O ) ); entity.getAttributes().getOneToOne().add( transferOneToOneAttribute( hbmO2O ) );
} }
} }
private JaxbOneToOne transferOneToOneAttribute(JaxbOneToOneElement 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(); final JaxbOneToOne o2o = new JaxbOneToOne();
o2o.setAttributeAccessor( hbmO2O.getAccess() ); o2o.setAttributeAccessor( hbmO2O.getAccess() );
o2o.setHbmCascade( convertCascadeType( hbmO2O.getCascade() ) ); o2o.setHbmCascade( convertCascadeType( hbmO2O.getCascade() ) );
o2o.setOrphanRemoval( isOrphanRemoval( hbmO2O.getCascade() ) ); o2o.setOrphanRemoval( isOrphanRemoval( hbmO2O.getCascade() ) );
o2o.setFetch( convert( hbmO2O.getFetch() ) );
o2o.setForeignKey( new JaxbForeignKey() ); o2o.setForeignKey( new JaxbForeignKey() );
o2o.getForeignKey().setName( hbmO2O.getForeignKey() ); o2o.getForeignKey().setName( hbmO2O.getForeignKey() );
if (! StringHelper.isEmpty( hbmO2O.getPropertyRef() )) { if (! StringHelper.isEmpty( hbmO2O.getPropertyRef() )) {
@ -967,23 +1098,39 @@ public class HbmXmlTransformer {
else { else {
o2o.setTargetEntity( hbmO2O.getClazz() ); o2o.setTargetEntity( hbmO2O.getClazz() );
} }
transferFetchable( hbmO2O.getLazy(), hbmO2O.getFetch(), hbmO2O.getOuterJoin(), hbmO2O.isConstrained(), o2o );
return o2o; return o2o;
} }
private void transferManyToOneAttributes(JaxbEntity entity, JaxbClassElement hbmClass) { private void transferManyToOneAttributes(JaxbEntity entity, EntityElement hbmClass) {
for (JaxbManyToOneElement hbmM2O : hbmClass.getManyToOne()) { for (JaxbManyToOneElement hbmM2O : hbmClass.getManyToOne()) {
entity.getAttributes().getManyToOne().add( transferManyToOneAttribute( hbmM2O ) ); entity.getAttributes().getManyToOne().add( transferManyToOneAttribute( hbmM2O ) );
} }
} }
private JaxbManyToOne transferManyToOneAttribute(JaxbManyToOneElement 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(); final JaxbManyToOne m2o = new JaxbManyToOne();
m2o.setAttributeAccessor( hbmM2O.getAccess() ); m2o.setAttributeAccessor( hbmM2O.getAccess() );
m2o.setHbmCascade( convertCascadeType( hbmM2O.getCascade() ) ); m2o.setHbmCascade( convertCascadeType( hbmM2O.getCascade() ) );
m2o.setFetch( convert( hbmM2O.getFetch() ) );
m2o.setForeignKey( new JaxbForeignKey() ); m2o.setForeignKey( new JaxbForeignKey() );
m2o.getForeignKey().setName( hbmM2O.getForeignKey() ); 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(); final JaxbJoinColumn joinColumn = new JaxbJoinColumn();
if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) { if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) {
// AbstractBasicBindingTests seems to imply this was the case // AbstractBasicBindingTests seems to imply this was the case
@ -997,17 +1144,10 @@ public class HbmXmlTransformer {
} }
joinColumn.setNullable( hbmM2O.isNotNull() == null ? null : !hbmM2O.isNotNull() ); joinColumn.setNullable( hbmM2O.isNotNull() == null ? null : !hbmM2O.isNotNull() );
joinColumn.setUnique( hbmM2O.isUnique() ); joinColumn.setUnique( hbmM2O.isUnique() );
joinColumn.setInsertable( hbmM2O.isInsert() );
joinColumn.setUpdatable( hbmM2O.isUpdate() );
m2o.getJoinColumn().add( joinColumn ); 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.setName( hbmM2O.getName() );
m2o.setOptional( hbmM2O.isNotNull() == null ? true : !hbmM2O.isNotNull() ); m2o.setOptional( hbmM2O.isNotNull() == null ? true : !hbmM2O.isNotNull() );
if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) { if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) {
@ -1016,6 +1156,7 @@ public class HbmXmlTransformer {
else { else {
m2o.setTargetEntity( hbmM2O.getClazz() ); m2o.setTargetEntity( hbmM2O.getClazz() );
} }
transferFetchable( hbmM2O.getLazy(), hbmM2O.getFetch(), hbmM2O.getOuterJoin(), null, m2o );
return m2o; return m2o;
} }
@ -1027,7 +1168,16 @@ public class HbmXmlTransformer {
m2o.setFetch( convert( hbmM2O.getLazy() ) ); m2o.setFetch( convert( hbmM2O.getLazy() ) );
m2o.setForeignKey( new JaxbForeignKey() ); m2o.setForeignKey( new JaxbForeignKey() );
m2o.getForeignKey().setName( hbmM2O.getForeignKey() ); 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(); final JaxbJoinColumn joinColumn = new JaxbJoinColumn();
if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) { if (StringHelper.isEmpty( hbmM2O.getColumnAttribute() )) {
// AbstractBasicBindingTests seems to imply this was the case // AbstractBasicBindingTests seems to imply this was the case
@ -1038,15 +1188,6 @@ public class HbmXmlTransformer {
} }
m2o.getJoinColumn().add( joinColumn ); 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.setName( hbmM2O.getName() );
if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) { if ( StringHelper.isNotEmpty( hbmM2O.getEntityName() ) ) {
m2o.setTargetEntity( hbmM2O.getEntityName() ); m2o.setTargetEntity( hbmM2O.getEntityName() );
@ -1054,10 +1195,13 @@ public class HbmXmlTransformer {
else { else {
m2o.setTargetEntity( hbmM2O.getClazz() ); m2o.setTargetEntity( hbmM2O.getClazz() );
} }
if (hbmM2O.getOnDelete() != null) {
m2o.setOnDelete( convert( hbmM2O.getOnDelete() ) );
}
return m2o; 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(); 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() ) { if ( !hbmClass.getPrimitiveArray().isEmpty() ) {
throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : " throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : "
+ hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used <primitive-array/> construct " + + hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used <primitive-array/> 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() ) { if ( !hbmClass.getProperties().isEmpty() ) {
throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : " throw new MappingException( "HBM transformation: Entity mapping [" + hbmClass.getName() + " : "
+ hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used <properties/> construct " + + hbmClass.getEntityName() + "] from hbm.xml [" + origin + "] used <properties/> construct " +
@ -1086,70 +1230,106 @@ public class HbmXmlTransformer {
} }
} }
private void transferDiscriminatorSubclass(JaxbSubclassElement hbmSubclass, JaxbEntity entity) { private void transferUnionSubclass(JaxbUnionSubclassElement hbmSubclass, JaxbEntity subclassEntity) {
// todo : implement 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 transferJoinedSubclass(JaxbJoinedSubclassElement hbmSubclass, JaxbEntity entity) { private void transferCollectionAttributes(JaxbEntity entity, EntityElement hbmClass) {
// todo : implement
}
private void transferUnionSubclass(JaxbUnionSubclassElement hbmSubclass, JaxbEntity entity) {
// todo : implement
}
private void transferPluralAttribute(JaxbEntity entity, JaxbClassElement hbmClass) {
for (JaxbSetElement hbmSet : hbmClass.getSet()) { for (JaxbSetElement hbmSet : hbmClass.getSet()) {
transferPluralAttribute( entity, hbmSet, "set" ); transferCollectionAttribute( entity, hbmSet, "set", hbmSet.getOrderBy() );
} }
for (JaxbBagElement hbmBag : hbmClass.getBag()) { for (JaxbBagElement hbmBag : hbmClass.getBag()) {
transferPluralAttribute( entity, hbmBag, "bag" ); transferCollectionAttribute( entity, hbmBag, "bag", hbmBag.getOrderBy() );
} }
for (JaxbListElement hbmList : hbmClass.getList()) { 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()) { 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, private CollectionAttribute transferCollectionAttribute(JaxbEntity entity, PluralAttributeElement pluralAttribute,
String collectionTypeName) { String collectionTypeName, String orderBy) {
if (pluralAttribute.getElement() != null) { if (pluralAttribute.getBatchSize() > 0) {
entity.getAttributes().getElementCollection().add( transferElementCollection( // TODO: New schema only defines batch-size at the class level, not collections.
pluralAttribute.getName(), collectionTypeName, pluralAttribute.getElement() ) ); throw new MappingException( "HBM transformation: 'batch-size' not yet supported." );
}
if (pluralAttribute.getOneToMany() != null) {
entity.getAttributes().getOneToMany().add( transferOneToManyAttribute(
pluralAttribute, collectionTypeName ) );
}
if (pluralAttribute.getManyToMany() != null) {
entity.getAttributes().getManyToMany().add( transferManyToManyAttribute(
pluralAttribute, collectionTypeName ) );
} }
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." );
} }
private void transferMapAttribute(JaxbEntity entity, JaxbMapElement pluralAttribute) { CollectionAttribute collection = null;
if (pluralAttribute.getElement() != null) { if (pluralAttribute.getElement() != null) {
entity.getAttributes().getElementCollection().add( transferElementCollection( final JaxbElementCollection elementCollection = transferElementCollection(
pluralAttribute.getName(), "map", pluralAttribute.getElement() ) ); pluralAttribute, collectionTypeName, orderBy );
entity.getAttributes().getElementCollection().add( elementCollection );
collection = elementCollection;
} }
if (pluralAttribute.getOneToMany() != null) { else if (pluralAttribute.getOneToMany() != null) {
final JaxbOneToMany o2m = transferOneToManyAttribute( pluralAttribute, "map" ); final JaxbOneToMany o2m = transferOneToManyAttribute( pluralAttribute, collectionTypeName, orderBy );
transferMapKey( o2m, pluralAttribute );
entity.getAttributes().getOneToMany().add( o2m ); entity.getAttributes().getOneToMany().add( o2m );
collection = o2m;
} }
if (pluralAttribute.getManyToMany() != null) { else if (pluralAttribute.getManyToMany() != null) {
final JaxbManyToMany m2m = transferManyToManyAttribute( pluralAttribute, "map" ); final JaxbManyToMany m2m = transferManyToManyAttribute( pluralAttribute, collectionTypeName );
transferMapKey( m2m, pluralAttribute );
entity.getAttributes().getManyToMany().add( m2m ); 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." );
} }
} }
private void transferMapKey(MapAttribute map, JaxbMapElement pluralAttribute) { 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(CollectionAttribute map, JaxbMapElement pluralAttribute) {
if (pluralAttribute.getIndex() != null) { if (pluralAttribute.getIndex() != null) {
final JaxbMapKeyColumn mapKey = new JaxbMapKeyColumn(); final JaxbMapKeyColumn mapKey = new JaxbMapKeyColumn();
// TODO: multiple columns? // TODO: multiple columns?
@ -1163,7 +1343,7 @@ public class HbmXmlTransformer {
} }
if (pluralAttribute.getMapKey() != null) { if (pluralAttribute.getMapKey() != null) {
if (! StringHelper.isEmpty( pluralAttribute.getMapKey().getFormulaAttribute() )) { 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(); final JaxbMapKeyColumn mapKey = new JaxbMapKeyColumn();
// TODO: multiple columns? // TODO: multiple columns?
@ -1178,10 +1358,11 @@ public class HbmXmlTransformer {
} }
} }
private JaxbElementCollection transferElementCollection(String propertyName, String collectionTypeName, private JaxbElementCollection transferElementCollection(
JaxbElementElement hbmElement) { PluralAttributeElement pluralAttribute, String collectionTypeName, String orderBy) {
final JaxbElementElement hbmElement = pluralAttribute.getElement();
final JaxbElementCollection element = new JaxbElementCollection(); final JaxbElementCollection element = new JaxbElementCollection();
element.setName( propertyName ); element.setName( pluralAttribute.getName() );
final JaxbColumn column = new JaxbColumn(); final JaxbColumn column = new JaxbColumn();
column.setName( hbmElement.getColumnAttribute() ); column.setName( hbmElement.getColumnAttribute() );
element.setColumn( column ); element.setColumn( column );
@ -1191,10 +1372,13 @@ public class HbmXmlTransformer {
final JaxbHbmType collectionType = new JaxbHbmType(); final JaxbHbmType collectionType = new JaxbHbmType();
collectionType.setName( collectionTypeName ); collectionType.setName( collectionTypeName );
element.setCollectionType( collectionType ); element.setCollectionType( collectionType );
element.setOrderBy( orderBy );
transferFetchable( pluralAttribute.getLazy(), pluralAttribute.getFetch(), pluralAttribute.getOuterJoin(), element );
return 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 JaxbOneToManyElement hbmO2M = pluralAttribute.getOneToMany();
final JaxbOneToMany o2m = new JaxbOneToMany(); final JaxbOneToMany o2m = new JaxbOneToMany();
final JaxbHbmType collectionType = new JaxbHbmType(); final JaxbHbmType collectionType = new JaxbHbmType();
@ -1203,21 +1387,13 @@ public class HbmXmlTransformer {
o2m.setAttributeAccessor( pluralAttribute.getAccess() ); o2m.setAttributeAccessor( pluralAttribute.getAccess() );
o2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) ); o2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) );
o2m.setOrphanRemoval( isOrphanRemoval( 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.setName( pluralAttribute.getName() );
o2m.setTargetEntity( hbmO2M.getClazz() ); o2m.setTargetEntity( hbmO2M.getClazz() );
o2m.setInverse( pluralAttribute.isInverse() ); o2m.setInverse( pluralAttribute.isInverse() );
if (pluralAttribute.getKey() != null) { if (pluralAttribute.getKey() != null) {
final JaxbKeyElement hbmKey = pluralAttribute.getKey(); final JaxbKeyElement hbmKey = pluralAttribute.getKey();
if (hbmKey.getColumn().isEmpty()) { 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 {
for ( JaxbColumnElement hbmColumn : hbmKey.getColumn() ) { for ( JaxbColumnElement hbmColumn : hbmKey.getColumn() ) {
final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); final JaxbJoinColumn joinColumn = new JaxbJoinColumn();
joinColumn.setName( hbmColumn.getName() ); joinColumn.setName( hbmColumn.getName() );
@ -1226,20 +1402,43 @@ public class HbmXmlTransformer {
o2m.getJoinColumn().add( joinColumn ); 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; return o2m;
} }
private JaxbManyToMany transferManyToManyAttribute(PluralAttributeElement pluralAttribute, private JaxbManyToMany transferManyToManyAttribute(PluralAttributeElement pluralAttribute,
String collectionTypeName) { String collectionTypeName) {
final JaxbManyToManyElement hbmM2M = pluralAttribute.getManyToMany(); 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 JaxbManyToMany m2m = new JaxbManyToMany();
final JaxbHbmType collectionType = new JaxbHbmType(); final JaxbHbmType collectionType = new JaxbHbmType();
collectionType.setName( collectionTypeName ); collectionType.setName( collectionTypeName );
m2m.setCollectionType( collectionType ); m2m.setCollectionType( collectionType );
m2m.setAttributeAccessor( pluralAttribute.getAccess() ); m2m.setAttributeAccessor( pluralAttribute.getAccess() );
m2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) ); m2m.setHbmCascade( convertCascadeType( pluralAttribute.getCascade() ) );
m2m.setFetch( convert( pluralAttribute.getFetch() ) ); transferFetchable( pluralAttribute.getLazy(), pluralAttribute.getFetch(), pluralAttribute.getOuterJoin(), m2m );
m2m.setName( pluralAttribute.getName() ); m2m.setName( pluralAttribute.getName() );
m2m.setTargetEntity( hbmM2M.getClazz() ); m2m.setTargetEntity( hbmM2M.getClazz() );
m2m.setOrderBy( hbmM2M.getOrderBy() ); m2m.setOrderBy( hbmM2M.getOrderBy() );
@ -1259,10 +1458,8 @@ public class HbmXmlTransformer {
} }
} }
else { else {
// TODO: handle other JaxbKeyElement props
final JaxbJoinColumn joinColumn = new JaxbJoinColumn(); final JaxbJoinColumn joinColumn = new JaxbJoinColumn();
joinColumn.setName( columnName ); joinColumn.setName( columnName );
// TODO: Handle other JaxbJoinColumn props
final JaxbJoinColumn inverseJoinColumn = new JaxbJoinColumn(); final JaxbJoinColumn inverseJoinColumn = new JaxbJoinColumn();
if (StringHelper.isEmpty( hbmM2M.getColumnAttribute() )) { if (StringHelper.isEmpty( hbmM2M.getColumnAttribute() )) {
inverseJoinColumn.setName( Collection.DEFAULT_ELEMENT_COLUMN_NAME ); inverseJoinColumn.setName( Collection.DEFAULT_ELEMENT_COLUMN_NAME );
@ -1315,6 +1512,9 @@ public class HbmXmlTransformer {
if (hbmCascade.contains( "lock" )) { if (hbmCascade.contains( "lock" )) {
cascadeType.setCascadeLock( new JaxbEmptyType() ); cascadeType.setCascadeLock( new JaxbEmptyType() );
} }
if (hbmCascade.contains( "delete" )) {
cascadeType.setCascadeDelete( new JaxbEmptyType() );
}
} }
} }
return cascadeType; return cascadeType;
@ -1328,43 +1528,119 @@ public class HbmXmlTransformer {
return false; return false;
} }
private FetchType convert(JaxbFetchStyleAttribute hbmFetch) { // ToOne
if (hbmFetch != null) { private void transferFetchable(JaxbLazyAttributeWithNoProxy hbmLazy, JaxbFetchStyleAttribute hbmFetch,
switch (hbmFetch) { JaxbOuterJoinAttribute hbmOuterJoin, Boolean constrained, FetchableAttribute fetchable) {
case JOIN: FetchType laziness = FetchType.LAZY;
return FetchType.EAGER; FetchMode fetch = FetchMode.SELECT;
case SELECT:
return FetchType.LAZY; 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) { // allow fetch style to override laziness, if necessary
if (hbmFetch != null) { if (constrained != null && ! constrained) {
switch (hbmFetch) { // NOTE SPECIAL CASE: one-to-one constrained=false cannot be proxied, so default to join and non-lazy
case JOIN: laziness = FetchType.EAGER;
return FetchType.EAGER; fetch = FetchMode.JOIN;
case SELECT: }
return FetchType.LAZY; 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) { private FetchType convert(JaxbLazyAttribute hbmLazy) {
// TODO: no-proxy? // TODO: no-proxy?
if ( hbmLazy != null && "proxy".equalsIgnoreCase( hbmLazy.value() ) ) { if ( hbmLazy != null || "proxy".equalsIgnoreCase( hbmLazy.value() ) ) {
return FetchType.LAZY; return FetchType.LAZY;
} }
else if ( hbmLazy != null && "false".equalsIgnoreCase( hbmLazy.value() ) ) { else if ( hbmLazy != null && "false".equalsIgnoreCase( hbmLazy.value() ) ) {
return FetchType.EAGER; return FetchType.EAGER;
} }
else { 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) { private String getFqClassName(String className) {
final String defaultPackageName = ormRoot.getPackage(); final String defaultPackageName = ormRoot.getPackage();
if ( StringHelper.isNotEmpty( className ) && className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) { if ( StringHelper.isNotEmpty( className ) && className.indexOf( '.' ) < 0 && StringHelper.isNotEmpty( defaultPackageName ) ) {

View File

@ -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();
}
}

View File

@ -499,6 +499,20 @@
</xsd:sequence> </xsd:sequence>
</xsd:complexType> </xsd:complexType>
<!-- **************************************************** -->
<xsd:simpleType name="on-delete-type">
<xsd:annotation>
<xsd:documentation>
org.hibernate.annotations.OnDeleteAction enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="NO_ACTION"/>
<xsd:enumeration value="CASCADE"/>
</xsd:restriction>
</xsd:simpleType>
<!-- **************************************************** --> <!-- **************************************************** -->
@ -702,6 +716,7 @@
<xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="target-class" type="xsd:string"/> <xsd:attribute name="target-class" type="xsd:string"/>
<xsd:attribute name="fetch" type="orm:fetch-type"/> <xsd:attribute name="fetch" type="orm:fetch-type"/>
<xsd:attribute name="hbm-fetch-mode" type="orm:hbm-fetch-mode"/>
<xsd:attribute name="access" type="orm:access-type"/> <xsd:attribute name="access" type="orm:access-type"/>
<xsd:attribute name="attribute-accessor" type="xsd:string" /> <xsd:attribute name="attribute-accessor" type="xsd:string" />
</xsd:complexType> </xsd:complexType>
@ -1024,6 +1039,22 @@
</xsd:simpleType> </xsd:simpleType>
<!-- **************************************************** -->
<xsd:simpleType name="hbm-fetch-mode">
<xsd:annotation>
<xsd:documentation>
org.hibernate.annotations.FetchMode enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
<xsd:enumeration value="SELECT"/>
<xsd:enumeration value="JOIN"/>
<xsd:enumeration value="SUBSELECT"/>
</xsd:restriction>
</xsd:simpleType>
<!-- **************************************************** --> <!-- **************************************************** -->
<xsd:simpleType name="flush-mode-type"> <xsd:simpleType name="flush-mode-type">
@ -1357,11 +1388,13 @@
<xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="target-entity" type="xsd:string"/> <xsd:attribute name="target-entity" type="xsd:string"/>
<xsd:attribute name="fetch" type="orm:fetch-type"/> <xsd:attribute name="fetch" type="orm:fetch-type"/>
<xsd:attribute name="hbm-fetch-mode" type="orm:hbm-fetch-mode"/>
<xsd:attribute name="access" type="orm:access-type"/> <xsd:attribute name="access" type="orm:access-type"/>
<xsd:attribute name="attribute-accessor" type="xsd:string" /> <xsd:attribute name="attribute-accessor" type="xsd:string" />
<xsd:attribute name="mapped-by" type="xsd:string"/> <xsd:attribute name="mapped-by" type="xsd:string"/>
<xsd:attribute name="inverse" type="xsd:boolean"/> <!-- DEPRECATED --> <xsd:attribute name="inverse" type="xsd:boolean"/> <!-- DEPRECATED -->
<xsd:attribute name="hbmKey" type="xsd:string"/> <!-- DEPRECATED (needed to carry the inverse side's <key> --> <xsd:attribute name="hbm-key" type="xsd:string"/> <!-- DEPRECATED (needed to carry the inverse side's <key> -->
<xsd:attribute name="orphan-removal" type="xsd:boolean"/>
</xsd:complexType> </xsd:complexType>
@ -1386,11 +1419,13 @@
</xsd:choice> </xsd:choice>
<xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/> <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
<xsd:element name="hbm-cascade" type="orm:hbm-cascade-type" minOccurs="0"/> <xsd:element name="hbm-cascade" type="orm:hbm-cascade-type" minOccurs="0"/>
<xsd:element name="on-delete" type="orm:on-delete-type" minOccurs="0"/>
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="target-entity" type="xsd:string"/> <xsd:attribute name="target-entity" type="xsd:string"/>
<xsd:attribute name="fetch" type="orm:fetch-type"/> <xsd:attribute name="fetch" type="orm:fetch-type"/>
<xsd:attribute name="hbm-fetch-mode" type="orm:hbm-fetch-mode"/>
<xsd:attribute name="optional" type="xsd:boolean"/> <xsd:attribute name="optional" type="xsd:boolean"/>
<xsd:attribute name="access" type="orm:access-type"/> <xsd:attribute name="access" type="orm:access-type"/>
<xsd:attribute name="attribute-accessor" type="xsd:string" /> <xsd:attribute name="attribute-accessor" type="xsd:string" />
@ -1736,12 +1771,14 @@
</xsd:choice> </xsd:choice>
<xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/> <xsd:element name="cascade" type="orm:cascade-type" minOccurs="0"/>
<xsd:element name="hbm-cascade" type="orm:hbm-cascade-type" minOccurs="0"/> <xsd:element name="hbm-cascade" type="orm:hbm-cascade-type" minOccurs="0"/>
<xsd:element name="on-delete" type="orm:on-delete-type" minOccurs="0"/>
<xsd:element name="collection-type" minOccurs="0" type="orm:hbm-type"/> <xsd:element name="collection-type" minOccurs="0" type="orm:hbm-type"/>
</xsd:sequence> </xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="target-entity" type="xsd:string"/> <xsd:attribute name="target-entity" type="xsd:string"/>
<xsd:attribute name="fetch" type="orm:fetch-type"/> <xsd:attribute name="fetch" type="orm:fetch-type"/>
<xsd:attribute name="hbm-fetch-mode" type="orm:hbm-fetch-mode"/>
<xsd:attribute name="access" type="orm:access-type"/> <xsd:attribute name="access" type="orm:access-type"/>
<xsd:attribute name="attribute-accessor" type="xsd:string" /> <xsd:attribute name="attribute-accessor" type="xsd:string" />
<xsd:attribute name="mapped-by" type="xsd:string"/> <xsd:attribute name="mapped-by" type="xsd:string"/>
@ -1778,6 +1815,7 @@
<xsd:attribute name="name" type="xsd:string" use="required"/> <xsd:attribute name="name" type="xsd:string" use="required"/>
<xsd:attribute name="target-entity" type="xsd:string"/> <xsd:attribute name="target-entity" type="xsd:string"/>
<xsd:attribute name="fetch" type="orm:fetch-type"/> <xsd:attribute name="fetch" type="orm:fetch-type"/>
<xsd:attribute name="hbm-fetch-mode" type="orm:hbm-fetch-mode"/>
<xsd:attribute name="optional" type="xsd:boolean"/> <xsd:attribute name="optional" type="xsd:boolean"/>
<xsd:attribute name="access" type="orm:access-type"/> <xsd:attribute name="access" type="orm:access-type"/>
<xsd:attribute name="attribute-accessor" type="xsd:string" /> <xsd:attribute name="attribute-accessor" type="xsd:string" />
@ -2333,6 +2371,7 @@
<xsd:attribute name="name" use="required" type="xsd:string"/> <xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="autoAliasInjection" type="xsd:boolean"/> <xsd:attribute name="autoAliasInjection" type="xsd:boolean"/>
<xsd:attribute name="conditionAttribute" type="xsd:string"/>
</xsd:complexType> </xsd:complexType>

View File

@ -41,6 +41,12 @@
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchTypeMarshalling.toXml" /> printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchTypeMarshalling.toXml" />
</bindings> </bindings>
<bindings node="//xsd:simpleType[@name='hbm-fetch-mode']">
<javaType name="org.hibernate.annotations.FetchMode"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchModeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchModeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='flush-mode-type']"> <bindings node="//xsd:simpleType[@name='flush-mode-type']">
<javaType name="org.hibernate.FlushMode" <javaType name="org.hibernate.FlushMode"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FlushModeMarshalling.fromXml" parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FlushModeMarshalling.fromXml"
@ -148,13 +154,15 @@
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='many-to-one']"> <bindings node="//xsd:complexType[@name='many-to-one']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.FetchableAttribute</inheritance:implements>
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='one-to-many']"> <bindings node="//xsd:complexType[@name='one-to-many']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.MapAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute</inheritance:implements>
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='one-to-one']"> <bindings node="//xsd:complexType[@name='one-to-one']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.FetchableAttribute</inheritance:implements>
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='embedded-id']"> <bindings node="//xsd:complexType[@name='embedded-id']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
@ -164,11 +172,11 @@
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='many-to-many']"> <bindings node="//xsd:complexType[@name='many-to-many']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.MapAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute</inheritance:implements>
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='element-collection']"> <bindings node="//xsd:complexType[@name='element-collection']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.MapAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.CollectionAttribute</inheritance:implements>
</bindings> </bindings>
<bindings node="//xsd:complexType[@name='any']"> <bindings node="//xsd:complexType[@name='any']">
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements> <inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>

View File

@ -32,6 +32,7 @@ import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl; import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.metamodel.spi.relational.Column; import org.hibernate.metamodel.spi.relational.Column;
import org.hibernate.metamodel.spi.relational.Identifier; import org.hibernate.metamodel.spi.relational.Identifier;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.After; import org.junit.After;
@ -41,6 +42,7 @@ import org.junit.Test;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema")
public class UnidirectionalManyToManyBindingTests extends BaseUnitTestCase { public class UnidirectionalManyToManyBindingTests extends BaseUnitTestCase {
private StandardServiceRegistryImpl serviceRegistry; private StandardServiceRegistryImpl serviceRegistry;

View File

@ -27,6 +27,7 @@ import org.junit.Test;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.internal.MetadataImpl; import org.hibernate.metamodel.internal.MetadataImpl;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -35,6 +36,7 @@ import static org.junit.Assert.assertEquals;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class UnsavedValueHbmTests extends AbstractUnsavedValueTests { public class UnsavedValueHbmTests extends AbstractUnsavedValueTests {
@Test @Test

View File

@ -24,10 +24,12 @@
package org.hibernate.metamodel.spi.binding.basiccollections; package org.hibernate.metamodel.spi.binding.basiccollections;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "extra lazy")
public class HbmBasicCollectionBindingTests extends AbstractBasicCollectionBindingTests { public class HbmBasicCollectionBindingTests extends AbstractBasicCollectionBindingTests {
public void addSources(MetadataSources sources) { public void addSources(MetadataSources sources) {
sources.addResource( "org/hibernate/metamodel/spi/binding/basiccollections/EntityWithBasicCollections.hbm.xml" ); sources.addResource( "org/hibernate/metamodel/spi/binding/basiccollections/EntityWithBasicCollections.hbm.xml" );

View File

@ -24,10 +24,12 @@
package org.hibernate.metamodel.spi.binding.onetomany; package org.hibernate.metamodel.spi.binding.onetomany;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema")
public class HbmUnidirectionalOneToManyBindingTests extends AbstractUnidirectionalOneToManyBindingTests { public class HbmUnidirectionalOneToManyBindingTests extends AbstractUnidirectionalOneToManyBindingTests {
@Override @Override
public void addSources(MetadataSources sources) { public void addSources(MetadataSources sources) {

View File

@ -27,6 +27,7 @@ import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources; import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.source.spi.InvalidMappingException; import org.hibernate.metamodel.source.spi.InvalidMappingException;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -34,6 +35,7 @@ import org.junit.Test;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@TestForIssue(jiraKey = "HHH-6271") @TestForIssue(jiraKey = "HHH-6271")
@FailureExpectedWithNewUnifiedXsd
public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase { public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testNonExistentOrmVersion() { public void testNonExistentOrmVersion() {

View File

@ -23,17 +23,18 @@
*/ */
package org.hibernate.test.annotations.xml.hbm; package org.hibernate.test.annotations.xml.hbm;
import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class) @RequiresDialectFeature(DialectChecks.SupportsIdentityColumns.class)
@FailureExpectedWithNewUnifiedXsd(message = "proxy attributes")
public class HbmWithIdentityTest extends BaseCoreFunctionalTestCase { public class HbmWithIdentityTest extends BaseCoreFunctionalTestCase {
@Test @Test
public void testManyToOneAndInterface() throws Exception { public void testManyToOneAndInterface() throws Exception {

View File

@ -35,6 +35,7 @@ import org.hibernate.cfg.AvailableSettings;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.loader.BatchFetchStyle; import org.hibernate.loader.BatchFetchStyle;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -44,6 +45,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.")
public class BatchFetchTest extends BaseCoreFunctionalTestCase { public class BatchFetchTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -40,12 +40,14 @@ import org.hibernate.Transaction;
import org.hibernate.engine.query.spi.HQLQueryPlan; import org.hibernate.engine.query.spi.HQLQueryPlan;
import org.hibernate.exception.SQLGrammarException; import org.hibernate.exception.SQLGrammarException;
import org.hibernate.hql.spi.QueryTranslator; import org.hibernate.hql.spi.QueryTranslator;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "MultipleBagFetchException")
public class CompositeIdTest extends BaseCoreFunctionalTestCase { public class CompositeIdTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -22,12 +22,13 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.component.basic; 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.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -43,17 +44,17 @@ import org.hibernate.mapping.Component;
import org.hibernate.mapping.Formula; import org.hibernate.mapping.Formula;
import org.hibernate.mapping.PersistentClass; import org.hibernate.mapping.PersistentClass;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialect; import org.hibernate.testing.RequiresDialect;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class ComponentTest extends BaseCoreFunctionalTestCase { public class ComponentTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {
@ -172,6 +173,7 @@ public class ComponentTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewUnifiedXsd
public void testComponentQueries() { public void testComponentQueries() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -22,9 +22,12 @@
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
package org.hibernate.test.fetchprofiles.join; 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.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
@ -32,18 +35,16 @@ import org.hibernate.UnknownProfileException;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
/** /**
* Various tests related to join-style fetch profiles. * Various tests related to join-style fetch profiles.
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "appears using component.field as the association path is failing")
public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase { public class JoinFetchProfileTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "fetchprofiles/join/Mappings.hbm.xml" }; return new String[] { "fetchprofiles/join/Mappings.hbm.xml" };

View File

@ -49,11 +49,10 @@ import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.persister.collection.CollectionPersister; import org.hibernate.persister.collection.CollectionPersister;
import org.hibernate.transform.DistinctRootEntityResultTransformer; import org.hibernate.transform.DistinctRootEntityResultTransformer;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
import org.jboss.logging.Logger; import org.jboss.logging.Logger;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -66,6 +65,7 @@ import static org.junit.Assert.assertTrue;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd( message = "<filter> within a collection not supported by schema" )
@SkipForDialect( value = SybaseASE15Dialect.class, jiraKey = "HHH-3637") @SkipForDialect( value = SybaseASE15Dialect.class, jiraKey = "HHH-3637")
public class DynamicFilterTest extends BaseCoreFunctionalTestCase { public class DynamicFilterTest extends BaseCoreFunctionalTestCase {
private static final Logger log = Logger.getLogger( DynamicFilterTest.class ); private static final Logger log = Logger.getLogger( DynamicFilterTest.class );

View File

@ -25,6 +25,7 @@ package org.hibernate.test.filter.hql;
import java.util.Date; import java.util.Date;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.junit.Test; 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" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewUnifiedXsd(message = "joined subclass not getting columns defined by superclass")
public class JoinedFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase { public class JoinedFilteredBulkManipulationTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { return new String[] {

View File

@ -28,7 +28,6 @@ import java.util.Map;
import java.util.Set; import java.util.Set;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
@ -36,6 +35,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory; import org.hibernate.hql.internal.ast.ASTQueryTranslatorFactory;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -46,6 +46,7 @@ import static org.junit.Assert.assertTrue;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase { public class ASTParserLoadingOrderByTest extends BaseCoreFunctionalTestCase {
StateProvince stateProvince; StateProvince stateProvince;
private Zoo zoo1; private Zoo zoo1;

View File

@ -30,7 +30,6 @@ import java.util.Collections;
import org.junit.After; import org.junit.After;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Projections; 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.internal.classic.ClassicQueryTranslatorFactory;
import org.hibernate.hql.spi.QueryTranslator; import org.hibernate.hql.spi.QueryTranslator;
import org.hibernate.hql.spi.QueryTranslatorFactory; import org.hibernate.hql.spi.QueryTranslatorFactory;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.type.BigDecimalType; import org.hibernate.type.BigDecimalType;
import org.hibernate.type.BigIntegerType; import org.hibernate.type.BigIntegerType;
@ -55,6 +55,7 @@ import static org.junit.Assert.fail;
* *
* @author Max Rydahl Andersen * @author Max Rydahl Andersen
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase { public class CriteriaHQLAlignmentTest extends QueryTranslatorTestCase {
private boolean initialVersion2SqlFlagValue; private boolean initialVersion2SqlFlagValue;

View File

@ -39,6 +39,7 @@ import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.engine.spi.SessionFactoryImplementor; import org.hibernate.engine.spi.SessionFactoryImplementor;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipForDialects; import org.hibernate.testing.SkipForDialects;
@ -51,6 +52,7 @@ import org.junit.Test;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase { public class ScrollableCollectionFetchingTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml" }; return new String[] { "hql/Animal.hbm.xml" };

View File

@ -37,6 +37,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.hql.internal.ast.InvalidWithClauseException; import org.hibernate.hql.internal.ast.InvalidWithClauseException;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -46,6 +47,7 @@ import org.junit.Test;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class WithClauseTest extends BaseCoreFunctionalTestCase { public class WithClauseTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "hql/Animal.hbm.xml", "hql/SimpleEntityWithAssociation.hbm.xml" }; return new String[] { "hql/Animal.hbm.xml", "hql/SimpleEntityWithAssociation.hbm.xml" };

View File

@ -29,6 +29,7 @@ import org.hibernate.Session;
import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder; import org.hibernate.id.IdentifierGeneratorHelper.BasicHolder;
import org.hibernate.id.enhanced.SequenceStyleGenerator; import org.hibernate.id.enhanced.SequenceStyleGenerator;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -76,6 +77,7 @@ public class BasicSequenceTest extends BaseCoreFunctionalTestCase {
@Test @Test
@TestForIssue(jiraKey = "HHH-6790") @TestForIssue(jiraKey = "HHH-6790")
@FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table")
public void testSequencePerEntity() { public void testSequencePerEntity() {
final String overriddenEntityName = "SpecialEntity"; final String overriddenEntityName = "SpecialEntity";
EntityPersister persister = sessionFactory().getEntityPersister( overriddenEntityName ); EntityPersister persister = sessionFactory().getEntityPersister( overriddenEntityName );

View File

@ -24,9 +24,9 @@
package org.hibernate.test.immutable.entitywithmutablecollection.inverse; package org.hibernate.test.immutable.entitywithmutablecollection.inverse;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.junit.Test; import org.junit.Test;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpected; 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" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class VersionedEntityWithInverseOneToManyJoinFailureExpectedTest extends AbstractEntityWithOneToManyTest { public class VersionedEntityWithInverseOneToManyJoinFailureExpectedTest extends AbstractEntityWithOneToManyTest {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" }; return new String[] { "immutable/entitywithmutablecollection/inverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };

View File

@ -24,10 +24,12 @@
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?")
public class EntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest { public class EntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -25,6 +25,7 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; 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" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class EntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest { public class EntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml" }; return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationOneToManyJoin.hbm.xml" };

View File

@ -24,10 +24,12 @@
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?")
public class EntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest { public class EntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml" }; return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariation.hbm.xml" };

View File

@ -24,10 +24,12 @@
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithManyToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?")
public class VersionedEntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest { public class VersionedEntityWithNonInverseManyToManyTest extends AbstractEntityWithManyToManyTest {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -25,6 +25,7 @@ package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; 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" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class VersionedEntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest { public class VersionedEntityWithNonInverseOneToManyJoinTest extends AbstractEntityWithOneToManyTest {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml" }; return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersionedOneToManyJoin.hbm.xml" };

View File

@ -24,10 +24,12 @@
package org.hibernate.test.immutable.entitywithmutablecollection.noninverse; package org.hibernate.test.immutable.entitywithmutablecollection.noninverse;
import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest; import org.hibernate.test.immutable.entitywithmutablecollection.AbstractEntityWithOneToManyTest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off -- shouldn't Contract#parties be inverse?")
public class VersionedEntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest { public class VersionedEntityWithNonInverseOneToManyTest extends AbstractEntityWithOneToManyTest {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" }; return new String[] { "immutable/entitywithmutablecollection/noninverse/ContractVariationVersioned.hbm.xml" };

View File

@ -35,6 +35,7 @@ import org.hibernate.Interceptor;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.TransactionException; import org.hibernate.TransactionException;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.Type; import org.hibernate.type.Type;
@ -50,6 +51,7 @@ import static org.junit.Assert.fail;
* @author Gavin King * @author Gavin King
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "select-before-update")
public class InterceptorTest extends BaseCoreFunctionalTestCase { public class InterceptorTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -28,6 +28,7 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -55,6 +56,7 @@ public class InterfaceProxyTest extends BaseCoreFunctionalTestCase {
value = DialectChecks.SupportsExpectedLobUsagePattern.class, value = DialectChecks.SupportsExpectedLobUsagePattern.class,
comment = "database/driver does not support expected LOB usage pattern" comment = "database/driver does not support expected LOB usage pattern"
) )
@FailureExpectedWithNewUnifiedXsd(message = "proxy attributes")
public void testInterfaceProxies() { public void testInterfaceProxies() {
Session s = openSession( new DocumentInterceptor() ); Session s = openSession( new DocumentInterceptor() );
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -39,12 +39,14 @@ import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jdbc.AbstractWork; import org.hibernate.jdbc.AbstractWork;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class JoinTest extends BaseCoreFunctionalTestCase { public class JoinTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -23,20 +23,21 @@
*/ */
package org.hibernate.test.join; 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.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
/** /**
* @author Chris Jones and Gail Badner * @author Chris Jones and Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class OptionalJoinTest extends BaseCoreFunctionalTestCase { public class OptionalJoinTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -25,11 +25,11 @@ package org.hibernate.test.jpa.fetch;
import java.util.Date; import java.util.Date;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.test.jpa.AbstractJPATest; import org.hibernate.test.jpa.AbstractJPATest;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -38,6 +38,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "extra lazy not yet supported in the unified schema")
public class FetchingTest extends AbstractJPATest { public class FetchingTest extends AbstractJPATest {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -29,6 +29,7 @@ import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; 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) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
*/ */
@RequiresDialectFeature(DialectChecks.SupportsCascadeDeleteCheck.class) @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 { public class KeyManyToOneCascadeDeleteTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -125,7 +125,7 @@ public class OneToOneCacheTest extends LegacyTestCase {
Serializable id = generatedId; Serializable id = generatedId;
MainObject mo = ( MainObject ) session.load( MainObject.class, id ); MainObject mo = ( MainObject ) session.get( MainObject.class, id );
tx.commit(); tx.commit();
session.close(); session.close();

View File

@ -52,12 +52,14 @@ import org.hibernate.dialect.SybaseDialect;
import org.hibernate.dialect.TimesTenDialect; import org.hibernate.dialect.TimesTenDialect;
import org.hibernate.dialect.function.SQLFunction; import org.hibernate.dialect.function.SQLFunction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class SQLFunctionsTest extends LegacyTestCase { public class SQLFunctionsTest extends LegacyTestCase {
private static final Logger log = Logger.getLogger( SQLFunctionsTest.class ); private static final Logger log = Logger.getLogger( SQLFunctionsTest.class );

View File

@ -33,8 +33,8 @@ import org.hibernate.loader.plan.spi.EntityReturn;
import org.hibernate.loader.plan.spi.FetchSource; import org.hibernate.loader.plan.spi.FetchSource;
import org.hibernate.loader.plan.spi.LoadPlan; import org.hibernate.loader.plan.spi.LoadPlan;
import org.hibernate.persister.entity.OuterJoinLoadable; import org.hibernate.persister.entity.OuterJoinLoadable;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.hibernate.test.annotations.Country; import org.hibernate.test.annotations.Country;
import org.hibernate.test.annotations.cid.keymanytoone.Card; import org.hibernate.test.annotations.cid.keymanytoone.Card;
@ -61,6 +61,7 @@ import static org.junit.Assert.assertTrue;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "one-to-one refers to entity-name")
public class LoadPlanStructureAssertionTest extends BaseUnitTestCase { public class LoadPlanStructureAssertionTest extends BaseUnitTestCase {
@Test @Test
public void testJoinedOneToOne() { public void testJoinedOneToOne() {
@ -82,6 +83,7 @@ public class LoadPlanStructureAssertionTest extends BaseUnitTestCase {
} }
@Test @Test
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public void testSpecialOneToOne() { public void testSpecialOneToOne() {
// tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest // tests the mappings defined in org.hibernate.test.onetoone.joined.JoinedSubclassOneToOneTest

View File

@ -42,9 +42,8 @@ import org.hibernate.loader.plan.exec.spi.LoadQueryDetails;
import org.hibernate.loader.plan.spi.LoadPlan; import org.hibernate.loader.plan.spi.LoadPlan;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.onetoone.formula.Address; import org.hibernate.test.onetoone.formula.Address;
import org.hibernate.test.onetoone.formula.Person; import org.hibernate.test.onetoone.formula.Person;
@ -55,6 +54,7 @@ import static org.junit.Assert.assertNotNull;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class NonEncapsulatedCompositeIdResultSetProcessorTest extends BaseCoreFunctionalTestCase { public class NonEncapsulatedCompositeIdResultSetProcessorTest extends BaseCoreFunctionalTestCase {
@Override @Override

View File

@ -25,15 +25,15 @@ package org.hibernate.test.loadplans.walking;
import org.hibernate.persister.entity.EntityPersister; import org.hibernate.persister.entity.EntityPersister;
import org.hibernate.persister.walking.spi.MetamodelGraphWalker; import org.hibernate.persister.walking.spi.MetamodelGraphWalker;
import org.junit.Test; import org.junit.Test;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.test.onetoone.formula.Address; import org.hibernate.test.onetoone.formula.Address;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class KeyManyToOneWalkingTest extends BaseCoreFunctionalTestCase { public class KeyManyToOneWalkingTest extends BaseCoreFunctionalTestCase {
@Override @Override
protected String[] getMappings() { protected String[] getMappings() {

View File

@ -24,13 +24,13 @@
package org.hibernate.test.manytomany; package org.hibernate.test.manytomany;
import org.junit.Test; import org.junit.Test;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -40,6 +40,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class ManyToManyTest extends BaseCoreFunctionalTestCase { public class ManyToManyTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -23,8 +23,13 @@
*/ */
package org.hibernate.test.manytomany.batchload; package org.hibernate.test.manytomany.batchload;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.List; import java.util.List;
import junit.framework.Assert;
import org.hibernate.EmptyInterceptor; import org.hibernate.EmptyInterceptor;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Interceptor; 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.batch.spi.BatchKey;
import org.hibernate.engine.jdbc.spi.JdbcCoordinator; import org.hibernate.engine.jdbc.spi.JdbcCoordinator;
import org.hibernate.stat.CollectionStatistics; import org.hibernate.stat.CollectionStatistics;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.junit.Test;
import junit.framework.Assert;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* Tests loading of many-to-many collection which should trigger * Tests loading of many-to-many collection which should trigger
@ -52,6 +52,7 @@ import static org.junit.Assert.assertTrue;
* *
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.")
public class BatchedManyToManyTest extends BaseCoreFunctionalTestCase { public class BatchedManyToManyTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -23,6 +23,7 @@
* *
*/ */
package org.hibernate.test.manytomanyassociationclass; package org.hibernate.test.manytomanyassociationclass;
import java.io.Serializable; import java.io.Serializable;
/** /**

View File

@ -31,6 +31,7 @@ import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.test.manytomanyassociationclass.AbstractManyToManyAssociationClassTest; import org.hibernate.test.manytomanyassociationclass.AbstractManyToManyAssociationClassTest;
import org.hibernate.test.manytomanyassociationclass.Membership; import org.hibernate.test.manytomanyassociationclass.Membership;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
@ -39,6 +40,7 @@ import static org.junit.Assert.fail;
* *
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "mapping looks off: Membership and subclass have Serializable id, but mapping uses type=long")
public class ManyToManyAssociationClassGeneratedIdTest extends AbstractManyToManyAssociationClassTest { public class ManyToManyAssociationClassGeneratedIdTest extends AbstractManyToManyAssociationClassTest {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -24,9 +24,9 @@
package org.hibernate.test.mapelemformula; package org.hibernate.test.mapelemformula;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -34,6 +34,7 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class MapElementFormulaTest extends BaseCoreFunctionalTestCase { public class MapElementFormulaTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "mapelemformula/UserGroup.hbm.xml" }; return new String[] { "mapelemformula/UserGroup.hbm.xml" };

View File

@ -19,6 +19,7 @@ import org.hibernate.metamodel.source.spi.InvalidMappingException;
import org.hibernate.metamodel.source.spi.MappingNotFoundException; import org.hibernate.metamodel.source.spi.MappingNotFoundException;
import org.hibernate.xml.spi.SourceType; import org.hibernate.xml.spi.SourceType;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
@ -34,6 +35,7 @@ import static org.junit.Assert.fail;
*/ */
public class MappingExceptionTest extends BaseUnitTestCase { public class MappingExceptionTest extends BaseUnitTestCase {
@Test @Test
@FailureExpectedWithNewUnifiedXsd
public void testNotFound() throws MappingException, MalformedURLException { public void testNotFound() throws MappingException, MalformedURLException {
Configuration cfg = new Configuration(); Configuration cfg = new Configuration();

View File

@ -23,22 +23,23 @@
*/ */
package org.hibernate.test.mixed; 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.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.dialect.SybaseASE15Dialect; import org.hibernate.dialect.SybaseASE15Dialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.hibernate.testing.SkipLog; import org.hibernate.testing.SkipLog;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@SkipForDialect( SybaseASE15Dialect.class ) @SkipForDialect( SybaseASE15Dialect.class )
@FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table")
public class MixedTest extends BaseCoreFunctionalTestCase { public class MixedTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -33,6 +33,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.stat.Statistics; import org.hibernate.stat.Statistics;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -43,6 +44,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd
public class OnDeleteTest extends BaseCoreFunctionalTestCase { public class OnDeleteTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -24,9 +24,9 @@
package org.hibernate.test.onetomany; package org.hibernate.test.onetomany;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -36,6 +36,7 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class OneToManyTest extends BaseCoreFunctionalTestCase { public class OneToManyTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "onetomany/Parent.hbm.xml" }; return new String[] { "onetomany/Parent.hbm.xml" };

View File

@ -24,7 +24,6 @@
package org.hibernate.test.onetoone.formula; package org.hibernate.test.onetoone.formula;
import org.junit.Test; import org.junit.Test;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
@ -34,6 +33,7 @@ import org.hibernate.cfg.Environment;
import org.hibernate.criterion.Property; import org.hibernate.criterion.Property;
import org.hibernate.dialect.Oracle8iDialect; import org.hibernate.dialect.Oracle8iDialect;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.AbstractSingleColumnStandardBasicType; import org.hibernate.type.AbstractSingleColumnStandardBasicType;
import org.hibernate.type.TextType; import org.hibernate.type.TextType;
@ -49,6 +49,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase { public class OneToOneFormulaTest extends BaseCoreFunctionalTestCase {
private static class TextAsMaterializedClobType extends AbstractSingleColumnStandardBasicType<String> { private static class TextAsMaterializedClobType extends AbstractSingleColumnStandardBasicType<String> {
public final static TextAsMaterializedClobType INSTANCE = new TextAsMaterializedClobType(); public final static TextAsMaterializedClobType INSTANCE = new TextAsMaterializedClobType();

View File

@ -26,10 +26,10 @@ package org.hibernate.test.onetoone.link;
import java.util.Date; import java.util.Date;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -41,6 +41,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "hbm joins not yet supported")
public class OneToOneLinkTest extends BaseCoreFunctionalTestCase { public class OneToOneLinkTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -6,5 +6,4 @@ package org.hibernate.test.onetoone.optional;
*/ */
public class Person extends Entity { public class Person extends Entity {
public Address address; public Address address;
public Address mailingAddress;
} }

View File

@ -32,6 +32,7 @@ import org.hibernate.PersistentObjectException;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.exception.ConstraintViolationException; import org.hibernate.exception.ConstraintViolationException;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -41,6 +42,7 @@ import static org.junit.Assert.fail;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class CreateTest extends AbstractOperationTestCase { public class CreateTest extends AbstractOperationTestCase {
@Test @Test
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})

View File

@ -26,10 +26,12 @@ package org.hibernate.test.ops;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class DeleteTest extends AbstractOperationTestCase { public class DeleteTest extends AbstractOperationTestCase {
@Test @Test
@SuppressWarnings( {"unchecked"}) @SuppressWarnings( {"unchecked"})

View File

@ -36,6 +36,7 @@ import org.hibernate.StaleObjectStateException;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Projections; import org.hibernate.criterion.Projections;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertFalse;
@ -47,6 +48,7 @@ import static org.junit.Assert.fail;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class MergeTest extends AbstractOperationTestCase { public class MergeTest extends AbstractOperationTestCase {
@Test @Test
public void testMergeStaleVersionFails() throws Exception { public void testMergeStaleVersionFails() throws Exception {

View File

@ -24,7 +24,7 @@
package org.hibernate.test.optlock; package org.hibernate.test.optlock;
import org.junit.Test; import static org.junit.Assert.fail;
import org.hibernate.JDBCException; import org.hibernate.JDBCException;
import org.hibernate.Session; import org.hibernate.Session;
@ -32,10 +32,10 @@ import org.hibernate.StaleObjectStateException;
import org.hibernate.StaleStateException; import org.hibernate.StaleStateException;
import org.hibernate.dialect.SQLServerDialect; import org.hibernate.dialect.SQLServerDialect;
import org.hibernate.testing.DialectChecks; import org.hibernate.testing.DialectChecks;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.RequiresDialectFeature; import org.hibernate.testing.RequiresDialectFeature;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.fail;
/** /**
* Tests relating to the optimistic-lock mapping option. * Tests relating to the optimistic-lock mapping option.
@ -47,6 +47,7 @@ import static org.junit.Assert.fail;
value = DialectChecks.DoesRepeatableReadNotCauseReadersToBlockWritersCheck.class, value = DialectChecks.DoesRepeatableReadNotCauseReadersToBlockWritersCheck.class,
comment = "potential deadlock" comment = "potential deadlock"
) )
@FailureExpectedWithNewUnifiedXsd(message = "multiple mappings of the same class/table")
public class OptimisticLockTest extends BaseCoreFunctionalTestCase { public class OptimisticLockTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -29,10 +29,12 @@ import java.util.List;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@FailureExpectedWithNewUnifiedXsd(message = "many-to-manys w/ orphan removal not yet supported")
public class ManyToManyOrphanTest extends BaseCoreFunctionalTestCase { public class ManyToManyOrphanTest extends BaseCoreFunctionalTestCase {
@Override @Override

View File

@ -28,6 +28,7 @@ import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
@ -38,6 +39,7 @@ import static org.junit.Assert.assertNull;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "m2o with orphan removal")
public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase { public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -30,6 +30,7 @@ import static org.junit.Assert.assertNull;
import java.util.List; import java.util.List;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -37,6 +38,7 @@ import org.junit.Test;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "m2o with orphan removal")
public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase { public class DeleteOneToOneOrphansTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "orphan/one2one/fk/reversed/unidirectional/Mapping.hbm.xml" }; return new String[] { "orphan/one2one/fk/reversed/unidirectional/Mapping.hbm.xml" };

View File

@ -24,9 +24,9 @@
package org.hibernate.test.readonly; package org.hibernate.test.readonly;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.testing.FailureExpected; import org.hibernate.testing.FailureExpected;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNotNull;
@ -36,6 +36,7 @@ import static org.junit.Assert.assertSame;
/** /**
* @author Gail Badner * @author Gail Badner
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "statistics are failing")
public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest { public class ReadOnlyVersionedNodesTest extends AbstractReadOnlyTest {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -26,26 +26,26 @@
*/ */
package org.hibernate.test.resulttransformer; package org.hibernate.test.resulttransformer;
import java.sql.ResultSet; import static org.junit.Assert.assertEquals;
import java.util.List; import static org.junit.Assert.assertTrue;
import org.junit.Test; import java.util.List;
import org.hibernate.Query; import org.hibernate.Query;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.dialect.AbstractHANADialect; import org.hibernate.dialect.AbstractHANADialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.transform.ResultTransformer; import org.hibernate.transform.ResultTransformer;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* @author Sharath Reddy * @author Sharath Reddy
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "named query return-join")
public class ResultTransformerTest extends BaseCoreFunctionalTestCase { public class ResultTransformerTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -31,6 +31,7 @@ import org.hibernate.ScrollMode;
import org.hibernate.ScrollableResults; import org.hibernate.ScrollableResults;
import org.hibernate.StatelessSession; import org.hibernate.StatelessSession;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -40,6 +41,7 @@ import static org.junit.Assert.assertNotSame;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class StatelessSessionTest extends BaseCoreFunctionalTestCase { public class StatelessSessionTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "stateless/Document.hbm.xml" }; return new String[] { "stateless/Document.hbm.xml" };

View File

@ -36,6 +36,7 @@ import org.hibernate.cfg.Configuration;
import org.hibernate.stat.QueryStatistics; import org.hibernate.stat.QueryStatistics;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseUnitTestCase; import org.hibernate.testing.junit4.BaseUnitTestCase;
import org.junit.Test; import org.junit.Test;
@ -48,6 +49,7 @@ import static org.junit.Assert.assertNotNull;
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "What does <import> translate to in annotations?")
public class StatsTest extends BaseUnitTestCase { public class StatsTest extends BaseUnitTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "stats/Continent.hbm.xml" }; return new String[] { "stats/Continent.hbm.xml" };

View File

@ -29,9 +29,9 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -39,6 +39,7 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd( message = "<filter> within a collection not supported by schema" )
public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase { public class DiscrimSubclassFilterTest extends BaseCoreFunctionalTestCase {
public final String[] getMappings() { public final String[] getMappings() {
return new String[] { "subclassfilter/discrim-subclass.hbm.xml" }; return new String[] { "subclassfilter/discrim-subclass.hbm.xml" };

View File

@ -29,6 +29,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.hibernate.dialect.CUBRIDDialect; import org.hibernate.dialect.CUBRIDDialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.SkipForDialect; import org.hibernate.testing.SkipForDialect;
import org.junit.Test; 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" + comment = "As of verion 8.4.1 CUBRID doesn't support temporary tables. This test fails with" +
"HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables" "HibernateException: cannot doAfterTransactionCompletion multi-table deletes using dialect not supporting temp tables"
) )
@FailureExpectedWithNewUnifiedXsd(message = "single filter used across joined-subclasses")
public class JoinedSubclassFilterTest extends BaseCoreFunctionalTestCase { public class JoinedSubclassFilterTest extends BaseCoreFunctionalTestCase {
public final String[] getMappings() { public final String[] getMappings() {
return new String[] { "subclassfilter/joined-subclass.hbm.xml" }; return new String[] { "subclassfilter/joined-subclass.hbm.xml" };

View File

@ -31,6 +31,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.cfg.Configuration; import org.hibernate.cfg.Configuration;
import org.hibernate.cfg.Environment; import org.hibernate.cfg.Environment;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -38,6 +39,7 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "timestamps")
public class TimestampTest extends BaseCoreFunctionalTestCase { public class TimestampTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "timestamp/User.hbm.xml" }; return new String[] { "timestamp/User.hbm.xml" };

View File

@ -26,11 +26,11 @@ package org.hibernate.test.typedmanytoone;
import java.util.List; import java.util.List;
import org.junit.Test; import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewMetamodel; import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -41,6 +41,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class TypedManyToOneTest extends BaseCoreFunctionalTestCase { public class TypedManyToOneTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "typedmanytoone/Customer.hbm.xml" }; return new String[] { "typedmanytoone/Customer.hbm.xml" };

View File

@ -35,6 +35,7 @@ import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.engine.spi.SessionImplementor; import org.hibernate.engine.spi.SessionImplementor;
import org.hibernate.jdbc.Work; import org.hibernate.jdbc.Work;
import org.hibernate.testing.FailureExpectedWithNewMetamodel;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
@ -43,6 +44,7 @@ import org.junit.Test;
* *
* @author Michael Gloegl * @author Michael Gloegl
*/ */
@FailureExpectedWithNewMetamodel
public class TypeParameterTest extends BaseCoreFunctionalTestCase { public class TypeParameterTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { return new String[] {

View File

@ -32,12 +32,14 @@ import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test; import org.junit.Test;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "formulas not yet supported in associations")
public class UnconstrainedTest extends BaseCoreFunctionalTestCase { public class UnconstrainedTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -23,9 +23,13 @@
*/ */
package org.hibernate.test.unionsubclass; 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.FetchMode;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
@ -33,18 +37,15 @@ import org.hibernate.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Order; import org.hibernate.criterion.Order;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
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;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS")
public class UnionSubclassTest extends BaseCoreFunctionalTestCase { public class UnionSubclassTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -23,21 +23,22 @@
*/ */
package org.hibernate.test.unionsubclass.alias; 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.Query;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.TestForIssue; import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
/** /**
* @author Strong Liu <stliu@redhat.com> * @author Strong Liu <stliu@redhat.com>
*/ */
@TestForIssue( jiraKey = "HHH-4825" ) @TestForIssue( jiraKey = "HHH-4825" )
@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS")
public class SellCarTest extends BaseCoreFunctionalTestCase { public class SellCarTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "unionsubclass/alias/mapping.hbm.xml" }; return new String[] { "unionsubclass/alias/mapping.hbm.xml" };

View File

@ -23,27 +23,28 @@
*/ */
package org.hibernate.test.unionsubclass2; 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.math.BigDecimal;
import java.util.List; import java.util.List;
import org.junit.Test;
import org.hibernate.Hibernate; import org.hibernate.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.criterion.Property; import org.hibernate.criterion.Property;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.dialect.HSQLDialect; import org.hibernate.dialect.HSQLDialect;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
/** /**
* @author Gavin King * @author Gavin King
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "no support for JaxbInheritanceType.UNION_SUBCLASS")
public class UnionSubclassTest extends BaseCoreFunctionalTestCase { public class UnionSubclassTest extends BaseCoreFunctionalTestCase {
protected String[] getMappings() { protected String[] getMappings() {
return new String[] { "unionsubclass2/Person.hbm.xml" }; return new String[] { "unionsubclass2/Person.hbm.xml" };

View File

@ -23,16 +23,16 @@
*/ */
package org.hibernate.test.version; 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.Hibernate;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/** /**
* @author Max Rydahl Andersen * @author Max Rydahl Andersen
@ -74,6 +74,7 @@ public class VersionTest extends BaseCoreFunctionalTestCase {
} }
@Test @Test
@FailureExpectedWithNewUnifiedXsd
public void testCollectionVersion() { public void testCollectionVersion() {
Session s = openSession(); Session s = openSession();
Transaction t = s.beginTransaction(); Transaction t = s.beginTransaction();

View File

@ -29,6 +29,7 @@ import org.junit.Test;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.Transaction; import org.hibernate.Transaction;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.hibernate.type.StandardBasicTypes; import org.hibernate.type.StandardBasicTypes;
@ -38,6 +39,7 @@ import static org.junit.Assert.assertTrue;
/** /**
* @author Steve Ebersole * @author Steve Ebersole
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines batch-size at the class level, not collections.")
public class DbVersionTest extends BaseCoreFunctionalTestCase { public class DbVersionTest extends BaseCoreFunctionalTestCase {
@Override @Override
public String[] getMappings() { public String[] getMappings() {

View File

@ -28,6 +28,7 @@ import org.junit.Test;
import org.hibernate.FetchMode; import org.hibernate.FetchMode;
import org.hibernate.Session; import org.hibernate.Session;
import org.hibernate.criterion.Restrictions; import org.hibernate.criterion.Restrictions;
import org.hibernate.testing.FailureExpectedWithNewUnifiedXsd;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase; import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -35,6 +36,7 @@ import static org.junit.Assert.assertEquals;
/** /**
* @author Max Rydahl Andersen * @author Max Rydahl Andersen
*/ */
@FailureExpectedWithNewUnifiedXsd(message = "New schema only defines where at the class level, not collections.")
public class WhereTest extends BaseCoreFunctionalTestCase { public class WhereTest extends BaseCoreFunctionalTestCase {
public String[] getMappings() { public String[] getMappings() {
return new String[] { "where/File.hbm.xml" }; return new String[] { "where/File.hbm.xml" };

View File

@ -26,6 +26,9 @@ package org.hibernate.envers.configuration.internal;
import java.sql.Date; import java.sql.Date;
import java.util.Collection; import java.util.Collection;
import org.dom4j.Document;
import org.dom4j.DocumentFactory;
import org.dom4j.Element;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService; import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.envers.DefaultRevisionEntity; 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.revisioninfo.RevisionInfoQueryCreator;
import org.hibernate.envers.internal.tools.MutableBoolean; import org.hibernate.envers.internal.tools.MutableBoolean;
import org.hibernate.envers.internal.tools.Tools; 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.JPADotNames;
import org.hibernate.metamodel.source.internal.annotations.util.JandexHelper; 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.InFlightMetadataCollector;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.AttributeBinding; import org.hibernate.metamodel.spi.binding.AttributeBinding;
import org.hibernate.metamodel.spi.binding.EntityBinding;
import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor; import org.hibernate.metamodel.spi.binding.HibernateTypeDescriptor;
import org.hibernate.metamodel.spi.binding.SetBinding; import org.hibernate.metamodel.spi.binding.SetBinding;
import org.hibernate.type.IntegerType; import org.hibernate.type.IntegerType;
import org.hibernate.type.LongType; import org.hibernate.type.LongType;
import org.hibernate.type.Type; import org.hibernate.type.Type;
import org.dom4j.Document;
import org.dom4j.Element;
import org.jboss.jandex.AnnotationInstance; import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget; import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo; import org.jboss.jandex.ClassInfo;
@ -68,8 +67,6 @@ import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.IndexView; import org.jboss.jandex.IndexView;
import org.jboss.jandex.MethodInfo; import org.jboss.jandex.MethodInfo;
import static org.hibernate.metamodel.spi.AdditionalJaxbRootProducer.AdditionalJaxbRootProducerContext;
/** /**
* @author Adam Warski (adam at warski dot org) * @author Adam Warski (adam at warski dot org)
* @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com) * @author Lukasz Antoniak (lukasz dot antoniak at gmail dot com)
@ -102,7 +99,7 @@ public class RevisionInfoConfiguration {
} }
private Document generateDefaultRevisionInfoXmlMapping() { private Document generateDefaultRevisionInfoXmlMapping() {
final Document document = XMLHelper.getDocumentFactory().createDocument(); final Document document = DocumentFactory.getInstance().createDocument();
final Element classMapping = MetadataTools.createEntity( final Element classMapping = MetadataTools.createEntity(
document, document,
@ -185,7 +182,7 @@ public class RevisionInfoConfiguration {
} }
private Element generateRevisionInfoRelationMapping() { private Element generateRevisionInfoRelationMapping() {
final Document document = XMLHelper.getDocumentFactory().createDocument(); final Document document = DocumentFactory.getInstance().createDocument();
final Element revRelMapping = document.addElement( "key-many-to-one" ); final Element revRelMapping = document.addElement( "key-many-to-one" );
// TODO: this does not belong here; does it belong somewhere else???? // TODO: this does not belong here; does it belong somewhere else????
//revRelMapping.addAttribute( "type", revisionPropType ); //revRelMapping.addAttribute( "type", revisionPropType );

View File

@ -1,28 +1,12 @@
package org.hibernate.envers.event.spi; 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.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; 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.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.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.envers.configuration.internal.AnnotationProxyBuilder; import org.hibernate.envers.configuration.internal.AnnotationProxyBuilder;
import org.hibernate.envers.configuration.internal.AuditEntitiesConfiguration; 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.binding.EntityBinding;
import org.hibernate.metamodel.spi.domain.Attribute; import org.hibernate.metamodel.spi.domain.Attribute;
import org.hibernate.metamodel.spi.domain.AttributeContainer; 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.BindResult;
import org.hibernate.xml.spi.Origin; import org.hibernate.xml.spi.Origin;
import org.hibernate.xml.spi.SourceType; 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) * @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 InFlightMetadataCollector metadataCollector;
private final AdditionalJaxbRootProducerContext additionalJaxbRootProducerContext; private final AdditionalJaxbRootProducerContext additionalJaxbRootProducerContext;
private final AnnotationProxyBuilder annotationProxyBuilder = new AnnotationProxyBuilder(); private final AnnotationProxyBuilder annotationProxyBuilder = new AnnotationProxyBuilder();
private final MappingXmlBinder jaxbProcessor;
private final List<BindResult> bindResults = new ArrayList<BindResult>(); private final List<BindResult> bindResults = new ArrayList<BindResult>();
private final Origin origin = new Origin( SourceType.DOM, Origin.UNKNOWN_FILE_PATH ); private final Origin origin = new Origin( SourceType.DOM, Origin.UNKNOWN_FILE_PATH );
private final GlobalConfiguration globalCfg; private final GlobalConfiguration globalCfg;
@ -88,9 +75,6 @@ public class EnversJaxbRootProducer implements AdditionalJaxbRootProducer {
final RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration( globalCfg ); final RevisionInfoConfiguration revInfoCfg = new RevisionInfoConfiguration( globalCfg );
this.revInfoCfgResult = revInfoCfg.configure( metadataCollector, additionalJaxbRootProducerContext ); this.revInfoCfgResult = revInfoCfg.configure( metadataCollector, additionalJaxbRootProducerContext );
this.auditEntCfg = new AuditEntitiesConfiguration( additionalJaxbRootProducerContext.getServiceRegistry(), revInfoCfgResult.getRevisionInfoEntityName() ); this.auditEntCfg = new AuditEntitiesConfiguration( additionalJaxbRootProducerContext.getServiceRegistry(), revInfoCfgResult.getRevisionInfoEntityName() );
jaxbProcessor = new MappingXmlBinder(
additionalJaxbRootProducerContext.getServiceRegistry()
);
} }
@Override @Override
@ -175,22 +159,7 @@ public class EnversJaxbRootProducer implements AdditionalJaxbRootProducer {
@Override @Override
public void addDocument(org.w3c.dom.Document document) { public void addDocument(org.w3c.dom.Document document) {
// TODO
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 ) );
} }
private List<BindResult> getBindResults() { private List<BindResult> getBindResults() {