HHH-8893 - Develop Hibernate mapping XSD extending the JPA mapping (orm) XSD;

HHH-8894 - Use an "upgrade" approach to validate and bind (JAXB) mapping XML - hbm-to-orm XSLT
This commit is contained in:
Steve Ebersole 2014-02-10 01:00:19 -06:00
parent e8fdeb258f
commit 056024a8b6
90 changed files with 1301 additions and 839 deletions

View File

@ -111,18 +111,17 @@ task jaxb {
// input schemas
cfgXsd = file( 'src/main/resources/org/hibernate/hibernate-configuration-4.0.xsd')
hbmXsd = file( 'src/main/resources/org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd' )
ormXsd = file( 'src/main/resources/org/hibernate/jpa/orm_2_1.xsd' )
unifiedOrmXsd = file( 'src/main/resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd' )
// input bindings
cfgXjb = file( 'src/main/xjb/hbm-configuration-bindings.xjb' )
hbmXjb = file( 'src/main/xjb/hbm-mapping-bindings.xjb' )
ormXjb = file( 'src/main/xjb/orm-bindings.xjb' )
unifiedOrmXjb = file( 'src/main/xjb/mapping-bindings.xjb' )
}
// configure Gradle up-to-date checking
inputs.files( [cfgXsd, hbmXsd, ormXsd, unifiedOrmXsd, cfgXjb, hbmXjb, ormXjb, unifiedOrmXjb] )
// inputs.files( [cfgXsd, hbmXsd, ormXsd, unifiedOrmXsd, cfgXjb, hbmXjb, ormXjb, unifiedOrmXjb] )
inputs.files( [cfgXsd, hbmXsd, unifiedOrmXsd, cfgXjb, hbmXjb, unifiedOrmXjb] )
outputs.dir( jaxbTargetDir )
// perform actions
@ -150,17 +149,6 @@ task jaxb {
arg line: '-Xinheritance -Xsimplify'
}
// orm.xml (jpa)
ant.xjc(
destdir: '${jaxbTargetDir}',
package: 'org.hibernate.jaxb.spi.orm',
binding: 'src/main/xjb/orm-bindings.xjb',
schema: ormXsd.path,
extension: 'true'
) {
arg line: '-Xinheritance'
}
// unified mapping xsd
ant.xjc(
destdir: '${jaxbTargetDir}',

View File

@ -23,6 +23,8 @@
*/
package org.hibernate;
import java.util.Locale;
/**
* Represents a flushing strategy. The flush process synchronizes
* database state with session state by detecting state changes
@ -102,6 +104,10 @@ public enum FlushMode {
return MANUAL.level == mode.level;
}
public String toExternalForm() {
return name().toLowerCase( Locale.ENGLISH );
}
/**
* Interprets an external representation of the flush mode. {@code null} is returned as {@code null}, otherwise
* {@link FlushMode#valueOf(String)} is used with the upper-case version of the incoming value. An unknown,
@ -119,7 +125,7 @@ public enum FlushMode {
}
try {
return FlushMode.valueOf( externalName.toUpperCase() );
return FlushMode.valueOf( externalName.toUpperCase( Locale.ENGLISH ) );
}
catch ( IllegalArgumentException e ) {
throw new MappingException( "unknown FlushMode : " + externalName );

View File

@ -32,7 +32,6 @@ import java.io.InputStream;
import java.io.Serializable;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
import java.util.HashSet;
import java.util.LinkedHashSet;
@ -47,6 +46,7 @@ import org.hibernate.boot.registry.BootstrapServiceRegistry;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.boot.registry.StandardServiceRegistry;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.SerializationHelper;
@ -56,16 +56,16 @@ import org.hibernate.jaxb.spi.hbm.JaxbHibernateMapping;
import org.hibernate.jaxb.spi.hbm.JaxbJoinedSubclassElement;
import org.hibernate.jaxb.spi.hbm.JaxbSubclassElement;
import org.hibernate.jaxb.spi.hbm.JaxbUnionSubclassElement;
import org.hibernate.jaxb.spi.orm.JaxbConverter;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddable;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.jaxb.spi.orm.JaxbMappedSuperclass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbConverter;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMappedSuperclass;
import org.hibernate.metamodel.internal.MetadataBuilderImpl;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.EntityMappingsMocker;
import org.hibernate.metamodel.source.internal.jandex.EntityMappingsMocker;
import org.hibernate.metamodel.spi.source.InvalidMappingException;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.metamodel.spi.source.MappingNotFoundException;
@ -78,7 +78,6 @@ import org.hibernate.xml.spi.SourceType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.CompositeIndex;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
@ -96,15 +95,7 @@ import org.w3c.dom.Document;
* @author Brett Meyer
*/
public class MetadataSources {
public static final String UNKNOWN_FILE_PATH = "<unknown>";
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class, MetadataSources.class.getName());
/**
* temporary option
*/
public static final String USE_NEW_METADATA_MAPPINGS = "hibernate.test.new_metadata_mappings";
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( MetadataSources.class );
private final ServiceRegistry serviceRegistry;
private final MappingXmlBinder jaxbProcessor;
@ -448,7 +439,7 @@ public class MetadataSources {
* @return this (for method chaining purposes)
*/
public MetadataSources addInputStream(InputStream xmlInputStream) {
add( xmlInputStream, new Origin( SourceType.INPUT_STREAM, UNKNOWN_FILE_PATH ), false );
add( xmlInputStream, new Origin( SourceType.INPUT_STREAM, Origin.UNKNOWN_FILE_PATH ), false );
return this;
}
@ -481,7 +472,7 @@ public class MetadataSources {
* @return this (for method chaining purposes)
*/
public MetadataSources addDocument(Document document) {
final Origin origin = new Origin( SourceType.DOM, UNKNOWN_FILE_PATH );
final Origin origin = new Origin( SourceType.DOM, Origin.UNKNOWN_FILE_PATH );
BindResult bindResult = jaxbProcessor.bind( document, origin );
addJaxbRoot( bindResult );
return this;
@ -562,31 +553,20 @@ public class MetadataSources {
return this;
}
@SuppressWarnings("unchecked")
public IndexView wrapJandexView(IndexView jandexView) {
if ( ! hasOrmXmlJaxbRoots ) {
// no need to wrap
return jandexView;
}
final List<JaxbEntityMappings> collectedOrmXmlMappings = new ArrayList<JaxbEntityMappings>();
for ( BindResult bindResult : getBindResultList() ) {
if ( JaxbEntityMappings.class.isInstance( bindResult.getRoot() ) ) {
collectedOrmXmlMappings.add( ( (BindResult<JaxbEntityMappings>) bindResult ).getRoot() );
}
}
if ( collectedOrmXmlMappings.isEmpty() ) {
// log a warning or something
}
return new EntityMappingsMocker( collectedOrmXmlMappings, jandexView, serviceRegistry ).mockNewIndex();
}
public IndexView buildJandexView() {
return buildJandexView( false );
}
/**
* Create a Jandex IndexView from scratch given the sources information contained here.
*
* @param autoIndexMemberTypes Should the types of class members automatically be added to the built index?
*
* @return
*/
public IndexView buildJandexView(boolean autoIndexMemberTypes) {
return JandexIndexBuilder.process( autoIndexMemberTypes, this );
}
public static class JandexIndexBuilder {
private static final Logger log = Logger.getLogger( JandexIndexBuilder.class );
@ -864,15 +844,4 @@ public class MetadataSources {
}
}
}
/**
* Create a Jandex IndexView from scratch given the sources information contained here.
*
* @param autoIndexMemberTypes Should the types of class members automatically be added to the built index?
*
* @return
*/
public IndexView buildJandexView(boolean autoIndexMemberTypes) {
return wrapJandexView( JandexIndexBuilder.process( autoIndexMemberTypes, this ) );
}
}

View File

@ -25,16 +25,11 @@ package org.hibernate.metamodel.internal;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.DuplicateMappingException;
import org.hibernate.EntityMode;
@ -62,13 +57,13 @@ import org.hibernate.id.factory.spi.MutableIdentifierGeneratorFactory;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.ValueHolder;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.xml.spi.BindResult;
import org.hibernate.metamodel.MetadataSourceProcessingOrder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.SessionFactoryBuilder;
import org.hibernate.metamodel.internal.source.annotations.AnnotationMetadataSourceProcessorImpl;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.hbm.HbmMetadataSourceProcessorImpl;
import org.hibernate.metamodel.source.internal.jandex.Unifier;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.spi.AdditionalJaxbRootProducer;
import org.hibernate.metamodel.spi.MetadataContributor;
import org.hibernate.metamodel.spi.MetadataImplementor;
@ -110,6 +105,10 @@ import org.hibernate.type.TypeFactory;
import org.hibernate.type.TypeResolver;
import org.hibernate.usertype.CompositeUserType;
import org.hibernate.usertype.UserType;
import org.hibernate.xml.spi.BindResult;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
/**
* Container for configuration data collected during binding the metamodel.
@ -177,13 +176,31 @@ public class MetadataImpl implements MetadataImplementor, Serializable {
}
};
// todo : cache the built index if no inputs have changed (look at gradle-style hashing for up-to-date checking)
boolean autoIndexMemberTypes = serviceRegistry.getService( ConfigurationService.class ).getSetting(
AvailableSettings.ENABLE_AUTO_INDEX_MEMBER_TYPES, StandardConverters.BOOLEAN, false );
final IndexView jandexView = options.getJandexView() != null
? metadataSources.wrapJandexView( options.getJandexView() )
: metadataSources.buildJandexView( autoIndexMemberTypes );
Collection<AnnotationInstance> tables = jandexView.getAnnotations( JPADotNames.TABLE );
final ConfigurationService configurationService = serviceRegistry.getService( ConfigurationService.class );
final IndexView baseJandexIndex;
if ( options.getJandexView() != null ) {
baseJandexIndex = options.getJandexView();
}
else {
final boolean autoIndexMemberTypes = configurationService.getSetting(
AvailableSettings.ENABLE_AUTO_INDEX_MEMBER_TYPES,
StandardConverters.BOOLEAN,
false
);
baseJandexIndex = metadataSources.buildJandexView( autoIndexMemberTypes );
}
final List<BindResult<JaxbEntityMappings>> jpaXmlBindings = new ArrayList<BindResult<JaxbEntityMappings>>();
for ( BindResult bindResult : metadataSources.getBindResultList() ) {
if ( JaxbEntityMappings.class.isInstance( bindResult.getRoot() ) ) {
// todo : this will be checked after hbm transformation is in place.
//noinspection unchecked
jpaXmlBindings.add( bindResult );
}
}
final IndexView jandexView = Unifier.unify( baseJandexIndex, jpaXmlBindings, serviceRegistry );
final MetadataSourceProcessor[] metadataSourceProcessors;
if ( options.getMetadataSourceProcessingOrder() == MetadataSourceProcessingOrder.HBM_FIRST ) {
metadataSourceProcessors = new MetadataSourceProcessor[] {

View File

@ -37,7 +37,7 @@ import org.hibernate.metamodel.internal.source.annotations.global.TableProcessor
import org.hibernate.metamodel.internal.source.annotations.util.EntityHierarchyBuilder;
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.hibernate.metamodel.source.internal.jandex.PseudoJpaDotNames;
import org.hibernate.metamodel.spi.MetadataSourceProcessor;
import org.hibernate.metamodel.spi.source.EntityHierarchy;
import org.hibernate.metamodel.spi.source.FilterDefinitionSource;

View File

@ -50,7 +50,7 @@ import org.hibernate.metamodel.internal.source.annotations.util.EnumConversionHe
import org.hibernate.metamodel.internal.source.annotations.util.HibernateDotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.MockHelper;
import org.hibernate.metamodel.source.internal.jandex.MockHelper;
import org.hibernate.metamodel.spi.source.MappingException;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;

View File

@ -51,7 +51,7 @@ import org.hibernate.metamodel.internal.source.annotations.entity.ConfiguredClas
import org.hibernate.metamodel.internal.source.annotations.entity.EntityBindingContext;
import org.hibernate.metamodel.internal.source.annotations.entity.EntityClass;
import org.hibernate.metamodel.internal.source.annotations.entity.MappedSuperclass;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.hibernate.metamodel.source.internal.jandex.PseudoJpaDotNames;
import org.hibernate.metamodel.spi.source.JpaCallbackSource;
/**

View File

@ -1,35 +0,0 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import java.util.List;
import org.hibernate.jaxb.spi.orm.JaxbBasic;
import org.hibernate.jaxb.spi.orm.JaxbElementCollection;
import org.hibernate.jaxb.spi.orm.JaxbEmbedded;
import org.hibernate.jaxb.spi.orm.JaxbManyToMany;
import org.hibernate.jaxb.spi.orm.JaxbManyToOne;
import org.hibernate.jaxb.spi.orm.JaxbOneToMany;
import org.hibernate.jaxb.spi.orm.JaxbOneToOne;
import org.hibernate.jaxb.spi.orm.JaxbTransient;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public interface AttributesContainer {
List<JaxbTransient> getTransient();
List<JaxbBasic> getBasic();
List<JaxbElementCollection> getElementCollection();
List<JaxbEmbedded> getEmbedded();
List<JaxbManyToMany> getManyToMany();
List<JaxbManyToOne> getManyToOne();
List<JaxbOneToMany> getOneToMany();
List<JaxbOneToOne> getOneToOne();
}

View File

@ -1,17 +0,0 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public interface EntityElement {
String getClazz();
void setClazz(String className);
Boolean isMetadataComplete();
void setMetadataComplete(Boolean isMetadataComplete);
public JaxbAccessType getAccess();
}

View File

@ -1,8 +0,0 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public interface Listener {
public String getMethodName();
}

View File

@ -1,14 +0,0 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
/**
* @author Strong Liu <stliu@hibernate.org>
*/
public interface PropertyElement {
String getName();
JaxbAccessType getAccess();
void setAccess(JaxbAccessType accessType);
}

View File

@ -25,6 +25,7 @@ package org.hibernate.metamodel.internal.source.hbm.transform;
import java.util.Date;
import org.hibernate.FlushMode;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.hbm.JaxbCacheModeAttribute;
import org.hibernate.jaxb.spi.hbm.JaxbClassElement;
@ -43,21 +44,19 @@ import org.hibernate.jaxb.spi.hbm.JaxbQueryParamElement;
import org.hibernate.jaxb.spi.hbm.JaxbSqlQueryElement;
import org.hibernate.jaxb.spi.hbm.JaxbSubclassElement;
import org.hibernate.jaxb.spi.hbm.JaxbTypedefElement;
import org.hibernate.metamodel.spi.source.jaxb.JaxbCacheModeType;
import org.hibernate.metamodel.spi.source.jaxb.JaxbEntity;
import org.hibernate.metamodel.spi.source.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.spi.source.jaxb.JaxbFlushModeType;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmFetchProfile;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmFilterDef;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmIdGeneratorDef;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmParam;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmToolingHint;
import org.hibernate.metamodel.spi.source.jaxb.JaxbHbmTypeDef;
import org.hibernate.metamodel.spi.source.jaxb.JaxbMappedSuperclass;
import org.hibernate.metamodel.spi.source.jaxb.JaxbNamedNativeQuery;
import org.hibernate.metamodel.spi.source.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.spi.source.jaxb.JaxbPersistenceUnitMetadata;
import org.hibernate.metamodel.spi.source.jaxb.JaxbQueryParamType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbCacheModeType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFetchProfile;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmFilterDef;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmIdGeneratorDef;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmParam;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmToolingHint;
import org.hibernate.metamodel.source.internal.jaxb.JaxbHbmTypeDef;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitMetadata;
import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryParamType;
import org.jboss.logging.Logger;
@ -255,7 +254,7 @@ public class HbmXmlTransformer {
query.setCacheRegion( hbmQuery.getCacheRegion() );
query.setComment( hbmQuery.getComment() );
query.setFetchSize( hbmQuery.getFetchSize() );
query.setFlushMode( convert( hbmQuery.getFlushMode() ) );
query.setFlushMode( interpret( hbmQuery.getFlushMode() ) );
query.setFetchSize( hbmQuery.getFetchSize() );
query.setReadOnly( hbmQuery.isReadOnly() );
query.setTimeout( hbmQuery.getTimeout() );
@ -285,13 +284,13 @@ public class HbmXmlTransformer {
return JaxbCacheModeType.fromValue( value );
}
private JaxbFlushModeType convert(JaxbFlushModeAttribute flushMode) {
private FlushMode interpret(JaxbFlushModeAttribute flushMode) {
final String value = flushMode == null ? null : flushMode.value();
if ( StringHelper.isEmpty( value ) ) {
return null;
}
return JaxbFlushModeType.fromValue( value );
return FlushMode.valueOf( value );
}
private void transferNamedSqlQuery(JaxbHibernateMapping hbmXmlMapping, JaxbEntityMappings ormRoot) {
@ -308,7 +307,7 @@ public class HbmXmlTransformer {
query.setCacheRegion( hbmQuery.getCacheRegion() );
query.setComment( hbmQuery.getComment() );
query.setFetchSize( hbmQuery.getFetchSize() );
query.setFlushMode( convert( hbmQuery.getFlushMode() ) );
query.setFlushMode( interpret( hbmQuery.getFlushMode() ) );
query.setFetchSize( hbmQuery.getFetchSize() );
query.setReadOnly( hbmQuery.isReadOnly() );
query.setTimeout( hbmQuery.getTimeout() );
@ -334,11 +333,11 @@ public class HbmXmlTransformer {
}
private void transferEntities(JaxbHibernateMapping hbmXmlMapping, JaxbEntityMappings ormRoot) {
// todo : make MappedSuperclass for abstract hbm class mappings?
// thoughts...
// 1) We only need to transfer the "extends" attribute if the model is dynamic (map mode)
//
// 1) We only need to transfer the "extends" attribute if the model is dynamic (map mode),
// otherwise it will be discovered via jandex
// 2) ?? Have abstract hbm class mappings become MappedSuperclass mappings ??
if ( !hbmXmlMapping.getClazz().isEmpty() ) {
for ( JaxbClassElement hbmClass : hbmXmlMapping.getClazz() ) {
final JaxbEntity entity = new JaxbEntity();

View File

@ -21,33 +21,34 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.AttributesContainer;
import org.hibernate.metamodel.source.internal.jaxb.JaxbBasic;
import org.hibernate.metamodel.source.internal.jaxb.JaxbElementCollection;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbedded;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddedId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToMany;
import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToOne;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToMany;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTransient;
import org.hibernate.metamodel.source.internal.jaxb.JaxbVersion;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbBasic;
import org.hibernate.jaxb.spi.orm.JaxbElementCollection;
import org.hibernate.jaxb.spi.orm.JaxbEmbedded;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddedId;
import org.hibernate.jaxb.spi.orm.JaxbId;
import org.hibernate.jaxb.spi.orm.JaxbManyToMany;
import org.hibernate.jaxb.spi.orm.JaxbManyToOne;
import org.hibernate.jaxb.spi.orm.JaxbOneToMany;
import org.hibernate.jaxb.spi.orm.JaxbOneToOne;
import org.hibernate.jaxb.spi.orm.JaxbTransient;
import org.hibernate.jaxb.spi.orm.JaxbVersion;
/**
* Abstract parse to handle {@link org.hibernate.jaxb.spi.orm.JaxbAttributes JaxbAttributes}
* and {@link org.hibernate.jaxb.spi.orm.JaxbEmbeddableAttributes JaxbEmbeddableAttributes}.
* Abstract parse to handle {@link org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes JaxbAttributes}
* and {@link org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddableAttributes JaxbEmbeddableAttributes}.
*
* It would be really helpful if these two classes can implement an interface with those abstract methods in this class.
*
* @author Strong Liu
*/
abstract class AbstractAttributesBuilder {
public abstract class AbstractAttributesBuilder {
private ClassInfo classInfo;
private EntityMappingsMocker.Default defaults;

View File

@ -21,30 +21,32 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import javax.persistence.AccessType;
import org.hibernate.AssertionFailure;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostPersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrePersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.ManagedType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.AssertionFailure;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
import org.hibernate.jaxb.spi.orm.JaxbIdClass;
import org.hibernate.jaxb.spi.orm.JaxbPostLoad;
import org.hibernate.jaxb.spi.orm.JaxbPostPersist;
import org.hibernate.jaxb.spi.orm.JaxbPostRemove;
import org.hibernate.jaxb.spi.orm.JaxbPostUpdate;
import org.hibernate.jaxb.spi.orm.JaxbPrePersist;
import org.hibernate.jaxb.spi.orm.JaxbPreRemove;
import org.hibernate.jaxb.spi.orm.JaxbPreUpdate;
/**
* @author Strong Liu
*/
abstract class AbstractEntityObjectMocker extends AnnotationMocker {
public abstract class AbstractEntityObjectMocker extends AnnotationMocker {
private ListenerMocker listenerparse;
protected AbstractAttributesBuilder attributesBuilder;
protected ClassInfo classInfo;
@ -58,7 +60,7 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
/**
* Pre-process Entity Objects to find the default {@link javax.persistence.Access} for later attributes processing.
*/
final void preProcess() {
public final void preProcess() {
DefaultConfigurationHelper.INSTANCE.applyDefaults( getEntityElement(), getDefaults() );
classInfo = indexBuilder.createClassInfo( getEntityElement().getClazz() );
DotName classDotName = classInfo.name();
@ -69,12 +71,12 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
isPreProcessCalled = true;
}
final void process() {
public final void process() {
if ( !isPreProcessCalled ) {
throw new AssertionFailure( "preProcess should be called before process" );
}
if ( getEntityElement().getAccess() == null ) {
JaxbAccessType accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
AccessType accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
if ( accessType == null ) {
accessType = getDefaults().getAccess();
}
@ -107,7 +109,7 @@ abstract class AbstractEntityObjectMocker extends AnnotationMocker {
indexBuilder.finishEntityObject( getTargetName(), getDefaults() );
}
abstract protected EntityElement getEntityElement();
abstract protected ManagedType getEntityElement();
abstract protected void processExtra();
abstract protected boolean isExcludeDefaultListeners();

View File

@ -21,16 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.AccessType;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbIndex;
import org.hibernate.jaxb.spi.orm.JaxbUniqueConstraint;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIndex;
import org.hibernate.metamodel.source.internal.jaxb.JaxbUniqueConstraint;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
@ -41,7 +42,7 @@ import org.jboss.jandex.DotName;
*
* @author Strong Liu
*/
abstract class AbstractMocker implements JPADotNames {
public abstract class AbstractMocker implements JPADotNames {
final protected IndexBuilder indexBuilder;
AbstractMocker(IndexBuilder indexBuilder) {
@ -69,7 +70,7 @@ abstract class AbstractMocker implements JPADotNames {
}
protected AnnotationInstance parseAccessType(JaxbAccessType accessType, AnnotationTarget target) {
protected AnnotationInstance parseAccessType(AccessType accessType, AnnotationTarget target) {
if ( accessType == null ) {
return null;
}

View File

@ -21,20 +21,20 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.List;
import java.util.Map;
import javax.persistence.AccessType;
import org.hibernate.AssertionFailure;
import org.hibernate.MappingException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.ClassInfo;
@ -45,13 +45,13 @@ import org.jboss.logging.Logger;
/**
* @author Strong Liu
*/
class AccessHelper implements JPADotNames {
public class AccessHelper implements JPADotNames {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
AccessHelper.class.getName()
);
static JaxbAccessType getAccessFromDefault(IndexBuilder indexBuilder) {
static AccessType getAccessFromDefault(IndexBuilder indexBuilder) {
AnnotationInstance annotationInstance = JandexHelper.getSingleAnnotation(
indexBuilder.getAnnotations(),
PseudoJpaDotNames.DEFAULT_ACCESS
@ -60,16 +60,20 @@ class AccessHelper implements JPADotNames {
return null;
}
else {
return JandexHelper.getEnumValue( annotationInstance, "value", JaxbAccessType.class,
indexBuilder.getServiceRegistry().getService( ClassLoaderService.class ) );
return JandexHelper.getEnumValue(
annotationInstance,
"value",
AccessType.class,
indexBuilder.getServiceRegistry().getService( ClassLoaderService.class )
);
}
}
static JaxbAccessType getAccessFromIdPosition(DotName className, IndexBuilder indexBuilder) {
static AccessType getAccessFromIdPosition(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
JaxbAccessType accessType = getAccessFromIdPosition( ormAnnotations );
AccessType accessType = getAccessFromIdPosition( ormAnnotations );
if ( accessType == null ) {
accessType = getAccessFromIdPosition( indexedAnnotations );
}
@ -88,7 +92,7 @@ class AccessHelper implements JPADotNames {
return accessType;
}
private static JaxbAccessType getAccessFromIdPosition(Map<DotName, List<AnnotationInstance>> annotations) {
private static AccessType getAccessFromIdPosition(Map<DotName, List<AnnotationInstance>> annotations) {
if ( annotations == null || annotations.isEmpty() || !( annotations.containsKey( ID ) ) ) {
return null;
}
@ -99,8 +103,8 @@ class AccessHelper implements JPADotNames {
return null;
}
private static JaxbAccessType processIdAnnotations(List<AnnotationInstance> idAnnotations) {
JaxbAccessType accessType = null;
private static AccessType processIdAnnotations(List<AnnotationInstance> idAnnotations) {
AccessType accessType = null;
for ( AnnotationInstance annotation : idAnnotations ) {
AnnotationTarget tmpTarget = annotation.target();
if ( tmpTarget == null ) {
@ -118,14 +122,14 @@ class AccessHelper implements JPADotNames {
return accessType;
}
static JaxbAccessType annotationTargetToAccessType(AnnotationTarget target) {
return ( target instanceof MethodInfo ) ? JaxbAccessType.PROPERTY : JaxbAccessType.FIELD;
static AccessType annotationTargetToAccessType(AnnotationTarget target) {
return ( target instanceof MethodInfo ) ? AccessType.PROPERTY : AccessType.FIELD;
}
static JaxbAccessType getEntityAccess(DotName className, IndexBuilder indexBuilder) {
static AccessType getEntityAccess(DotName className, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
Map<DotName, List<AnnotationInstance>> ormAnnotations = indexBuilder.getClassInfoAnnotationsMap( className );
JaxbAccessType accessType = getAccess( ormAnnotations, indexBuilder );
AccessType accessType = getAccess( ormAnnotations, indexBuilder );
if ( accessType == null ) {
accessType = getAccess( indexedAnnotations, indexBuilder );
}
@ -143,7 +147,7 @@ class AccessHelper implements JPADotNames {
}
private static JaxbAccessType getAccess(Map<DotName, List<AnnotationInstance>> annotations, IndexBuilder indexBuilder) {
private static AccessType getAccess(Map<DotName, List<AnnotationInstance>> annotations, IndexBuilder indexBuilder) {
if ( annotations == null || annotations.isEmpty() || !isEntityObject( annotations ) ) {
return null;
}
@ -154,7 +158,7 @@ class AccessHelper implements JPADotNames {
return JandexHelper.getEnumValue(
annotationInstance,
"value",
JaxbAccessType.class,
AccessType.class,
indexBuilder.getServiceRegistry().getService( ClassLoaderService.class )
);
}
@ -171,7 +175,7 @@ class AccessHelper implements JPADotNames {
/**
* Get {@link javax.persistence.AccessType } from {@link javax.persistence.Access @Access} on the attribute of the given class
*/
static JaxbAccessType getAccessFromAttributeAnnotation(DotName className, String attributeName, IndexBuilder indexBuilder) {
static AccessType getAccessFromAttributeAnnotation(DotName className, String attributeName, IndexBuilder indexBuilder) {
Map<DotName, List<AnnotationInstance>> indexedAnnotations = indexBuilder.getIndexedAnnotations( className );
if ( indexedAnnotations != null && indexedAnnotations.containsKey( ACCESS ) ) {
List<AnnotationInstance> annotationInstances = indexedAnnotations.get( ACCESS );
@ -182,16 +186,16 @@ class AccessHelper implements JPADotNames {
continue;
}
if ( JandexHelper.getPropertyName( indexedPropertyTarget ).equals( attributeName ) ) {
JaxbAccessType accessType = JandexHelper.getEnumValue(
AccessType accessType = JandexHelper.getEnumValue(
annotationInstance,
"value",
JaxbAccessType.class,
AccessType.class,
indexBuilder.getServiceRegistry().getService( ClassLoaderService.class )
);
/**
* here we ignore @Access(FIELD) on property (getter) and @Access(PROPERTY) on field
*/
JaxbAccessType targetAccessType = annotationTargetToAccessType( indexedPropertyTarget );
AccessType targetAccessType = annotationTargetToAccessType( indexedPropertyTarget );
if ( accessType.equals( targetAccessType ) ) {
return targetAccessType;
}

View File

@ -21,37 +21,37 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.persistence.EnumType;
import javax.persistence.TemporalType;
import org.hibernate.AssertionFailure;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAssociationOverride;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributeOverride;
import org.hibernate.metamodel.source.internal.jaxb.JaxbCollectionTable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbJoinTable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbLob;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOrderColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrimaryKeyJoinColumn;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
import org.hibernate.AssertionFailure;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAssociationOverride;
import org.hibernate.jaxb.spi.orm.JaxbAttributeOverride;
import org.hibernate.jaxb.spi.orm.JaxbCollectionTable;
import org.hibernate.jaxb.spi.orm.JaxbColumn;
import org.hibernate.jaxb.spi.orm.JaxbEnumType;
import org.hibernate.jaxb.spi.orm.JaxbJoinColumn;
import org.hibernate.jaxb.spi.orm.JaxbJoinTable;
import org.hibernate.jaxb.spi.orm.JaxbLob;
import org.hibernate.jaxb.spi.orm.JaxbOrderColumn;
import org.hibernate.jaxb.spi.orm.JaxbPrimaryKeyJoinColumn;
import org.hibernate.jaxb.spi.orm.JaxbTemporalType;
/**
* @author Strong Liu
*/
abstract class AnnotationMocker extends AbstractMocker {
public abstract class AnnotationMocker extends AbstractMocker {
private EntityMappingsMocker.Default defaults;
AnnotationMocker(IndexBuilder indexBuilder, EntityMappingsMocker.Default defaults) {
@ -209,14 +209,14 @@ abstract class AnnotationMocker extends AbstractMocker {
return create( LOB, target );
}
protected AnnotationInstance parseTemporalType(JaxbTemporalType temporalType, AnnotationTarget target) {
protected AnnotationInstance parseTemporalType(TemporalType temporalType, AnnotationTarget target) {
if ( temporalType == null ) {
return null;
}
return create( TEMPORAL, target, MockHelper.enumValueArray( "value", TEMPORAL_TYPE, temporalType ) );
}
protected AnnotationInstance parseEnumType(JaxbEnumType enumerated, AnnotationTarget target) {
protected AnnotationInstance parseEnumType(EnumType enumerated, AnnotationTarget target) {
if ( enumerated == null ) {
return null;
}

View File

@ -21,25 +21,31 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.List;
import javax.persistence.AccessType;
import org.hibernate.metamodel.source.internal.jaxb.AttributesContainer;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddedId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbVersion;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddedId;
import org.hibernate.jaxb.spi.orm.JaxbId;
import org.hibernate.jaxb.spi.orm.JaxbVersion;
/**
* @author Strong Liu
*/
class AttributesBuilder extends AbstractAttributesBuilder {
public class AttributesBuilder extends AbstractAttributesBuilder {
private final JaxbAttributes attributes;
AttributesBuilder(IndexBuilder indexBuilder, ClassInfo classInfo, JaxbAccessType accessType, EntityMappingsMocker.Default defaults, JaxbAttributes attributes) {
AttributesBuilder(
IndexBuilder indexBuilder,
ClassInfo classInfo,
AccessType accessType,
EntityMappingsMocker.Default defaults,
JaxbAttributes attributes) {
super( indexBuilder, classInfo, defaults );
this.attributes = attributes;
}

View File

@ -21,20 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbBasic;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbBasic;
/**
* @author Strong Liu
*/
class BasicMocker extends PropertyMocker {
public class BasicMocker extends PropertyMocker {
private final JaxbBasic basic;
BasicMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbBasic basic) {
@ -43,9 +44,10 @@ class BasicMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return basic;
}
@Override
protected void processExtra() {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();

View File

@ -21,34 +21,36 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.source.internal.jandex.filter.IndexedAnnotationFilter;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTable;
import org.hibernate.metamodel.source.internal.jaxb.ManagedType;
import org.hibernate.metamodel.source.internal.jaxb.SchemaAware;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbTable;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.util.JandexHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.filter.IndexedAnnotationFilter;
/**
* @author Strong Liu
*/
class DefaultConfigurationHelper {
public class DefaultConfigurationHelper {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
DefaultConfigurationHelper.class.getName()
);
static final DefaultConfigurationHelper INSTANCE = new DefaultConfigurationHelper();
public static final DefaultConfigurationHelper INSTANCE = new DefaultConfigurationHelper();
static final DotName[] GLOBAL_ANNOTATIONS = new DotName[] {
JPADotNames.SEQUENCE_GENERATOR,
JPADotNames.TABLE_GENERATOR,
@ -75,7 +77,7 @@ class DefaultConfigurationHelper {
private DefaultConfigurationHelper() {
}
void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) {
public void applyDefaults(SchemaAware schemaAware, EntityMappingsMocker.Default defaults) {
if ( hasSchemaOrCatalogDefined( defaults ) ) {
if ( StringHelper.isEmpty( schemaAware.getSchema() ) ) {
schemaAware.setSchema( defaults.getSchema() );
@ -86,7 +88,7 @@ class DefaultConfigurationHelper {
}
}
void applyDefaults(Map<DotName, List<AnnotationInstance>> annotationsMap, EntityMappingsMocker.Default defaults) {
public void applyDefaults(Map<DotName, List<AnnotationInstance>> annotationsMap, EntityMappingsMocker.Default defaults) {
if ( annotationsMap.isEmpty() || defaults == null ) {
return;
}
@ -98,7 +100,7 @@ class DefaultConfigurationHelper {
}
}
void applyDefaults(EntityElement entityElement, EntityMappingsMocker.Default defaults) {
public void applyDefaults(ManagedType entityElement, EntityMappingsMocker.Default defaults) {
if(JaxbEntity.class.isInstance( entityElement ))
mockTableIfNonExist( JaxbEntity.class.cast( entityElement ), defaults );
applyDefaultsToEntityObject( entityElement , defaults );
@ -114,7 +116,7 @@ class DefaultConfigurationHelper {
}
}
private void applyDefaultsToEntityObject(EntityElement entityObject, EntityMappingsMocker.Default defaults) {
private void applyDefaultsToEntityObject(ManagedType entityObject, EntityMappingsMocker.Default defaults) {
if ( defaults == null ) {
return;
}

View File

@ -21,20 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbElementCollection;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbElementCollection;
/**
* @author Strong Liu
*/
class ElementCollectionMocker extends PropertyMocker {
public class ElementCollectionMocker extends PropertyMocker {
private final JaxbElementCollection elementCollection;
ElementCollectionMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbElementCollection elementCollection) {
@ -43,7 +44,7 @@ class ElementCollectionMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return elementCollection;
}

View File

@ -21,26 +21,32 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.Collections;
import java.util.List;
import javax.persistence.AccessType;
import org.hibernate.metamodel.source.internal.jaxb.AttributesContainer;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddableAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddedId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbVersion;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddableAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddedId;
import org.hibernate.jaxb.spi.orm.JaxbId;
import org.hibernate.jaxb.spi.orm.JaxbVersion;
/**
* @author Strong Liu
*/
class EmbeddableAttributesBuilder extends AbstractAttributesBuilder {
public class EmbeddableAttributesBuilder extends AbstractAttributesBuilder {
private final JaxbEmbeddableAttributes attributes;
EmbeddableAttributesBuilder(IndexBuilder indexBuilder, ClassInfo classInfo, JaxbAccessType accessType, EntityMappingsMocker.Default defaults, JaxbEmbeddableAttributes embeddableAttributes) {
EmbeddableAttributesBuilder(
IndexBuilder indexBuilder,
ClassInfo classInfo,
AccessType accessType,
EntityMappingsMocker.Default defaults,
JaxbEmbeddableAttributes embeddableAttributes) {
super( indexBuilder, classInfo, defaults );
this.attributes = embeddableAttributes;
}
@ -49,6 +55,7 @@ class EmbeddableAttributesBuilder extends AbstractAttributesBuilder {
protected AttributesContainer getAttributesContainer() {
return attributes;
}
@Override
List<JaxbId> getId() {
return Collections.emptyList();
@ -58,6 +65,7 @@ class EmbeddableAttributesBuilder extends AbstractAttributesBuilder {
List<JaxbVersion> getVersion() {
return Collections.emptyList();
}
@Override
JaxbEmbeddedId getEmbeddedId() {
return null;

View File

@ -21,26 +21,27 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddable;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
import org.hibernate.jaxb.spi.orm.JaxbIdClass;
import org.hibernate.jaxb.spi.orm.JaxbPostLoad;
import org.hibernate.jaxb.spi.orm.JaxbPostPersist;
import org.hibernate.jaxb.spi.orm.JaxbPostRemove;
import org.hibernate.jaxb.spi.orm.JaxbPostUpdate;
import org.hibernate.jaxb.spi.orm.JaxbPrePersist;
import org.hibernate.jaxb.spi.orm.JaxbPreRemove;
import org.hibernate.jaxb.spi.orm.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostPersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrePersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.ManagedType;
/**
* Mock <embeddable> to {@link javax.persistence.Embeddable @Embeddable}
*
* @author Strong Liu
*/
class EmbeddableMocker extends AbstractEntityObjectMocker {
public class EmbeddableMocker extends AbstractEntityObjectMocker {
private final JaxbEmbeddable embeddable;
EmbeddableMocker(IndexBuilder indexBuilder, JaxbEmbeddable embeddable, EntityMappingsMocker.Default defaults) {
@ -59,7 +60,7 @@ class EmbeddableMocker extends AbstractEntityObjectMocker {
}
@Override
protected EntityElement getEntityElement() {
protected ManagedType getEntityElement() {
return embeddable;
}

View File

@ -21,16 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddedId;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddedId;
/**
* @author Strong Liu
*/
class EmbeddedIdMocker extends PropertyMocker {
public class EmbeddedIdMocker extends PropertyMocker {
private final JaxbEmbeddedId embeddedId;
EmbeddedIdMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbEmbeddedId embeddedId) {
@ -39,7 +40,7 @@ class EmbeddedIdMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return embeddedId;
}

View File

@ -21,16 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbedded;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbEmbedded;
/**
* @author Strong Liu
*/
class EmbeddedMocker extends PropertyMocker {
public class EmbeddedMocker extends PropertyMocker {
private final JaxbEmbedded embedded;
EmbeddedMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbEmbedded embedded) {
@ -47,7 +48,7 @@ class EmbeddedMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return embedded;
}
}

View File

@ -21,37 +21,40 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.AccessType;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEmbeddable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMappedSuperclass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitDefaults;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitMetadata;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.xml.spi.BindResult;
import org.hibernate.xml.spi.Origin;
import org.hibernate.xml.spi.SourceType;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbEmbeddable;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.jaxb.spi.orm.JaxbMappedSuperclass;
import org.hibernate.jaxb.spi.orm.JaxbPersistenceUnitDefaults;
import org.hibernate.jaxb.spi.orm.JaxbPersistenceUnitMetadata;
import org.hibernate.service.ServiceRegistry;
/**
* Parse all {@link org.hibernate.jaxb.spi.orm.JaxbEntityMappings} generated from orm.xml.
* Parse all {@link org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings} generated from orm.xml.
*
* @author Strong Liu
*/
@Deprecated
public class EntityMappingsMocker {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
EntityMappingsMocker.class.getName()
);
private final List<JaxbEntityMappings> entityMappingsList;
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( EntityMappingsMocker.class );
private final List<BindResult<JaxbEntityMappings>> xmlBindings;
/**
* Default configuration defined in Persistence Metadata Unit, one or zero per Persistence Unit.
*/
@ -59,21 +62,45 @@ public class EntityMappingsMocker {
private final IndexBuilder indexBuilder;
private final GlobalAnnotations globalAnnotations;
public EntityMappingsMocker(List<JaxbEntityMappings> entityMappingsList, IndexView index, ServiceRegistry serviceRegistry) {
this.entityMappingsList = entityMappingsList;
public EntityMappingsMocker(List<BindResult<JaxbEntityMappings>> xmlBindings, IndexView index, ServiceRegistry serviceRegistry) {
this.xmlBindings = xmlBindings;
this.indexBuilder = new IndexBuilder( index, serviceRegistry );
this.globalAnnotations = new GlobalAnnotations();
}
public EntityMappingsMocker(
List<JaxbEntityMappings> xmlEntityMappingsList,
Index index,
ServiceRegistry serviceRegistry) {
this(
grabJaxbEntityMappings( xmlEntityMappingsList ),
index,
serviceRegistry
);
}
private static List<BindResult<JaxbEntityMappings>> grabJaxbEntityMappings(List<JaxbEntityMappings> xmlEntityMappingsList) {
final List<BindResult<JaxbEntityMappings>> result = new ArrayList<BindResult<JaxbEntityMappings>>();
for ( JaxbEntityMappings binding : xmlEntityMappingsList ) {
result.add(
new BindResult<JaxbEntityMappings>(
binding,
new Origin( SourceType.OTHER, Origin.UNKNOWN_FILE_PATH )
)
);
}
return result;
}
/**
* Create new {@link Index} with mocking JPA annotations from {@link org.hibernate.jaxb.spi.orm.JaxbEntityMappings}
* Create new {@link Index} with mocking JPA annotations from {@link org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings}
* and merge them with existing {@link Index}
*
* @return new {@link Index}
*/
public Index mockNewIndex() {
processPersistenceUnitMetadata( entityMappingsList );
processEntityMappings( entityMappingsList );
processPersistenceUnitMetadata( xmlBindings );
processEntityMappings( xmlBindings );
processGlobalAnnotations();
return indexBuilder.build( globalDefaults );
}
@ -81,10 +108,10 @@ public class EntityMappingsMocker {
/**
* processing PersistenceUnitMetadata, there should be only one PersistenceUnitMetadata in all mapping xml files.
*/
private void processPersistenceUnitMetadata(List<JaxbEntityMappings> entityMappingsList) {
for ( JaxbEntityMappings entityMappings : entityMappingsList ) {
private void processPersistenceUnitMetadata(List<BindResult<JaxbEntityMappings>> xmlBindings) {
for ( BindResult<JaxbEntityMappings> xmlBinding : xmlBindings ) {
//we have to iterate entityMappingsList first to find persistence-unit-metadata
JaxbPersistenceUnitMetadata pum = entityMappings.getPersistenceUnitMetadata();
JaxbPersistenceUnitMetadata pum = xmlBinding.getRoot().getPersistenceUnitMetadata();
if ( globalDefaults != null ) {
LOG.duplicateMetadata();
return;
@ -110,24 +137,24 @@ public class EntityMappingsMocker {
}
private void processEntityMappings(List<JaxbEntityMappings> entityMappingsList) {
private void processEntityMappings(List<BindResult<JaxbEntityMappings>> xmlBindings) {
List<AbstractEntityObjectMocker> mockerList = new ArrayList<AbstractEntityObjectMocker>();
for ( JaxbEntityMappings entityMappings : entityMappingsList ) {
final Default defaults = getEntityMappingsDefaults( entityMappings );
globalAnnotations.collectGlobalMappings( entityMappings, defaults );
for ( JaxbMappedSuperclass mappedSuperclass : entityMappings.getMappedSuperclass() ) {
for ( BindResult<JaxbEntityMappings> xmlBinding : xmlBindings ) {
final Default defaults = getEntityMappingsDefaults( xmlBinding.getRoot() );
globalAnnotations.collectGlobalMappings( xmlBinding.getRoot(), defaults );
for ( JaxbMappedSuperclass mappedSuperclass : xmlBinding.getRoot().getMappedSuperclass() ) {
AbstractEntityObjectMocker mocker =
new MappedSuperclassMocker( indexBuilder, mappedSuperclass, defaults );
mockerList.add( mocker );
mocker.preProcess();
}
for ( JaxbEmbeddable embeddable : entityMappings.getEmbeddable() ) {
for ( JaxbEmbeddable embeddable : xmlBinding.getRoot().getEmbeddable() ) {
AbstractEntityObjectMocker mocker =
new EmbeddableMocker( indexBuilder, embeddable, defaults );
mockerList.add( mocker );
mocker.preProcess();
}
for ( JaxbEntity entity : entityMappings.getEntity() ) {
for ( JaxbEntity entity : xmlBinding.getRoot().getEntity() ) {
globalAnnotations.collectGlobalMappings( entity, defaults );
AbstractEntityObjectMocker mocker =
new EntityMocker( indexBuilder, entity, defaults );
@ -163,18 +190,18 @@ public class EntityMappingsMocker {
public static class Default implements Serializable {
private JaxbAccessType access;
private AccessType access;
private String packageName;
private String schema;
private String catalog;
private Boolean metadataComplete;
private Boolean cascadePersist;
public JaxbAccessType getAccess() {
public AccessType getAccess() {
return access;
}
void setAccess(JaxbAccessType access) {
public void setAccess(AccessType access) {
this.access = access;
}
@ -182,7 +209,7 @@ public class EntityMappingsMocker {
return catalog;
}
void setCatalog(String catalog) {
public void setCatalog(String catalog) {
this.catalog = catalog;
}
@ -190,7 +217,7 @@ public class EntityMappingsMocker {
return packageName;
}
void setPackageName(String packageName) {
public void setPackageName(String packageName) {
this.packageName = packageName;
}
@ -198,7 +225,7 @@ public class EntityMappingsMocker {
return schema;
}
void setSchema(String schema) {
public void setSchema(String schema) {
this.schema = schema;
}
@ -206,7 +233,7 @@ public class EntityMappingsMocker {
return metadataComplete;
}
void setMetadataComplete(Boolean metadataComplete) {
public void setMetadataComplete(Boolean metadataComplete) {
this.metadataComplete = metadataComplete;
}
@ -214,7 +241,7 @@ public class EntityMappingsMocker {
return cascadePersist;
}
void setCascadePersist(Boolean cascadePersist) {
public void setCascadePersist(Boolean cascadePersist) {
this.cascadePersist = cascadePersist;
}

View File

@ -21,46 +21,47 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import javax.persistence.AccessType;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbDiscriminatorColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbInheritance;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostPersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrePersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSecondaryTable;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTable;
import org.hibernate.metamodel.source.internal.jaxb.ManagedType;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbDiscriminatorColumn;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
import org.hibernate.jaxb.spi.orm.JaxbIdClass;
import org.hibernate.jaxb.spi.orm.JaxbInheritance;
import org.hibernate.jaxb.spi.orm.JaxbPostLoad;
import org.hibernate.jaxb.spi.orm.JaxbPostPersist;
import org.hibernate.jaxb.spi.orm.JaxbPostRemove;
import org.hibernate.jaxb.spi.orm.JaxbPostUpdate;
import org.hibernate.jaxb.spi.orm.JaxbPrePersist;
import org.hibernate.jaxb.spi.orm.JaxbPreRemove;
import org.hibernate.jaxb.spi.orm.JaxbPreUpdate;
import org.hibernate.jaxb.spi.orm.JaxbSecondaryTable;
import org.hibernate.jaxb.spi.orm.JaxbTable;
/**
* Mock <entity> to {@link javax.persistence.Entity @Entity}
*
* @author Strong Liu
*/
class EntityMocker extends AbstractEntityObjectMocker {
public class EntityMocker extends AbstractEntityObjectMocker {
private final JaxbEntity entity;
EntityMocker(IndexBuilder indexBuilder, JaxbEntity entity, EntityMappingsMocker.Default defaults) {
public EntityMocker(IndexBuilder indexBuilder, JaxbEntity entity, EntityMappingsMocker.Default defaults) {
super( indexBuilder, defaults );
this.entity = entity;
}
@ -115,7 +116,7 @@ class EntityMocker extends AbstractEntityObjectMocker {
protected AccessType getDefaultAccess() {
if ( entity.getAccess() != null ) {
return AccessType.valueOf( entity.getAccess().value() );
return entity.getAccess();
}
return null;
@ -139,7 +140,7 @@ class EntityMocker extends AbstractEntityObjectMocker {
}
@Override
protected EntityElement getEntityElement() {
protected ManagedType getEntityElement() {
return entity;
}

View File

@ -21,31 +21,30 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;
import java.util.List;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbQueryHint;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSequenceGenerator;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingColumnResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingEntityResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMappingFieldResult;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbColumnResult;
import org.hibernate.jaxb.spi.orm.JaxbEntityResult;
import org.hibernate.jaxb.spi.orm.JaxbFieldResult;
import org.hibernate.jaxb.spi.orm.JaxbNamedNativeQuery;
import org.hibernate.jaxb.spi.orm.JaxbNamedQuery;
import org.hibernate.jaxb.spi.orm.JaxbQueryHint;
import org.hibernate.jaxb.spi.orm.JaxbSequenceGenerator;
import org.hibernate.jaxb.spi.orm.JaxbSqlResultSetMapping;
import org.hibernate.jaxb.spi.orm.JaxbTableGenerator;
/**
* @author Strong Liu
*/
class GlobalAnnotationMocker extends AbstractMocker {
public class GlobalAnnotationMocker extends AbstractMocker {
private GlobalAnnotations globalAnnotations;
GlobalAnnotationMocker(IndexBuilder indexBuilder, GlobalAnnotations globalAnnotations) {
@ -92,8 +91,8 @@ class GlobalAnnotationMocker extends AbstractMocker {
private AnnotationInstance parseSqlResultSetMappings(Collection<JaxbSqlResultSetMapping> namedQueries) {
AnnotationValue[] values = new AnnotationValue[namedQueries.size()];
int i = 0;
for ( Iterator<JaxbSqlResultSetMapping> iterator = namedQueries.iterator(); iterator.hasNext(); ) {
AnnotationInstance annotationInstance = parseSqlResultSetMapping( iterator.next() );
for ( JaxbSqlResultSetMapping namedQuery : namedQueries ) {
AnnotationInstance annotationInstance = parseSqlResultSetMapping( namedQuery );
values[i++] = MockHelper.nestedAnnotationValue(
"", annotationInstance
);
@ -108,21 +107,16 @@ class GlobalAnnotationMocker extends AbstractMocker {
//@SqlResultSetMapping
private AnnotationInstance parseSqlResultSetMapping(JaxbSqlResultSetMapping mapping) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.stringValue( "name", mapping.getName(), annotationValueList );
nestedEntityResultList( "entities", mapping.getEntityResult(), annotationValueList );
nestedColumnResultList( "columns", mapping.getColumnResult(), annotationValueList );
return
create(
SQL_RESULT_SET_MAPPING, null, annotationValueList
);
return create( SQL_RESULT_SET_MAPPING, null, annotationValueList );
}
//@EntityResult
private AnnotationInstance parseEntityResult(JaxbEntityResult result) {
private AnnotationInstance parseEntityResult(JaxbSqlResultSetMappingEntityResult result) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.stringValue(
@ -139,7 +133,7 @@ class GlobalAnnotationMocker extends AbstractMocker {
);
}
private void nestedEntityResultList(String name, List<JaxbEntityResult> entityResults, List<AnnotationValue> annotationValueList) {
private void nestedEntityResultList(String name, List<JaxbSqlResultSetMappingEntityResult> entityResults, List<AnnotationValue> annotationValueList) {
if ( CollectionHelper.isNotEmpty( entityResults ) ) {
AnnotationValue[] values = new AnnotationValue[entityResults.size()];
for ( int i = 0; i < entityResults.size(); i++ ) {
@ -155,11 +149,11 @@ class GlobalAnnotationMocker extends AbstractMocker {
}
//@ColumnResult
private AnnotationInstance parseColumnResult(JaxbColumnResult result) {
private AnnotationInstance parseColumnResult(JaxbSqlResultSetMappingColumnResult result) {
return create( COLUMN_RESULT, null, MockHelper.stringValueArray( "name", result.getName() ) );
}
private void nestedColumnResultList(String name, List<JaxbColumnResult> columnResults, List<AnnotationValue> annotationValueList) {
private void nestedColumnResultList(String name, List<JaxbSqlResultSetMappingColumnResult> columnResults, List<AnnotationValue> annotationValueList) {
if ( CollectionHelper.isNotEmpty( columnResults ) ) {
AnnotationValue[] values = new AnnotationValue[columnResults.size()];
for ( int i = 0; i < columnResults.size(); i++ ) {
@ -175,7 +169,7 @@ class GlobalAnnotationMocker extends AbstractMocker {
}
//@FieldResult
private AnnotationInstance parseFieldResult(JaxbFieldResult result) {
private AnnotationInstance parseFieldResult(JaxbSqlResultSetMappingFieldResult result) {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();
MockHelper.stringValue( "name", result.getName(), annotationValueList );
MockHelper.stringValue( "column", result.getColumn(), annotationValueList );
@ -183,7 +177,7 @@ class GlobalAnnotationMocker extends AbstractMocker {
}
private void nestedFieldResultList(String name, List<JaxbFieldResult> fieldResultList, List<AnnotationValue> annotationValueList) {
private void nestedFieldResultList(String name, List<JaxbSqlResultSetMappingFieldResult> fieldResultList, List<AnnotationValue> annotationValueList) {
if ( CollectionHelper.isNotEmpty( fieldResultList ) ) {
AnnotationValue[] values = new AnnotationValue[fieldResultList.size()];
for ( int i = 0; i < fieldResultList.size(); i++ ) {
@ -201,8 +195,8 @@ class GlobalAnnotationMocker extends AbstractMocker {
private AnnotationInstance parseNamedNativeQueries(Collection<JaxbNamedNativeQuery> namedQueries) {
AnnotationValue[] values = new AnnotationValue[namedQueries.size()];
int i = 0;
for ( Iterator<JaxbNamedNativeQuery> iterator = namedQueries.iterator(); iterator.hasNext(); ) {
AnnotationInstance annotationInstance = parseNamedNativeQuery( iterator.next() );
for ( JaxbNamedNativeQuery namedQuery : namedQueries ) {
AnnotationInstance annotationInstance = parseNamedNativeQuery( namedQuery );
values[i++] = MockHelper.nestedAnnotationValue(
"", annotationInstance
);
@ -237,8 +231,8 @@ class GlobalAnnotationMocker extends AbstractMocker {
private AnnotationInstance parseNamedQueries(Collection<JaxbNamedQuery> namedQueries) {
AnnotationValue[] values = new AnnotationValue[namedQueries.size()];
int i = 0;
for ( Iterator<JaxbNamedQuery> iterator = namedQueries.iterator(); iterator.hasNext(); ) {
AnnotationInstance annotationInstance = parseNamedQuery( iterator.next() );
for ( JaxbNamedQuery namedQuery : namedQueries ) {
AnnotationInstance annotationInstance = parseNamedQuery( namedQuery );
values[i++] = MockHelper.nestedAnnotationValue(
"", annotationInstance
);

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.Collection;
@ -31,34 +31,33 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.jaxb.spi.orm.JaxbId;
import org.hibernate.jaxb.spi.orm.JaxbNamedNativeQuery;
import org.hibernate.jaxb.spi.orm.JaxbNamedQuery;
import org.hibernate.jaxb.spi.orm.JaxbSequenceGenerator;
import org.hibernate.jaxb.spi.orm.JaxbSqlResultSetMapping;
import org.hibernate.jaxb.spi.orm.JaxbTableGenerator;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedNativeQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbNamedQuery;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSequenceGenerator;
import org.hibernate.metamodel.source.internal.jaxb.JaxbSqlResultSetMapping;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTableGenerator;
import org.hibernate.metamodel.source.internal.jaxb.SchemaAware;
import org.hibernate.metamodel.spi.source.MappingException;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.DotName;
/**
* @author Strong Liu
*/
class GlobalAnnotations implements JPADotNames {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
GlobalAnnotations.class.getName()
);
public class GlobalAnnotations implements JPADotNames {
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( GlobalAnnotations.class );
private final Map<String, JaxbSequenceGenerator> sequenceGeneratorMap = new HashMap<String, JaxbSequenceGenerator>();
private final Map<String, JaxbTableGenerator> tableGeneratorMap = new HashMap<String, JaxbTableGenerator>();
private final Map<String, JaxbNamedQuery> namedQueryMap = new HashMap<String, JaxbNamedQuery>();

View File

@ -21,23 +21,24 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbGeneratedValue;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbGeneratedValue;
import org.hibernate.jaxb.spi.orm.JaxbId;
/**
* @author Strong Liu
*/
class IdMocker extends PropertyMocker {
public class IdMocker extends PropertyMocker {
private final JaxbId id;
IdMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbId id) {
@ -46,7 +47,7 @@ class IdMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return id;
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.Collection;
@ -30,40 +30,39 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.jandex.filter.IndexedAnnotationFilter;
import org.hibernate.service.ServiceRegistry;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.jandex.IndexView;
import org.jboss.logging.Logger;
import org.hibernate.AssertionFailure;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.boot.registry.classloading.spi.ClassLoadingException;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.internal.source.annotations.xml.filter.IndexedAnnotationFilter;
import org.hibernate.service.ServiceRegistry;
/**
* @author Strong Liu
*/
public class IndexBuilder {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
IndexBuilder.class.getName()
);
private static final CoreMessageLogger LOG = CoreLogging.messageLogger( IndexBuilder.class );
private IndexView index;
private final ServiceRegistry serviceRegistry;
private final Map<DotName, List<AnnotationInstance>> annotations;
private final Map<DotName, List<ClassInfo>> subclasses;
private final Map<DotName, List<ClassInfo>> implementors;
private final Map<DotName, ClassInfo> classes;
private IndexView index;
private final Map<DotName, Map<DotName, List<AnnotationInstance>>> classInfoAnnotationsMap;
private final Map<DotName, Map<DotName, List<AnnotationInstance>>> indexedClassInfoAnnotationsMap;
private final ServiceRegistry serviceRegistry;
IndexBuilder(IndexView index, ServiceRegistry serviceRegistry) {
public IndexBuilder(IndexView index, ServiceRegistry serviceRegistry) {
this.index = index;
this.serviceRegistry = serviceRegistry;
this.annotations = new HashMap<DotName, List<AnnotationInstance>>();
@ -82,7 +81,7 @@ public class IndexBuilder {
*
* @return Index.
*/
Index build(EntityMappingsMocker.Default globalDefaults) {
public Index build(EntityMappingsMocker.Default globalDefaults) {
//merge annotations that not overrided by xml into the new Index
for ( ClassInfo ci : index.getKnownClasses() ) {
DotName name = ci.name();

View File

@ -21,28 +21,29 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.MappingException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListener;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners;
import org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.MappingException;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.jaxb.spi.orm.JaxbEntityListener;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
/**
* {@link javax.persistence.EntityListeners @EntityListeners} mocker
*
* @author Strong Liu
*/
class ListenerMocker extends AbstractMocker {
public class ListenerMocker extends AbstractMocker {
private final ClassInfo classInfo;
ListenerMocker(IndexBuilder indexBuilder, ClassInfo classInfo) {
@ -86,7 +87,7 @@ class ListenerMocker extends AbstractMocker {
protected ListenerMocker createListenerMocker(IndexBuilder indexBuilder, ClassInfo classInfo) {
return new ListenerMocker( indexBuilder, classInfo );
}
AnnotationInstance parse(Listener callback, DotName target) {
AnnotationInstance parse(LifecycleCallback callback, DotName target) {
if ( callback == null ) {
return null;
}

View File

@ -21,28 +21,30 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToMany;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbManyToMany;
/**
* @author Strong Liu
*/
class ManyToManyMocker extends PropertyMocker {
public class ManyToManyMocker extends PropertyMocker {
private final JaxbManyToMany manyToMany;
ManyToManyMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbManyToMany manyToMany) {
super( indexBuilder, classInfo, defaults );
this.manyToMany = manyToMany;
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return manyToMany;
}

View File

@ -21,20 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbManyToOne;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbManyToOne;
/**
* @author Strong Liu
*/
class ManyToOneMocker extends PropertyMocker {
public class ManyToOneMocker extends PropertyMocker {
private final JaxbManyToOne manyToOne;
ManyToOneMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbManyToOne manyToOne) {
@ -43,7 +44,7 @@ class ManyToOneMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return manyToOne;
}

View File

@ -21,33 +21,27 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import org.jboss.logging.Logger;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEntityListeners;
import org.hibernate.jaxb.spi.orm.JaxbIdClass;
import org.hibernate.jaxb.spi.orm.JaxbMappedSuperclass;
import org.hibernate.jaxb.spi.orm.JaxbPostLoad;
import org.hibernate.jaxb.spi.orm.JaxbPostPersist;
import org.hibernate.jaxb.spi.orm.JaxbPostRemove;
import org.hibernate.jaxb.spi.orm.JaxbPostUpdate;
import org.hibernate.jaxb.spi.orm.JaxbPrePersist;
import org.hibernate.jaxb.spi.orm.JaxbPreRemove;
import org.hibernate.jaxb.spi.orm.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityListeners;
import org.hibernate.metamodel.source.internal.jaxb.JaxbIdClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMappedSuperclass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostLoad;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostPersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPostUpdate;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPrePersist;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreRemove;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPreUpdate;
import org.hibernate.metamodel.source.internal.jaxb.ManagedType;
/**
* Mock <mapped-superclass> to {@link javax.persistence.MappedSuperclass @MappedSuperClass}
*
* @author Strong Liu
*/
class MappedSuperclassMocker extends AbstractEntityObjectMocker {
private static final CoreMessageLogger LOG = Logger.getMessageLogger(
CoreMessageLogger.class,
MappedSuperclassMocker.class.getName()
);
public class MappedSuperclassMocker extends AbstractEntityObjectMocker {
private JaxbMappedSuperclass mappedSuperclass;
MappedSuperclassMocker(IndexBuilder indexBuilder, JaxbMappedSuperclass mappedSuperclass, EntityMappingsMocker.Default defaults) {
@ -56,7 +50,7 @@ class MappedSuperclassMocker extends AbstractEntityObjectMocker {
}
@Override
protected EntityElement getEntityElement() {
protected ManagedType getEntityElement() {
return mappedSuperclass;
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.beans.Introspector;
import java.lang.reflect.Field;
@ -31,6 +31,14 @@ import java.util.Collection;
import java.util.List;
import javax.persistence.CascadeType;
import org.hibernate.HibernateException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jaxb.JaxbCascadeType;
import org.hibernate.service.ServiceRegistry;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
@ -40,14 +48,6 @@ import org.jboss.jandex.FieldInfo;
import org.jboss.jandex.MethodInfo;
import org.jboss.jandex.Type;
import org.hibernate.HibernateException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbCascadeType;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.service.ServiceRegistry;
/**
* @author Strong Liu
*/

View File

@ -21,20 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToMany;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbOneToMany;
/**
* @author Strong Liu
*/
class OneToManyMocker extends PropertyMocker {
public class OneToManyMocker extends PropertyMocker {
private final JaxbOneToMany oneToMany;
OneToManyMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbOneToMany oneToMany) {
@ -43,9 +44,10 @@ class OneToManyMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return oneToMany;
}
@Override
protected void processExtra() {
List<AnnotationValue> annotationValueList = new ArrayList<AnnotationValue>();

View File

@ -21,20 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import org.hibernate.metamodel.source.internal.jaxb.JaxbOneToOne;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbOneToOne;
/**
* @author Strong Liu
*/
class OneToOneMocker extends PropertyMocker {
public class OneToOneMocker extends PropertyMocker {
private JaxbOneToOne oneToOne;
OneToOneMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbOneToOne oneToOne) {
@ -43,7 +44,7 @@ class OneToOneMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return oneToOne;
}

View File

@ -1,21 +1,20 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.HashMap;
import java.util.Map;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitDefaults;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.jaxb.spi.orm.JaxbPersistenceUnitDefaults;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
/**
* @author Strong Liu
*/
class PersistenceMetadataMocker extends AbstractMocker {
public class PersistenceMetadataMocker extends AbstractMocker {
private final JaxbPersistenceUnitDefaults persistenceUnitDefaults;
private final GlobalAnnotations globalAnnotations = new GlobalAnnotations();
/**

View File

@ -21,10 +21,21 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.AccessType;
import javax.persistence.EnumType;
import javax.persistence.TemporalType;
import org.hibernate.HibernateException;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKey;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyClass;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyColumn;
import org.hibernate.metamodel.source.internal.jaxb.JaxbMapKeyJoinColumn;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
@ -32,20 +43,10 @@ import org.jboss.jandex.AnnotationValue;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.hibernate.HibernateException;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbEnumType;
import org.hibernate.jaxb.spi.orm.JaxbMapKey;
import org.hibernate.jaxb.spi.orm.JaxbMapKeyClass;
import org.hibernate.jaxb.spi.orm.JaxbMapKeyColumn;
import org.hibernate.jaxb.spi.orm.JaxbMapKeyJoinColumn;
import org.hibernate.jaxb.spi.orm.JaxbTemporalType;
/**
* @author Strong Liu
*/
abstract class PropertyMocker extends AnnotationMocker {
public abstract class PropertyMocker extends AnnotationMocker {
protected ClassInfo classInfo;
private AnnotationTarget target;
@ -53,7 +54,8 @@ abstract class PropertyMocker extends AnnotationMocker {
super( indexBuilder, defaults );
this.classInfo = classInfo;
}
protected abstract PropertyElement getPropertyElement();
protected abstract PersistentAttribute getPersistentAttribute();
protected abstract void processExtra();
@Override
@ -63,10 +65,10 @@ abstract class PropertyMocker extends AnnotationMocker {
protected void resolveTarget() {
//attribute in orm.xml has access sub-element
JaxbAccessType accessType = getPropertyElement().getAccess();
AccessType accessType = getPersistentAttribute().getAccess();
if ( accessType == null ) {
//attribute in the entity class has @Access
accessType = AccessHelper.getAccessFromAttributeAnnotation( getTargetName(), getPropertyElement().getName(), indexBuilder );
accessType = AccessHelper.getAccessFromAttributeAnnotation( getTargetName(), getPersistentAttribute().getName(), indexBuilder );
if ( accessType == null ) {
accessType = AccessHelper.getEntityAccess( getTargetName(), indexBuilder );
}
@ -78,10 +80,10 @@ abstract class PropertyMocker extends AnnotationMocker {
accessType = AccessHelper.getAccessFromDefault( indexBuilder );
}
if ( accessType == null ) {
accessType = JaxbAccessType.PROPERTY;
accessType = AccessType.PROPERTY;
}
getPropertyElement().setAccess( accessType );
getPersistentAttribute().setAccess( accessType );
}
}
@ -89,12 +91,12 @@ abstract class PropertyMocker extends AnnotationMocker {
@Override
protected AnnotationTarget getTarget() {
if ( target == null ) {
target = getTargetFromAttributeAccessType( getPropertyElement().getAccess() );
target = getTargetFromAttributeAccessType( getPersistentAttribute().getAccess() );
}
return target;
}
protected AnnotationTarget getTargetFromAttributeAccessType(JaxbAccessType accessType) {
protected AnnotationTarget getTargetFromAttributeAccessType(AccessType accessType) {
if ( accessType == null ) {
throw new IllegalArgumentException( "access type can't be null." );
}
@ -103,14 +105,14 @@ abstract class PropertyMocker extends AnnotationMocker {
return MockHelper.getTarget(
indexBuilder.getServiceRegistry(),
classInfo,
getPropertyElement().getName(),
getPersistentAttribute().getName(),
MockHelper.TargetType.FIELD
);
case PROPERTY:
return MockHelper.getTarget(
indexBuilder.getServiceRegistry(),
classInfo,
getPropertyElement().getName(),
getPersistentAttribute().getName(),
MockHelper.TargetType.PROPERTY
);
default:
@ -154,7 +156,7 @@ abstract class PropertyMocker extends AnnotationMocker {
);
}
protected AnnotationInstance parseMapKeyTemporal(JaxbTemporalType temporalType, AnnotationTarget target) {
protected AnnotationInstance parseMapKeyTemporal(TemporalType temporalType, AnnotationTarget target) {
if ( temporalType == null ) {
return null;
}
@ -164,7 +166,7 @@ abstract class PropertyMocker extends AnnotationMocker {
);
}
protected AnnotationInstance parseMapKeyEnumerated(JaxbEnumType enumType, AnnotationTarget target) {
protected AnnotationInstance parseMapKeyEnumerated(EnumType enumType, AnnotationTarget target) {
if ( enumType == null ) {
return null;
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml;
package org.hibernate.metamodel.source.internal.jandex;
import org.jboss.jandex.DotName;

View File

@ -21,36 +21,48 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import javax.persistence.AccessType;
import org.hibernate.metamodel.source.internal.jaxb.JaxbTransient;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbAccessType;
import org.hibernate.jaxb.spi.orm.JaxbTransient;
/**
* @author Strong Liu
*/
class TransientMocker extends PropertyMocker {
public class TransientMocker extends PropertyMocker {
private final JaxbTransient transientObj;
private final PropertyElement wrapper;
private final PersistentAttribute wrapper;
TransientMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, final JaxbTransient transientObj) {
super( indexBuilder, classInfo, defaults );
this.transientObj = transientObj;
this.wrapper = new PropertyElement() {
this.wrapper = new PersistentAttribute() {
@Override
public String getName() {
return transientObj.getName();
}
@Override
public JaxbAccessType getAccess() {
return JaxbAccessType.FIELD;
public AccessType getAccess() {
return AccessType.FIELD;
}
@Override
public void setAccess(JaxbAccessType accessType) {
public void setAccess(AccessType accessType) {
}
@Override
public String getCustomAccess() {
return null;
}
@Override
public void setCustomAccess(String customAccess) {
}
};
}
@ -61,7 +73,7 @@ class TransientMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return wrapper;
}
}

View File

@ -0,0 +1,85 @@
/*
* 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.jandex;
import java.util.List;
import org.hibernate.internal.CoreLogging;
import org.hibernate.internal.CoreMessageLogger;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbPersistenceUnitMetadata;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.xml.spi.BindResult;
import org.jboss.jandex.IndexView;
/**
* Responsible for consolidating mapping information supplied by annotations and mapping information
* supplied by XML into a unified view.
* <p/>
* Ultimately we are building a Jandex {@link org.jboss.jandex.IndexView} which is a de-typed (and
* classloading safe!) representation of annotations. We add virtual annotation information into the
* Jandex to represent XML supplied information.
*
* @author Steve Ebersole
* @author Strong Liu
*/
public class Unifier {
private static final CoreMessageLogger log = CoreLogging.messageLogger( Unifier.class );
// todo : per Jason, it is bad if we create a CompositeIndex where multiple of the aggregated indexes contain the same classes.
public static IndexView unify(
IndexView initialJandex,
List<BindResult<JaxbEntityMappings>> xmlBindings,
ServiceRegistry serviceRegistry) {
if ( xmlBindings == null || xmlBindings.isEmpty() ) {
// if there is no XML information, just return the original index
return initialJandex;
}
JaxbPersistenceUnitMetadata persistenceUnitMetadata = null;
for ( BindResult<JaxbEntityMappings> xmlBinding : xmlBindings ) {
if ( xmlBinding.getRoot().getPersistenceUnitMetadata() != null ) {
if ( persistenceUnitMetadata == null ) {
log.debugf( "Using <persistence-unit-metadata/> located in %s", xmlBinding.getOrigin() );
persistenceUnitMetadata = xmlBinding.getRoot().getPersistenceUnitMetadata();
}
else {
// todo : parameterize duplicateMetadata() to accept the origin
log.duplicateMetadata();
log.debugf(
"Encountered <persistence-unit-metadata/> in %s after previously " +
"encountered one; keeping original",
xmlBinding.getOrigin()
);
}
}
}
// for now, simply hook into the existing code...
return new EntityMappingsMocker( xmlBindings, initialJandex, serviceRegistry ).mockNewIndex();
}
}

View File

@ -21,16 +21,17 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
package org.hibernate.metamodel.source.internal.jandex;
import org.hibernate.metamodel.source.internal.jaxb.JaxbVersion;
import org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute;
import org.jboss.jandex.ClassInfo;
import org.hibernate.jaxb.spi.orm.JaxbVersion;
/**
* @author Strong Liu
*/
class VersionMocker extends PropertyMocker {
public class VersionMocker extends PropertyMocker {
private final JaxbVersion version;
VersionMocker(IndexBuilder indexBuilder, ClassInfo classInfo, EntityMappingsMocker.Default defaults, JaxbVersion version) {
@ -39,9 +40,10 @@ class VersionMocker extends PropertyMocker {
}
@Override
protected PropertyElement getPropertyElement() {
protected PersistentAttribute getPersistentAttribute() {
return version;
}
@Override
protected void processExtra() {
create( VERSION );

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.filter;
package org.hibernate.metamodel.source.internal.jandex.filter;
import java.util.Arrays;
import java.util.HashSet;
@ -32,7 +32,7 @@ import java.util.Set;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.IndexBuilder;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
/**
* @author Strong Liu

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.filter;
package org.hibernate.metamodel.source.internal.jandex.filter;
import java.util.ArrayList;
import java.util.Collections;
@ -35,7 +35,7 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.MockHelper;
import org.hibernate.metamodel.source.internal.jandex.MockHelper;
/**
* @author Strong Liu
@ -168,7 +168,7 @@ class ExclusiveAnnotationFilter extends AbstractAnnotationFilter {
Scope scope = Scope.ATTRIBUTE;
@Override
public Iterator iterator() {
public Iterator<DotName> iterator() {
return names.iterator();
}

View File

@ -21,13 +21,13 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.filter;
package org.hibernate.metamodel.source.internal.jandex.filter;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.IndexBuilder;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
/**
* @author Strong Liu

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.filter;
package org.hibernate.metamodel.source.internal.jandex.filter;
import java.util.List;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.filter;
package org.hibernate.metamodel.source.internal.jandex.filter;
import java.util.Iterator;
import java.util.List;
@ -30,8 +30,7 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.AnnotationTarget;
import org.jboss.jandex.DotName;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.xml.mocker.MockHelper;
import org.hibernate.metamodel.source.internal.jandex.MockHelper;
/**
* @author Strong Liu
@ -51,42 +50,42 @@ class NameTargetAnnotationFilter extends AbstractAnnotationFilter {
public static NameTargetAnnotationFilter INSTANCE = new NameTargetAnnotationFilter();
private static final DotName[] TARGET_ANNOTATIONS = new DotName[] {
JPADotNames.LOB,
JPADotNames.ID,
JPADotNames.BASIC,
JPADotNames.GENERATED_VALUE,
JPADotNames.VERSION,
JPADotNames.TRANSIENT,
JPADotNames.ACCESS,
JPADotNames.POST_LOAD,
JPADotNames.POST_PERSIST,
JPADotNames.POST_REMOVE,
JPADotNames.POST_UPDATE,
JPADotNames.PRE_PERSIST,
JPADotNames.PRE_REMOVE,
JPADotNames.PRE_UPDATE,
JPADotNames.EMBEDDED_ID,
JPADotNames.EMBEDDED,
JPADotNames.MANY_TO_ONE,
JPADotNames.MANY_TO_MANY,
JPADotNames.ONE_TO_ONE,
JPADotNames.ONE_TO_MANY,
JPADotNames.ELEMENT_COLLECTION,
JPADotNames.COLLECTION_TABLE,
JPADotNames.COLUMN,
JPADotNames.ENUMERATED,
JPADotNames.JOIN_TABLE,
JPADotNames.TEMPORAL,
JPADotNames.ORDER_BY,
JPADotNames.ORDER_COLUMN,
JPADotNames.JOIN_COLUMN,
JPADotNames.JOIN_COLUMNS,
JPADotNames.MAPS_ID,
JPADotNames.MAP_KEY_TEMPORAL,
JPADotNames.MAP_KEY,
JPADotNames.MAP_KEY_CLASS,
JPADotNames.MAP_KEY_COLUMN,
JPADotNames.MAP_KEY_ENUMERATED
LOB,
ID,
BASIC,
GENERATED_VALUE,
VERSION,
TRANSIENT,
ACCESS,
POST_LOAD,
POST_PERSIST,
POST_REMOVE,
POST_UPDATE,
PRE_PERSIST,
PRE_REMOVE,
PRE_UPDATE,
EMBEDDED_ID,
EMBEDDED,
MANY_TO_ONE,
MANY_TO_MANY,
ONE_TO_ONE,
ONE_TO_MANY,
ELEMENT_COLLECTION,
COLLECTION_TABLE,
COLUMN,
ENUMERATED,
JOIN_TABLE,
TEMPORAL,
ORDER_BY,
ORDER_COLUMN,
JOIN_COLUMN,
JOIN_COLUMNS,
MAPS_ID,
MAP_KEY_TEMPORAL,
MAP_KEY,
MAP_KEY_CLASS,
MAP_KEY_COLUMN,
MAP_KEY_ENUMERATED
};
@Override
protected DotName[] targetAnnotation() {

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
import java.util.List;

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
/**
* Common interface for all the JAXB bindings representing lifecycle callbacks.

View File

@ -21,7 +21,9 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
import javax.persistence.AccessType;
/**
* Common interface for JAXB bindings representing entities, mapped-superclasses and embeddables (JPA collective
@ -38,5 +40,5 @@ public interface ManagedType {
Boolean isMetadataComplete();
void setMetadataComplete(Boolean isMetadataComplete);
public JaxbAccessType getAccess();
public AccessType getAccess();
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
import java.util.List;

View File

@ -21,7 +21,9 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
import javax.persistence.AccessType;
/**
* Common interface for JAXB bindings that represent persistent attributes.
@ -32,11 +34,9 @@ package org.hibernate.metamodel.spi.source.jaxb;
public interface PersistentAttribute {
String getName();
JaxbAccessType getAccess();
void setAccess(JaxbAccessType accessType);
AccessType getAccess();
void setAccess(AccessType accessType);
String getCustomAccess();
void setCustomAccess(String customAccess);
}

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
/**
* Common interface for JAXB bindings that understand database schema (tables, sequences, etc).

View File

@ -21,7 +21,7 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.spi.source.jaxb;
package org.hibernate.metamodel.source.internal.jaxb;
import java.util.List;

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 javax.persistence.AccessType;
/**
* Marshalling support for dealing with JPA AccessType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class AccessTypeMarshalling {
public static AccessType fromXml(String name) {
return AccessType.valueOf( name );
}
public static String toXml(AccessType accessType) {
return accessType.name();
}
}

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 javax.persistence.DiscriminatorType;
/**
* Marshalling support for dealing with JPA DiscriminatorType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class DiscriminatorTypeMarshalling {
public static DiscriminatorType fromXml(String name) {
return DiscriminatorType.valueOf( name );
}
public static String toXml(DiscriminatorType discriminatorType) {
return discriminatorType.name();
}
}

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 javax.persistence.EnumType;
/**
* Marshalling support for dealing with JPA EnumType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class EnumTypeMarshalling {
public static EnumType fromXml(String name) {
return EnumType.valueOf( name );
}
public static String toXml(EnumType enumType) {
return enumType.name();
}
}

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 javax.persistence.FetchType;
/**
* Marshalling support for dealing with JPA FetchType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class FetchTypeMarshalling {
public static FetchType fromXml(String name) {
return FetchType.valueOf( name );
}
public static String toXml(FetchType fetchType) {
return fetchType.name();
}
}

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.FlushMode;
/**
* Marshalling support for dealing with Hibernate FlushMode enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class FlushModeMarshalling {
public static FlushMode fromXml(String name) {
return FlushMode.interpretExternalSetting( name );
}
public static String toXml(FlushMode flushMode) {
return flushMode.toExternalForm();
}
}

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 javax.persistence.LockModeType;
/**
* Marshalling support for dealing with JPA LockModeType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class LockModeTypeMarshalling {
public static LockModeType fromXml(String name) {
return LockModeType.valueOf( name );
}
public static String toXml(LockModeType lockModeType) {
return lockModeType.name();
}
}

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 javax.persistence.ParameterMode;
/**
* Marshalling support for dealing with JPA ParameterMode enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class ParameterModeMarshalling {
public static ParameterMode fromXml(String name) {
return ParameterMode.valueOf( name );
}
public static String toXml(ParameterMode parameterMode) {
return parameterMode.name();
}
}

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 javax.persistence.TemporalType;
/**
* Marshalling support for dealing with JPA TemporalType enums. Plugged into JAXB for binding
*
* @author Steve Ebersole
*/
public class TemporalTypeMarshalling {
public static TemporalType fromXml(String name) {
return TemporalType.valueOf( name );
}
public static String toXml(TemporalType temporalType) {
return temporalType.name();
}
}

View File

@ -1,10 +1,10 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
* 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..
* 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
@ -21,17 +21,8 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
/**
* @author Strong Liu
* todo : Move org.hibernate.metamodel.spi.source here
*/
public interface SchemaAware {
String getSchema();
void setSchema(String schema);
String getCatalog();
void setCatalog(String catalog);
}
package org.hibernate.metamodel.source.spi;

View File

@ -55,7 +55,10 @@ import org.hibernate.xml.spi.XmlBinder;
*
* @author Steve Ebersole
* @author Strong Liu <stliu@hibernate.org>
*
* @deprecated See {@link AbstractUnifiedBinder}
*/
@Deprecated
abstract class AbstractXmlBinder implements XmlBinder {
protected static final Logger log = Logger.getLogger( AbstractXmlBinder.class );

View File

@ -0,0 +1,105 @@
/*
* 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.xml.internal.jaxb;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
import javax.xml.stream.util.EventReaderDelegate;
import org.hibernate.xml.internal.stax.LocalSchema;
/**
* @author Steve Ebersole
*/
public class HbmEventReader extends EventReaderDelegate {
private static final List<String> NAMESPACE_URIS_TO_MAP = Arrays.asList(
// the initial (premature) hbm.xml xsd namespace
"http://www.hibernate.org/xsd/hibernate-mapping"
);
private final XMLEventFactory xmlEventFactory;
public HbmEventReader(XMLEventReader reader) {
this( reader, XMLEventFactory.newInstance() );
}
public HbmEventReader(XMLEventReader reader, XMLEventFactory xmlEventFactory) {
super( reader );
this.xmlEventFactory = xmlEventFactory;
}
@Override
public XMLEvent peek() throws XMLStreamException {
return wrap( super.peek() );
}
@Override
public XMLEvent nextEvent() throws XMLStreamException {
return wrap( super.nextEvent() );
}
private XMLEvent wrap(XMLEvent event) {
if ( event != null && event.isStartElement() ) {
return applyNamespace( event.asStartElement() );
}
return event;
}
@SuppressWarnings("unchecked")
private StartElement applyNamespace(StartElement startElement) {
final List<Namespace> targetNamespaces = new ArrayList<Namespace>();
if ( "".equals( startElement.getName().getNamespaceURI() ) ) {
// add the default namespace mapping
targetNamespaces.add( xmlEventFactory.createNamespace( LocalSchema.HBM.getNamespaceUri() ) );
}
// transfer any namespaces directly, unless it is in the "to map" list in which case
// we transfer a mapped copy pointing to the new namespace
final Iterator<Namespace> originalNamespaces = startElement.getNamespaces();
while ( originalNamespaces.hasNext() ) {
Namespace namespace = originalNamespaces.next();
if ( NAMESPACE_URIS_TO_MAP.contains( namespace.getNamespaceURI() ) ) {
// this is a namespace "to map" so map it
namespace = xmlEventFactory.createNamespace( namespace.getPrefix(), LocalSchema.HBM.getNamespaceUri() );
}
targetNamespaces.add( namespace );
}
return xmlEventFactory.createStartElement(
new QName( LocalSchema.HBM.getNamespaceUri(), startElement.getName().getLocalPart() ),
startElement.getAttributes(),
targetNamespaces.iterator()
);
}
}

View File

@ -26,36 +26,34 @@ package org.hibernate.xml.internal.jaxb;
import javax.xml.bind.JAXBContext;
import javax.xml.bind.JAXBException;
import javax.xml.bind.Unmarshaller;
import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.XMLEvent;
import javax.xml.transform.dom.DOMSource;
import javax.xml.validation.Schema;
import org.jboss.logging.Logger;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.hibernate.internal.util.StringHelper;
import org.hibernate.xml.internal.stax.LocalXmlResourceResolver;
import org.hibernate.jaxb.spi.hbm.JaxbHibernateMapping;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.xml.internal.stax.LocalSchema;
import org.hibernate.xml.internal.stax.SupportedOrmXsdVersion;
import org.hibernate.xml.spi.BindResult;
import org.hibernate.xml.spi.Origin;
import org.hibernate.jaxb.spi.hbm.JaxbHibernateMapping;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.metamodel.spi.source.MappingException;
import org.hibernate.service.ServiceRegistry;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
/**
* Loads {@code hbm.xml} and {@code orm.xml} files and processes them using StAX and JAXB.
*
* @author Steve Ebersole
* @author Hardy Ferentschik
*
* @deprecated see {@link org.hibernate.xml.internal.jaxb.UnifiedMappingBinder}
*/
@Deprecated
public class MappingXmlBinder extends AbstractXmlBinder {
private static final Logger log = Logger.getLogger( MappingXmlBinder.class );
public static final String HIBERNATE_MAPPING_URI = "http://www.hibernate.org/xsd/hibernate-mapping";
public MappingXmlBinder(ServiceRegistry serviceRegistry) {
this( serviceRegistry, true );
}
@ -64,12 +62,6 @@ public class MappingXmlBinder extends AbstractXmlBinder {
super(serviceRegistry, validateXml);
}
// todo : DO THIS!
// the goal here ultimately is to:
// 1) use one "combined" XSD for both orm.xml and hbm.xml features (HHH-8893)
// 2) always always always validate against the latest version of that XSD (HHH-8894)
// 3) profit!
@Override
protected JAXBContext getJaxbContext(XMLEvent event) throws JAXBException {
final String elementName = event.asStartElement().getName().getLocalPart();
@ -88,9 +80,7 @@ public class MappingXmlBinder extends AbstractXmlBinder {
final String elementName = event.asStartElement().getName().getLocalPart();
final Schema validationSchema;
if ( "entity-mappings".equals( elementName ) ) {
final Attribute attribute = event.asStartElement().getAttributeByName( ORM_VERSION_ATTRIBUTE_QNAME );
final String explicitVersion = attribute == null ? null : attribute.getValue();
validationSchema = validateXml ? resolveSupportedOrmXsd( explicitVersion, origin ) : null;
return LocalSchema.MAPPING.getSchema();
}
else {
validationSchema = validateXml ? SupportedOrmXsdVersion.HBM_4_0.getSchema() : null;
@ -102,30 +92,13 @@ public class MappingXmlBinder extends AbstractXmlBinder {
protected XMLEventReader wrapReader(XMLEventReader staxEventReader, XMLEvent event) {
final String elementName = event.asStartElement().getName().getLocalPart();
if ( "entity-mappings".equals( elementName ) ) {
final Attribute attribute = event.asStartElement().getAttributeByName( ORM_VERSION_ATTRIBUTE_QNAME );
final String explicitVersion = attribute == null ? null : attribute.getValue();
if ( !"2.1".equals( explicitVersion ) ) {
return new LegacyJPAEventReader(
staxEventReader,
LocalXmlResourceResolver.SECOND_JPA_ORM_NS
);
}
return new UnifiedMappingEventReader( staxEventReader );
}
else {
if ( !isNamespaced( event.asStartElement() ) ) {
// if the elements are not namespaced, wrap the reader in a reader which will namespace them as pulled.
log.debug( "HBM mapping document did not define namespaces; wrapping in custom event reader to introduce namespace information" );
return new NamespaceAddingEventReader( staxEventReader, HIBERNATE_MAPPING_URI );
}
return new HbmEventReader( staxEventReader );
}
return super.wrapReader( staxEventReader, event );
}
private static final QName ORM_VERSION_ATTRIBUTE_QNAME = new QName( "version" );
@SuppressWarnings( { "unchecked" })
public BindResult bind(Document document, Origin origin) {

View File

@ -28,7 +28,7 @@ import javax.xml.stream.events.StartElement;
import org.hibernate.jaxb.spi.hbm.JaxbHibernateMapping;
import org.hibernate.metamodel.internal.source.hbm.transform.HbmXmlTransformer;
import org.hibernate.metamodel.spi.source.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.xml.internal.stax.LocalSchema;
import org.hibernate.xml.spi.Origin;
@ -40,7 +40,7 @@ import org.jboss.logging.Logger;
* @author Steve Ebersole
*/
public class UnifiedMappingBinder extends AbstractUnifiedBinder<JaxbEntityMappings> {
private static final Logger log = Logger.getLogger( MappingXmlBinder.class );
private static final Logger log = Logger.getLogger( UnifiedMappingBinder.class );
public UnifiedMappingBinder() {
super();
@ -59,19 +59,12 @@ public class UnifiedMappingBinder extends AbstractUnifiedBinder<JaxbEntityMappin
if ( "hibernate-mapping".equals( rootElementLocalName ) ) {
// todo: finalize message test here, and possibly use a message logger
log.debug(
"Found legacy Hibernate hbm.xml mapping; performing on-the-fly transformation. " +
"Consider using build-time transformation tool to speed up run-time parsing"
"Found legacy Hibernate hbm.xml mapping; performing on-the-fly transformation. "
+ "Consider using build-time transformation tool to speed up run-time parsing"
);
XMLEventReader hbmReader = staxEventReader;
if ( !hasNamespace( rootElementStartEvent ) ) {
// if the elements are not namespaced in the source document, which can cause problems with validation
// and/or JAXB binding (since the xsd is namespaced). So we wrap the reader in a version that will
// return events that are namespaced versions of the original
hbmReader = new NamespaceAddingEventReader( staxEventReader, LocalSchema.LEGACY_HBM.getNamespaceUri() );
}
JaxbHibernateMapping hbmBindings = jaxb( hbmReader, LocalSchema.LEGACY_HBM.getSchema(), JaxbHibernateMapping.class, origin );
XMLEventReader hbmReader = new HbmEventReader( staxEventReader );
JaxbHibernateMapping hbmBindings = jaxb( hbmReader, LocalSchema.HBM.getSchema(), JaxbHibernateMapping.class, origin );
return HbmXmlTransformer.INSTANCE.transform( hbmBindings );
}
else {

View File

@ -31,7 +31,6 @@ import javax.xml.namespace.QName;
import javax.xml.stream.XMLEventFactory;
import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.events.Attribute;
import javax.xml.stream.events.Namespace;
import javax.xml.stream.events.StartElement;
import javax.xml.stream.events.XMLEvent;
@ -88,22 +87,8 @@ public class UnifiedMappingEventReader extends EventReaderDelegate {
Iterator<?> namespacesItr;
if ( "entity-mappings".equals( startElement.getName().getLocalPart() ) ) {
final List<Attribute> targetAttributeList = new ArrayList<Attribute>();
final List<Namespace> targetNamespaces = new ArrayList<Namespace>();
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// attributes are pretty straight-forward; copy over any attributes
// *except* the version attribute and then add our specific unified
// schema version explicitly
final Iterator<Attribute> originalAttributes = startElement.getAttributes();
while ( originalAttributes.hasNext() ) {
final Attribute attribute = originalAttributes.next();
if ( !"version".equals( attribute.getName().getLocalPart() ) ) {
targetAttributeList.add( attribute );
}
}
targetAttributeList.add( xmlEventFactory.createAttribute( "version", LocalSchema.MAPPING.getCurrentVersion() ) );
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// namespaces are a little more complicated. We copy over all namespaces,
// but if any uris match known JPA namespaces which point that given
@ -119,7 +104,7 @@ public class UnifiedMappingEventReader extends EventReaderDelegate {
targetNamespaces.add( namespace );
}
attributesItr = targetAttributeList.iterator();
attributesItr = startElement.getAttributes();
namespacesItr = targetNamespaces.iterator();
}
else {

View File

@ -42,13 +42,13 @@ public enum LocalSchema {
"org/hibernate/xsd/mapping/mapping-2.1.0.xsd",
"2.1.0"
),
LEGACY_HBM(
HBM(
"http://www.hibernate.org/xsd/orm/hbm",
"org/hibernate/xsd/mapping/legacy-mapping-4.0.xsd",
"4.0"
)
// , CONFIGURATION( )
// , LEGACY_CONFIGURATON( )
// , CFG( )
;
private static final Logger log = Logger.getLogger( LocalSchema.class );

View File

@ -24,6 +24,7 @@
package org.hibernate.xml.spi;
import java.io.Serializable;
import java.util.Locale;
/**
* Describes the origin of an xml document
@ -31,6 +32,8 @@ import java.io.Serializable;
* @author Steve Ebersole
*/
public class Origin implements Serializable {
public static final String UNKNOWN_FILE_PATH = "<unknown>";
private final SourceType type;
private final String name;
@ -88,9 +91,6 @@ public class Origin implements Serializable {
@Override
public String toString() {
return "Origin{" +
"name='" + name + '\'' +
", type=" + type +
'}';
return String.format( Locale.ENGLISH, "Origin(name=%s,type=%s)", name, type );
}
}

View File

@ -315,8 +315,6 @@
</xs:choice>
</xs:sequence>
<xs:attribute name="discriminator-value" type="xs:string" />
<xs:attribute name="name" type="xs:string" />
<xs:attribute name="entity-name" type="xs:string" />
</xs:extension>
</xs:complexContent>
</xs:complexType>

View File

@ -118,7 +118,7 @@
</xsd:element>
</xsd:sequence>
<xsd:attribute name="version" type="orm:supportedVersionsType" default="2.1.0" use="optional"/>
<xsd:attribute name="version" type="orm:supportedVersionsType" use="required" />
</xsd:complexType>
</xsd:element>
@ -132,7 +132,10 @@
<xsd:simpleType name="supportedVersionsType">
<xsd:restriction base="orm:versionType">
<xsd:enumeration value="2.1.0"/>
<xsd:enumeration value="2.1.0" />
<xsd:enumeration value="1.0" />
<xsd:enumeration value="2.0" />
<xsd:enumeration value="2.1" />
</xsd:restriction>
</xsd:simpleType>
@ -222,9 +225,7 @@
<xsd:simpleType name="access-type">
<xsd:annotation>
<xsd:documentation>
The JPA "attribute access" enumeration, declaring the discrete set of values
describing how the persistence provider accesses the state of an entity or
embedded object.
javax.persistence.AccessType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -443,7 +444,7 @@
<xsd:simpleType name="cache-mode-type">
<xsd:annotation>
<xsd:documentation>
Enumeration values for Hibernate's CacheMode
org.hibernate.CacheMode enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -462,7 +463,7 @@
<!-- todo : account for Hibernate cascade types -->
<xsd:annotation>
<xsd:documentation>
public enum CascadeType { ALL, PERSIST, MERGE, REMOVE, REFRESH, DETACH};
javax.persistence.CascadeType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:sequence>
@ -584,9 +585,7 @@
<xsd:simpleType name="discriminator-type">
<xsd:annotation>
<xsd:documentation>
public enum DiscriminatorType { STRING, CHAR, INTEGER };
javax.persistence.DiscriminatorType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -961,7 +960,7 @@
<xsd:simpleType name="enum-type">
<xsd:annotation>
<xsd:documentation>
Enumerated values specified by javax.persistence.EnumType
javax.persistence.EnumType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -988,7 +987,7 @@
<xsd:simpleType name="fetch-type">
<xsd:annotation>
<xsd:documentation>
Enumerated values specified by javax.persistence.FetchType
javax.persistence.FetchType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -1003,7 +1002,7 @@
<xsd:simpleType name="flush-mode-type">
<xsd:annotation>
<xsd:documentation>
Enumeration values for Hibernate's FlushMode
org.hibernate.FlushMode enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -1047,7 +1046,9 @@
<xsd:simpleType name="generation-type">
<xsd:annotation>
<xsd:documentation>
Enumerated values specified by javax.persistence.GenerationType
javax.persistence.GenerationType rnum values
todo : add custom ones like INCREMENT, UUID, etc
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -1151,6 +1152,8 @@
<xsd:annotation>
<xsd:documentation>
Corresponds to the JPA InheritanceType enumeration values + Hibernate's UNION_SUBCLASS
todo : make a singular enum to cover these
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -1226,7 +1229,7 @@
<xsd:simpleType name="lock-mode-type">
<xsd:annotation>
<xsd:documentation>
Enumerated values specified by javax.persistence.LockModeType
javax.persistence.LockModeType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">
@ -1641,7 +1644,7 @@
<xsd:simpleType name="parameter-mode">
<xsd:annotation>
<xsd:documentation>
Corresponds to enumerated values defined by javax.persistence.ParameterMode
javax.persistence.ParameterMode enum values
</xsd:documentation>
</xsd:annotation>
@ -2146,7 +2149,7 @@
<xsd:simpleType name="temporal-type">
<xsd:annotation>
<xsd:documentation>
javax.persistence.TemporalType enum
javax.persistence.TemporalType enum values
</xsd:documentation>
</xsd:annotation>
<xsd:restriction base="xsd:token">

View File

@ -8,7 +8,7 @@
<bindings schemaLocation="../resources/org/hibernate/xsd/mapping/mapping-2.1.0.xsd" node="/xsd:schema">
<schemaBindings>
<package name="org.hibernate.metamodel.spi.source.jaxb" />
<package name="org.hibernate.metamodel.source.internal.jaxb" />
<nameXmlTransform>
<typeName prefix="Jaxb" />
<elementName prefix="Jaxb" />
@ -17,35 +17,83 @@
</nameXmlTransform>
</schemaBindings>
<bindings node="//xsd:simpleType[@name='access-type']">
<javaType name="javax.persistence.AccessType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.AccessTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.AccessTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='discriminator-type']">
<javaType name="javax.persistence.DiscriminatorType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.DiscriminatorTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.DiscriminatorTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='enum-type']">
<javaType name="javax.persistence.EnumType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.EnumTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.EnumTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='fetch-type']">
<javaType name="javax.persistence.FetchType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FetchTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='flush-mode-type']">
<javaType name="org.hibernate.FlushMode"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FlushModeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.FlushModeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='lock-mode-type']">
<javaType name="javax.persistence.LockModeType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.LockModeTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.LockModeTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='parameter-mode']">
<javaType name="javax.persistence.ParameterMode"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.ParameterModeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.ParameterModeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:simpleType[@name='temporal-type']">
<javaType name="javax.persistence.TemporalType"
parseMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.TemporalTypeMarshalling.fromXml"
printMethod="org.hibernate.metamodel.source.internal.jaxb.marshalling.TemporalTypeMarshalling.toXml" />
</bindings>
<bindings node="//xsd:element[@name='entity-mappings']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='any']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='basic']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='element-collection']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='embedded']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='entity']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='id']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='many-to-any']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='many-to-one']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='version']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ToolingHintContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ToolingHintContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='hbm-tooling-hint']//xsd:attribute[@name='attribute']">
@ -56,103 +104,103 @@
</bindings>
<bindings node="//xsd:complexType[@name='hbm-type-def']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.Parameterized</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.Parameterized</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='secondary-table']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='table']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='join-table']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='collection-table']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='table-generator']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='sequence-generator']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.SchemaAware</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.SchemaAware</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='entity']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ManagedType</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ManagedType</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='embeddable']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ManagedType</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ManagedType</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='mapped-superclass']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.ManagedType</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.ManagedType</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='id']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='version']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='basic']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='many-to-one']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='one-to-many']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='one-to-one']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='embedded-id']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='embedded']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='many-to-many']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='element-collection']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='any']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='many-to-any']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.PersistentAttribute</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.PersistentAttribute</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='pre-persist']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='pre-remove']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='pre-update']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='post-load']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='post-remove']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='post-update']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='post-persist']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.LifecycleCallback</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.LifecycleCallback</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='attributes']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.AttributesContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.AttributesContainer</inheritance:implements>
</bindings>
<bindings node="//xsd:complexType[@name='embeddable-attributes']">
<inheritance:implements>org.hibernate.metamodel.spi.source.jaxb.AttributesContainer</inheritance:implements>
<inheritance:implements>org.hibernate.metamodel.source.internal.jaxb.AttributesContainer</inheritance:implements>
</bindings>
<!-- See http://stackoverflow.com/questions/4394134/jaxb-property-value-is-already-defined-use-jaxbproperty-to-resolve-this -->

View File

@ -30,7 +30,9 @@ import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.boot.registry.classloading.spi.ClassLoaderService;
import org.hibernate.jaxb.spi.orm.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.source.internal.jandex.EntityMappingsMocker;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
import org.hibernate.service.ServiceRegistry;
import org.hibernate.xml.internal.jaxb.MappingXmlBinder;
import org.hibernate.xml.spi.BindResult;

View File

@ -29,11 +29,14 @@ import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.junit.Test;
import org.hibernate.jaxb.spi.orm.JaxbAttributes;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.jaxb.spi.orm.JaxbGeneratedValue;
import org.hibernate.jaxb.spi.orm.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbGeneratedValue;
import org.hibernate.metamodel.source.internal.jaxb.JaxbId;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jandex.EntityMappingsMocker;
import org.hibernate.metamodel.source.internal.jandex.EntityMocker;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
import static org.junit.Assert.assertEquals;

View File

@ -18,8 +18,10 @@ import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.junit.Test;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jandex.DefaultConfigurationHelper;
import org.hibernate.metamodel.source.internal.jandex.EntityMappingsMocker;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

View File

@ -29,7 +29,7 @@ import org.jboss.jandex.Index;
import org.junit.Test;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.hibernate.metamodel.source.internal.jandex.PseudoJpaDotNames;
import static org.junit.Assert.assertEquals;

View File

@ -1,5 +1,7 @@
package org.hibernate.metamodel.internal.source.annotations.xml.mocker;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
import org.junit.Test;
/**

View File

@ -32,8 +32,11 @@ import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.junit.Test;
import org.hibernate.jaxb.spi.orm.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.internal.source.annotations.util.JPADotNames;
import org.hibernate.metamodel.source.internal.jandex.EntityMappingsMocker;
import org.hibernate.metamodel.source.internal.jandex.EntityMocker;
import org.hibernate.metamodel.source.internal.jandex.IndexBuilder;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

View File

@ -29,7 +29,7 @@ import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.Index;
import org.junit.Test;
import org.hibernate.metamodel.internal.source.annotations.xml.PseudoJpaDotNames;
import org.hibernate.metamodel.source.internal.jandex.PseudoJpaDotNames;
import static org.junit.Assert.assertEquals;

View File

@ -23,16 +23,13 @@
*/
package org.hibernate.test.annotations.xml.ejb3;
import java.io.InputStream;
import org.hibernate.InvalidMappingException;
import org.hibernate.cfg.Configuration;
import org.hibernate.xml.internal.stax.UnsupportedOrmXsdVersionException;
import org.junit.Test;
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
import org.hibernate.metamodel.MetadataSources;
import org.hibernate.metamodel.spi.source.InvalidMappingException;
import org.hibernate.testing.TestForIssue;
import org.hibernate.testing.junit4.BaseCoreFunctionalTestCase;
import org.junit.Test;
import static org.junit.Assert.fail;
@ -41,16 +38,11 @@ public class NonExistentOrmVersionTest extends BaseCoreFunctionalTestCase {
@Test
public void testNonExistentOrmVersion() {
try {
Configuration config = buildConfiguration();
String xmlFileName = "org/hibernate/test/annotations/xml/ejb3/orm5.xml";
InputStream is = Thread.currentThread().getContextClassLoader().getResourceAsStream( xmlFileName );
config.addInputStream( is );
config.buildMappings();
MetadataSources sources = new MetadataSources( new BootstrapServiceRegistryBuilder().build() );
sources.addResource( "org/hibernate/test/annotations/xml/ejb3/orm5.xml" );
fail( "Expecting failure due to unsupported xsd version" );
}
catch ( InvalidMappingException expected ) {
}
catch ( UnsupportedOrmXsdVersionException expected ) {
catch (InvalidMappingException expected) {
}
}
}

View File

@ -49,11 +49,6 @@ import static org.junit.Assert.assertTrue;
* @author Gavin King
*/
public class SimpleInheritanceTest extends BaseCoreFunctionalTestCase {
public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( MetadataSources.USE_NEW_METADATA_MAPPINGS, "true");
}
@Override
public String[] getMappings() {
return new String[] { "discriminator/SimpleInheritance.hbm.xml" };

View File

@ -25,11 +25,10 @@ package org.hibernate.test.metamodel.unified.jaxb;
import java.io.InputStream;
import org.hibernate.metamodel.spi.source.jaxb.JaxbAttributes;
import org.hibernate.metamodel.spi.source.jaxb.JaxbBasic;
import org.hibernate.metamodel.spi.source.jaxb.JaxbEntity;
import org.hibernate.metamodel.spi.source.jaxb.JaxbEntityMappings;
import org.hibernate.metamodel.spi.source.jaxb.JaxbId;
import org.hibernate.metamodel.source.internal.jaxb.JaxbAttributes;
import org.hibernate.metamodel.source.internal.jaxb.JaxbBasic;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntity;
import org.hibernate.metamodel.source.internal.jaxb.JaxbEntityMappings;
import org.hibernate.xml.internal.jaxb.UnifiedMappingBinder;
import org.hibernate.xml.spi.Origin;
import org.hibernate.xml.spi.SourceType;

View File

@ -39,11 +39,6 @@ import static org.junit.Assert.assertTrue;
* @author Gail Badner
*/
public class SimpleOpsTest extends AbstractOperationTestCase {
public void configure(Configuration cfg) {
super.configure( cfg );
cfg.setProperty( MetadataSources.USE_NEW_METADATA_MAPPINGS, "true");
}
public String[] getMappings() {
return new String[] { "ops/SimpleEntity.hbm.xml" };
}

View File

@ -30,8 +30,7 @@ import java.lang.annotation.Target;
/**
* Used to mark test classes or methods as expecting to fail when using the new metamodel introduced in 5.0. This annotation is
* only honored when the system property
* {@value org.hibernate.metamodel.MetadataSources#USE_NEW_METADATA_MAPPINGS} is set to <code>true</code>.
* only honored when the system property 'hibernate.test.new_metadata_mappings' is set to <code>true</code>.
*/
@Retention( RetentionPolicy.RUNTIME )
@Target( { ElementType.METHOD, ElementType.TYPE } )

View File

@ -110,16 +110,7 @@ public abstract class BaseCoreFunctionalTestCase extends BaseUnitTestCase {
final ConfigurationService dummyConfigurationService = new ConfigurationServiceImpl(
dummyConfiguration.getProperties()
);
isMetadataUsed = dummyConfigurationService.getSetting(
MetadataSources.USE_NEW_METADATA_MAPPINGS,
new ConfigurationService.Converter<Boolean>() {
@Override
public Boolean convert(Object value) {
return Boolean.parseBoolean( ( String ) value );
}
},
DEFAULT_USE_NEW_METAMODEL
);
isMetadataUsed = true;
}
protected Configuration configuration() {

View File

@ -44,12 +44,6 @@ import org.junit.runner.RunWith;
public abstract class BaseUnitTestCase {
private static final Logger log = Logger.getLogger( BaseUnitTestCase.class );
public static final boolean DEFAULT_USE_NEW_METAMODEL = Boolean.valueOf(
System.getProperty(
MetadataSources.USE_NEW_METADATA_MAPPINGS, "true"
)
);
@Rule
public TestRule globalTimeout= new Timeout(30 * 60 * 1000); // no test should run longer than 30 minutes
@After

View File

@ -298,7 +298,7 @@ public class CustomRunner extends BlockJUnit4ClassRunner {
catch ( Exception e ) {
}
return BaseCoreFunctionalTestCase.DEFAULT_USE_NEW_METAMODEL;
return true;
}
protected Ignore convertSkipToIgnore(FrameworkMethod frameworkMethod) {