From bd82732deeee6db423e1dc5e6a590e90c5ec15b7 Mon Sep 17 00:00:00 2001 From: Gail Badner Date: Tue, 19 Apr 2011 14:29:03 -0700 Subject: [PATCH] HH-6131 : Updates for "XML" prefix for jaxb-generated classes --- .../hibernate/InvalidMappingException.java | 2 - .../metamodel/binding/EntityBinding.java | 16 ++-- .../source/annotations/xml/OrmXmlParser.java | 8 +- .../source/hbm/AbstractEntityBinder.java | 91 ++++++++++--------- .../metamodel/source/hbm/HbmHelper.java | 12 +-- .../source/hbm/HibernateMappingBinder.java | 47 ++++++---- .../source/hbm/HibernateMappingJaxbRoot.java | 6 +- .../source/hbm/HibernateXmlBinder.java | 6 +- .../source/hbm/RootEntityBinder.java | 28 +++--- .../AbstractHbmAttributeDomainState.java | 18 ++-- .../HbmCollectionElementDomainState.java | 5 +- .../domain/HbmPluralAttributeDomainState.java | 24 +++-- .../domain/HbmSimpleAttributeDomainState.java | 15 ++- .../relational/HbmColumnRelationalState.java | 18 ++-- ...bmSimpleValueRelationalStateContainer.java | 22 +++-- .../metamodel/source/internal/JaxbHelper.java | 12 +-- 16 files changed, 185 insertions(+), 145 deletions(-) diff --git a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java index 124fe21954..afee84203c 100644 --- a/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java +++ b/hibernate-core/src/main/java/org/hibernate/InvalidMappingException.java @@ -25,8 +25,6 @@ import org.hibernate.internal.util.xml.XmlDocument; import org.hibernate.metamodel.source.Origin; -import org.hibernate.metamodel.source.hbm.xml.mapping.HibernateMapping; -import org.hibernate.metamodel.source.internal.JaxbRoot; /** * Thrown when a mapping is found to be invalid. diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java index 2fb47e28bc..689e0405e0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/binding/EntityBinding.java @@ -25,7 +25,6 @@ import java.util.ArrayList; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -37,6 +36,11 @@ import org.hibernate.metamodel.relational.Column; import org.hibernate.metamodel.relational.TableSpecification; import org.hibernate.metamodel.source.hbm.HbmHelper; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLClass; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDelete; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlInsert; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdate; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronize; import org.hibernate.metamodel.source.util.MappingHelper; /** @@ -83,7 +87,7 @@ public class EntityBinding { private List synchronizedTableNames; // TODO: change to intialize from Doimain - public void fromHbmXml(MappingDefaults defaults, org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, Entity entity) { + public void fromHbmXml(MappingDefaults defaults, XMLClass entityClazz, Entity entity) { this.entity = entity; metaAttributes = HbmHelper.extractMetas( entityClazz.getMeta(), true, defaults.getMappingMetas() ); @@ -125,7 +129,7 @@ else if ( "none".equals( optimisticLockModeString ) ) { } // CUSTOM SQL - org.hibernate.metamodel.source.hbm.xml.mapping.SqlInsert sqlInsert = entityClazz.getSqlInsert(); + XMLSqlInsert sqlInsert = entityClazz.getSqlInsert(); if ( sqlInsert != null ) { customInsert = HbmHelper.getCustomSql( sqlInsert.getContent(), @@ -134,7 +138,7 @@ else if ( "none".equals( optimisticLockModeString ) ) { ); } - org.hibernate.metamodel.source.hbm.xml.mapping.SqlDelete sqlDelete = entityClazz.getSqlDelete(); + XMLSqlDelete sqlDelete = entityClazz.getSqlDelete(); if ( sqlDelete != null ) { customDelete = HbmHelper.getCustomSql( sqlDelete.getContent(), @@ -143,7 +147,7 @@ else if ( "none".equals( optimisticLockModeString ) ) { ); } - org.hibernate.metamodel.source.hbm.xml.mapping.SqlUpdate sqlUpdate = entityClazz.getSqlUpdate(); + XMLSqlUpdate sqlUpdate = entityClazz.getSqlUpdate(); if ( sqlUpdate != null ) { customUpdate = HbmHelper.getCustomSql( sqlUpdate.getContent(), @@ -153,7 +157,7 @@ else if ( "none".equals( optimisticLockModeString ) ) { } if ( entityClazz.getSynchronize() != null ) { - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Synchronize synchronize : entityClazz.getSynchronize() ) { + for ( XMLSynchronize synchronize : entityClazz.getSynchronize() ) { addSynchronizedTable( synchronize.getTable() ); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParser.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParser.java index 4685ac45a2..7a711313cf 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParser.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/annotations/xml/OrmXmlParser.java @@ -9,7 +9,7 @@ import org.hibernate.AnnotationException; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.metamodel.source.annotation.xml.EntityMappings; +import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings; import org.hibernate.metamodel.source.util.xml.XmlHelper; import org.hibernate.service.classloading.spi.ClassLoaderService; @@ -40,17 +40,17 @@ public Index parseAndUpdateIndex(Set mappingFileNames, Index annotationI Set mappingStreams = new HashSet(); for ( String fileName : mappingFileNames ) { - EntityMappings entityMappings; + XMLEntityMappings entityMappings; try { entityMappings = XmlHelper.unmarshallXml( - fileName, ORM2_MAPPING_XSD, EntityMappings.class, classLoaderService + fileName, ORM2_MAPPING_XSD, XMLEntityMappings.class, classLoaderService ).getRoot(); } catch ( JAXBException orm2Exception ) { // if we cannot parse against orm_2_0.xsd we try orm_1_0.xsd for backwards compatibility try { entityMappings = XmlHelper.unmarshallXml( - fileName, ORM1_MAPPING_XSD, EntityMappings.class, classLoaderService + fileName, ORM1_MAPPING_XSD, XMLEntityMappings.class, classLoaderService ).getRoot(); } catch ( JAXBException orm1Exception ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java index da57659982..9c62c953bd 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/AbstractEntityBinder.java @@ -47,6 +47,7 @@ import org.hibernate.metamodel.relational.Table; import org.hibernate.metamodel.relational.TableSpecification; import org.hibernate.metamodel.relational.UniqueKey; +import org.hibernate.metamodel.source.hbm.xml.mapping.*; import org.hibernate.metamodel.source.internal.MetadataImpl; import org.hibernate.metamodel.source.hbm.state.domain.HbmPluralAttributeDomainState; import org.hibernate.metamodel.source.hbm.state.domain.HbmSimpleAttributeDomainState; @@ -62,7 +63,7 @@ abstract class AbstractEntityBinder { private final Schema.Name schemaName; AbstractEntityBinder(HibernateMappingBinder hibernateMappingBinder, - org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz) { + XMLClass entityClazz) { this.hibernateMappingBinder = hibernateMappingBinder; this.schemaName = new Schema.Name( ( entityClazz.getSchema() == null ? @@ -93,7 +94,7 @@ protected NamingStrategy getNamingStrategy() { return getMetadata().getNamingStrategy(); } - protected void basicEntityBinding(org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + protected void basicEntityBinding(XMLClass entityClazz, EntityBinding entityBinding, Hierarchical superType) { entityBinding.fromHbmXml( @@ -125,7 +126,7 @@ protected String getDefaultAccess() { return hibernateMappingBinder.getDefaultAccess(); } - private void bindPojoRepresentation(org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + private void bindPojoRepresentation(XMLClass entityClazz, EntityBinding entityBinding) { String className = hibernateMappingBinder.getClassName( entityClazz.getName() ); String proxyName = hibernateMappingBinder.getClassName( entityClazz.getProxy() ); @@ -140,13 +141,13 @@ else if ( entityBinding.isLazy() ) { entityBinding.getEntity().getPojoEntitySpecifics().setProxyInterfaceName( className ); } - org.hibernate.metamodel.source.hbm.xml.mapping.Tuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.POJO ); + XMLTuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.POJO ); if ( tuplizer != null ) { entityBinding.getEntity().getPojoEntitySpecifics().setTuplizerClassName( tuplizer.getClazz() ); } } - private void bindDom4jRepresentation(org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + private void bindDom4jRepresentation(XMLClass entityClazz, EntityBinding entityBinding) { String nodeName = entityClazz.getNode(); if ( nodeName == null ) { @@ -154,15 +155,15 @@ private void bindDom4jRepresentation(org.hibernate.metamodel.source.hbm.xml.mapp } entityBinding.getEntity().getDom4jEntitySpecifics().setNodeName(nodeName); - org.hibernate.metamodel.source.hbm.xml.mapping.Tuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.DOM4J ); + XMLTuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.DOM4J ); if ( tuplizer != null ) { entityBinding.getEntity().getDom4jEntitySpecifics().setTuplizerClassName( tuplizer.getClazz() ); } } - private void bindMapRepresentation(org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + private void bindMapRepresentation(XMLClass entityClazz, EntityBinding entityBinding) { - org.hibernate.metamodel.source.hbm.xml.mapping.Tuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.MAP ); + XMLTuplizer tuplizer = locateTuplizerDefinition( entityClazz, EntityMode.MAP ); if ( tuplizer != null ) { entityBinding.getEntity().getMapEntitySpecifics().setTuplizerClassName( tuplizer.getClazz() ); } @@ -176,9 +177,9 @@ private void bindMapRepresentation(org.hibernate.metamodel.source.hbm.xml.mappin * * @return The tuplizer element, or null. */ - private static org.hibernate.metamodel.source.hbm.xml.mapping.Tuplizer locateTuplizerDefinition(org.hibernate.metamodel.source.hbm.xml.mapping.Class container, + private static XMLTuplizer locateTuplizerDefinition(XMLClass container, EntityMode entityMode) { - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Tuplizer tuplizer : container.getTuplizer() ) { + for ( XMLTuplizer tuplizer : container.getTuplizer() ) { if ( entityMode.toString().equals( tuplizer.getEntityMode() ) ) { return tuplizer; } @@ -209,7 +210,7 @@ else if ( "none".equals( olMode ) ) { } protected String getClassTableName( - org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + XMLClass entityClazz, EntityBinding entityBinding, Table denormalizedSuperTable) { final String entityName = entityBinding.getEntity().getName(); @@ -228,7 +229,7 @@ protected String getClassTableName( return physicalTableName; } - protected void buildAttributeBindings(org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + protected void buildAttributeBindings(XMLClass entityClazz, EntityBinding entityBinding) { // null = UniqueKey (we are not binding a natural-id mapping) // true = mutable, by default properties are mutable @@ -247,7 +248,7 @@ protected void buildAttributeBindings(org.hibernate.metamodel.source.hbm.xml.map * @param nullable */ protected void buildAttributeBindings( - org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, + XMLClass entityClazz, EntityBinding entityBinding, UniqueKey uniqueKey, boolean mutable, @@ -259,67 +260,67 @@ protected void buildAttributeBindings( AttributeBinding attributeBinding = null; for ( Object attribute : entityClazz.getPropertyOrManyToOneOrOneToOne() ) { - if ( org.hibernate.metamodel.source.hbm.xml.mapping.Bag.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection = org.hibernate.metamodel.source.hbm.xml.mapping.Bag.class.cast( attribute ); + if ( XMLBag.class.isInstance( attribute ) ) { + XMLBag collection = XMLBag.class.cast( attribute ); BagBinding collectionBinding = entityBinding.makeBagAttributeBinding( collection.getName() ); bindBag( collection, collectionBinding, entityBinding ); hibernateMappingBinder.getHibernateXmlBinder().getMetadata().addCollection( collectionBinding ); attributeBinding = collectionBinding; } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Idbag.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Idbag collection = org.hibernate.metamodel.source.hbm.xml.mapping.Idbag.class.cast( attribute ); + else if ( XMLIdbag.class.isInstance( attribute ) ) { + XMLIdbag collection = XMLIdbag.class.cast( attribute ); //BagBinding collectionBinding = entityBinding.makeBagAttributeBinding( collection.getName() ); //bindIdbag( collection, bagBinding, entityBinding, PluralAttributeNature.BAG, collection.getName() ); // todo: handle identifier //attributeBinding = collectionBinding; //hibernateMappingBinder.getHibernateXmlBinder().getMetadata().addCollection( attributeBinding ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Set.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Set collection = org.hibernate.metamodel.source.hbm.xml.mapping.Set.class.cast( attribute ); + else if ( XMLSet.class.isInstance( attribute ) ) { + XMLSet collection = XMLSet.class.cast( attribute ); //BagBinding collectionBinding = entityBinding.makeBagAttributeBinding( collection.getName() ); //bindSet( collection, collectionBinding, entityBinding, PluralAttributeNature.SET, collection.getName() ); //attributeBinding = collectionBinding; //hibernateMappingBinder.getHibernateXmlBinder().getMetadata().addCollection( attributeBinding ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.List.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.List collection = org.hibernate.metamodel.source.hbm.xml.mapping.List.class.cast( attribute ); + else if ( XMLList.class.isInstance( attribute ) ) { + XMLList collection = XMLList.class.cast( attribute ); //ListBinding collectionBinding = entityBinding.makeBagAttributeBinding( collection.getName() ); //bindList( collection, bagBinding, entityBinding, PluralAttributeNature.LIST, collection.getName() ); // todo : handle list index //attributeBinding = collectionBinding; //hibernateMappingBinder.getHibernateXmlBinder().getMetadata().addCollection( attributeBinding ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Map.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Map collection = org.hibernate.metamodel.source.hbm.xml.mapping.Map.class.cast( attribute ); + else if ( XMLMap.class.isInstance( attribute ) ) { + XMLMap collection = XMLMap.class.cast( attribute ); //BagBinding bagBinding = entityBinding.makeBagAttributeBinding( collection.getName() ); //bindMap( collection, bagBinding, entityBinding, PluralAttributeNature.MAP, collection.getName() ); // todo : handle map key //hibernateMappingBinder.getHibernateXmlBinder().getMetadata().addCollection( attributeBinding ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.ManyToOne.class.isInstance( attribute ) ) { + else if ( XMLManyToOne.class.isInstance( attribute ) ) { // todo : implement // value = new ManyToOne( mappings, table ); // bindManyToOne( subElement, (ManyToOne) value, propertyName, nullable, mappings ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Any.class.isInstance( attribute ) ) { + else if ( XMLAny.class.isInstance( attribute ) ) { // todo : implement // value = new Any( mappings, table ); // bindAny( subElement, (Any) value, nullable, mappings ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.OneToOne.class.isInstance( attribute ) ) { + else if ( XMLOneToOne.class.isInstance( attribute ) ) { // todo : implement // value = new OneToOne( mappings, table, persistentClass ); // bindOneToOne( subElement, (OneToOne) value, propertyName, true, mappings ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Property.class.isInstance( attribute ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Property property = org.hibernate.metamodel.source.hbm.xml.mapping.Property.class.cast( attribute ); + else if ( XMLProperty.class.isInstance( attribute ) ) { + XMLProperty property = XMLProperty.class.cast( attribute ); SimpleAttributeBinding binding = entityBinding.makeSimpleAttributeBinding( property.getName() ); bindSimpleAttribute( property, binding, entityBinding ); attributeBinding = binding; } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Component.class.isInstance( attribute ) - || org.hibernate.metamodel.source.hbm.xml.mapping.DynamicComponent.class.isInstance( attribute ) - || org.hibernate.metamodel.source.hbm.xml.mapping.Properties.class.isInstance( attribute ) ) { + else if ( XMLComponent.class.isInstance( attribute ) + || XMLDynamicComponent.class.isInstance( attribute ) + || XMLProperties.class.isInstance( attribute ) ) { // todo : implement // String subpath = StringHelper.qualify( entityName, propertyName ); // value = new Component( mappings, persistentClass ); @@ -343,26 +344,26 @@ else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Component.class.isInsta Array PrimitiveArray */ - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Join join : entityClazz.getJoin() ) { + for ( XMLJoin join : entityClazz.getJoin() ) { // todo : implement // Join join = new Join(); // join.setPersistentClass( persistentClass ); // bindJoin( subElement, join, mappings, inheritedMetas ); // persistentClass.addJoin( join ); } - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Subclass subclass : entityClazz.getSubclass() ) { + for ( XMLSubclass subclass : entityClazz.getSubclass() ) { // todo : implement // handleSubclass( persistentClass, mappings, subElement, inheritedMetas ); } - for ( org.hibernate.metamodel.source.hbm.xml.mapping.JoinedSubclass subclass : entityClazz.getJoinedSubclass() ) { + for ( XMLJoinedSubclass subclass : entityClazz.getJoinedSubclass() ) { // todo : implement // handleJoinedSubclass( persistentClass, mappings, subElement, inheritedMetas ); } - for ( org.hibernate.metamodel.source.hbm.xml.mapping.UnionSubclass subclass : entityClazz.getUnionSubclass() ) { + for ( XMLUnionSubclass subclass : entityClazz.getUnionSubclass() ) { // todo : implement // handleUnionSubclass( persistentClass, mappings, subElement, inheritedMetas ); } - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Filter filter : entityClazz.getFilter() ) { + for ( XMLFilter filter : entityClazz.getFilter() ) { // todo : implement // parseFilter( subElement, entityBinding ); } @@ -387,18 +388,18 @@ else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Component.class.isInsta } if ( entityClazz.getQueryOrSqlQuery() != null ) { for ( Object queryOrSqlQuery : entityClazz.getQueryOrSqlQuery() ) { - if ( org.hibernate.metamodel.source.hbm.xml.mapping.Query.class.isInstance( queryOrSqlQuery ) ) { + if ( XMLQuery.class.isInstance( queryOrSqlQuery ) ) { // todo : implement // bindNamedQuery(subElement, persistentClass.getEntityName(), mappings); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.SqlQuery.class.isInstance( queryOrSqlQuery ) ) { + else if ( XMLSqlQuery.class.isInstance( queryOrSqlQuery ) ) { // todo : implement // bindNamedSQLQuery(subElement, persistentClass.getEntityName(), mappings); } } } if ( entityClazz.getResultset() != null ) { - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Resultset resultSet : entityClazz.getResultset() ) { + for ( XMLResultset resultSet : entityClazz.getResultset() ) { // todo : implement // bindResultSetMappingDefinition( subElement, persistentClass.getEntityName(), mappings ); } @@ -414,7 +415,7 @@ else if ( org.hibernate.metamodel.source.hbm.xml.mapping.SqlQuery.class.isInstan } - protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mapping.Id id, + protected void bindSimpleAttribute(XMLId id, SimpleAttributeBinding attributeBinding, EntityBinding entityBinding, String attributeName) { @@ -442,7 +443,7 @@ protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mappin } } - protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator, + protected void bindSimpleAttribute(XMLDiscriminator discriminator, SimpleAttributeBinding attributeBinding, EntityBinding entityBinding, String attributeName) { @@ -470,7 +471,7 @@ protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mappin } } - protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mapping.Version version, + protected void bindSimpleAttribute(XMLVersion version, SimpleAttributeBinding attributeBinding, EntityBinding entityBinding, String attributeName) { @@ -498,7 +499,7 @@ protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mappin } } - protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mapping.Timestamp timestamp, + protected void bindSimpleAttribute(XMLTimestamp timestamp, SimpleAttributeBinding attributeBinding, EntityBinding entityBinding, String attributeName) { @@ -526,7 +527,7 @@ protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mappin } } - protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mapping.Property property, + protected void bindSimpleAttribute(XMLProperty property, SimpleAttributeBinding attributeBinding, EntityBinding entityBinding) { if ( attributeBinding.getAttribute() == null ) { @@ -554,7 +555,7 @@ protected void bindSimpleAttribute(org.hibernate.metamodel.source.hbm.xml.mappin } protected void bindBag( - org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection, + XMLBag collection, PluralAttributeBinding collectionBinding, EntityBinding entityBinding) { if ( collectionBinding.getAttribute() == null ) { diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HbmHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HbmHelper.java index 8b3cc61a79..f94f89b87b 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HbmHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HbmHelper.java @@ -24,7 +24,6 @@ package org.hibernate.metamodel.source.hbm; import java.util.HashMap; -import java.util.Iterator; import java.util.List; import java.util.Map; @@ -33,9 +32,10 @@ import org.hibernate.MappingException; import org.hibernate.engine.ExecuteUpdateResultCheckStyle; -import org.hibernate.internal.util.ReflectHelper; import org.hibernate.metamodel.binding.CustomSQL; import org.hibernate.metamodel.domain.MetaAttribute; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLClass; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLMeta; import org.hibernate.metamodel.source.util.DomHelper; import org.hibernate.metamodel.source.util.MappingHelper; @@ -69,14 +69,14 @@ public static ExecuteUpdateResultCheckStyle getResultCheckStyle(String check, bo return ExecuteUpdateResultCheckStyle.parse( check ); } - public static final Map extractMetas(List meta, Map baseline) { + public static final Map extractMetas(List meta, Map baseline) { return extractMetas( meta, false, baseline ); } - public static final Map extractMetas(List metaList, boolean onlyInheritable, Map baseline) { + public static final Map extractMetas(List metaList, boolean onlyInheritable, Map baseline) { Map extractedMetas = new HashMap(); extractedMetas.putAll( baseline ); - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Meta meta : metaList) { + for ( XMLMeta meta : metaList) { boolean inheritable = Boolean.valueOf( meta.getInherit() ); if ( onlyInheritable & !inheritable ) { continue; @@ -94,7 +94,7 @@ public static final Map extractMetas(List jaxbRoot; - private final HibernateMapping hibernateMapping; + private final JaxbRoot jaxbRoot; + private final XMLHibernateMapping hibernateMapping; private final String defaultSchemaName; private final String defaultCatalogName; @@ -58,7 +67,7 @@ class HibernateMappingBinder implements MappingDefaults { private Map mappingMetas; - HibernateMappingBinder(HibernateXmlBinder hibernateXmlBinder, JaxbRoot jaxbRoot) { + HibernateMappingBinder(HibernateXmlBinder hibernateXmlBinder, JaxbRoot jaxbRoot) { this.hibernateXmlBinder = hibernateXmlBinder; this.jaxbRoot = jaxbRoot; this.hibernateMapping = jaxbRoot.getRoot(); @@ -79,7 +88,7 @@ HibernateXmlBinder getHibernateXmlBinder() { return hibernateXmlBinder; } - HibernateMapping getHibernateMapping() { + XMLHibernateMapping getHibernateMapping() { return hibernateMapping; } @@ -138,20 +147,20 @@ void processHibernateMapping() { } if ( hibernateMapping.getClazzOrSubclassOrJoinedSubclass() != null ) { for ( Object clazzOrSubclass : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) { - if ( org.hibernate.metamodel.source.hbm.xml.mapping.Class.class.isInstance( clazzOrSubclass ) ) { - org.hibernate.metamodel.source.hbm.xml.mapping.Class clazz = - org.hibernate.metamodel.source.hbm.xml.mapping.Class.class.cast( clazzOrSubclass ); + if ( XMLClass.class.isInstance( clazzOrSubclass ) ) { + XMLClass clazz = + XMLClass.class.cast( clazzOrSubclass ); new RootEntityBinder( this, clazz ).process( clazz ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.Subclass.class.isInstance( clazzOrSubclass ) ) { + else if ( XMLSubclass.class.isInstance( clazzOrSubclass ) ) { // PersistentClass superModel = getSuperclass( mappings, element ); // handleSubclass( superModel, mappings, element, inheritedMetas ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.JoinedSubclass.class.isInstance( clazzOrSubclass ) ) { + else if ( XMLJoinedSubclass.class.isInstance( clazzOrSubclass ) ) { // PersistentClass superModel = getSuperclass( mappings, element ); // handleJoinedSubclass( superModel, mappings, element, inheritedMetas ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.UnionSubclass.class.isInstance( clazzOrSubclass ) ) { + else if ( XMLUnionSubclass.class.isInstance( clazzOrSubclass ) ) { // PersistentClass superModel = getSuperclass( mappings, element ); // handleUnionSubclass( superModel, mappings, element, inheritedMetas ); } @@ -164,10 +173,10 @@ else if ( org.hibernate.metamodel.source.hbm.xml.mapping.UnionSubclass.class.isI } if ( hibernateMapping.getQueryOrSqlQuery() != null ) { for ( Object queryOrSqlQuery : hibernateMapping.getQueryOrSqlQuery() ) { - if ( org.hibernate.metamodel.source.hbm.xml.mapping.Query.class.isInstance( queryOrSqlQuery ) ) { + if ( XMLQuery.class.isInstance( queryOrSqlQuery ) ) { // bindNamedQuery( element, null, mappings ); } - else if ( org.hibernate.metamodel.source.hbm.xml.mapping.SqlQuery.class.isInstance( queryOrSqlQuery ) ) { + else if ( XMLSqlQuery.class.isInstance( queryOrSqlQuery ) ) { // bindNamedSQLQuery( element, null, mappings ); } else { @@ -188,8 +197,8 @@ else if ( org.hibernate.metamodel.source.hbm.xml.mapping.SqlQuery.class.isInstan } } - private void processImports(List imports) { - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Import importValue : imports ) { + private void processImports(List imports) { + for ( XMLImport importValue : imports ) { String className = getClassName( importValue.getClazz() ); String rename = importValue.getRename(); rename = ( rename == null ) ? StringHelper.unqualify( className ) : rename; @@ -197,11 +206,11 @@ private void processImports(List fetchProfiles, String containingEntityName) { - for ( org.hibernate.metamodel.source.hbm.xml.mapping.FetchProfile fetchProfile : fetchProfiles ) { + protected void parseFetchProfiles(List fetchProfiles, String containingEntityName) { + for ( XMLFetchProfile fetchProfile : fetchProfiles ) { String profileName = fetchProfile.getName(); org.hibernate.metamodel.binding.FetchProfile profile = hibernateXmlBinder.getMetadata().findOrCreateFetchProfile( profileName, MetadataSource.HBM ); - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Fetch fetch : fetchProfile.getFetch() ) { + for ( XMLFetch fetch : fetchProfile.getFetch() ) { String entityName = fetch.getEntity() == null ? containingEntityName : fetch.getEntity(); if ( entityName == null ) { throw new MappingException( "could not determine entity for fetch-profile fetch [" + profileName + "]:[" + fetch.getAssociation() + "]" ); @@ -211,7 +220,7 @@ protected void parseFetchProfiles(List { +public class HibernateMappingJaxbRoot extends JaxbRoot { - public HibernateMappingJaxbRoot(HibernateMapping root, Origin origin) { + public HibernateMappingJaxbRoot(XMLHibernateMapping root, Origin origin) { super(root, origin); } } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateXmlBinder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateXmlBinder.java index ec39521d03..c3a5c4eda0 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateXmlBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/HibernateXmlBinder.java @@ -41,7 +41,7 @@ import org.hibernate.metamodel.domain.MetaAttribute; import org.hibernate.metamodel.source.internal.JaxbRoot; import org.hibernate.metamodel.source.internal.MetadataImpl; -import org.hibernate.metamodel.source.hbm.xml.mapping.HibernateMapping; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping; /** * Binder for {@code hbm.xml} files @@ -63,12 +63,12 @@ public HibernateXmlBinder(MetadataImpl metadata, Map glob this.globalMetas = globalMetas; } - public void bindRoot(JaxbRoot jaxbRoot) { + public void bindRoot(JaxbRoot jaxbRoot) { log.debug( jaxbRoot.toString() ); bindRoot( jaxbRoot, Collections.emptySet() ); } - public void bindRoot(JaxbRoot jaxbRoot, Set entityNames) { + public void bindRoot(JaxbRoot jaxbRoot, Set entityNames) { final HibernateMappingBinder mappingBinder = new HibernateMappingBinder( this, jaxbRoot ); // this is irrelevant due to HHH-6118 and the fact that now all sources should be diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/RootEntityBinder.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/RootEntityBinder.java index 401fc26687..3d48cc7e84 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/RootEntityBinder.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/RootEntityBinder.java @@ -23,12 +23,8 @@ */ package org.hibernate.metamodel.source.hbm; -import org.dom4j.Attribute; -import org.dom4j.Element; - import org.hibernate.InvalidMappingException; import org.hibernate.MappingException; -import org.hibernate.mapping.PropertyGeneration; import org.hibernate.mapping.RootClass; import org.hibernate.metamodel.binding.Caching; import org.hibernate.metamodel.binding.EntityBinding; @@ -37,6 +33,10 @@ import org.hibernate.metamodel.relational.Identifier; import org.hibernate.metamodel.relational.InLineView; import org.hibernate.metamodel.relational.Schema; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLCache; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLClass; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLCompositeId; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLId; import org.hibernate.metamodel.source.util.MappingHelper; /** @@ -46,11 +46,11 @@ */ class RootEntityBinder extends AbstractEntityBinder { - RootEntityBinder(HibernateMappingBinder hibernateMappingBinder, org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClazz) { + RootEntityBinder(HibernateMappingBinder hibernateMappingBinder, XMLClass xmlClazz) { super( hibernateMappingBinder, xmlClazz ); } - public void process(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClazz) { + public void process(XMLClass xmlClazz) { String entityName = getHibernateMappingBinder().extractEntityName( xmlClazz ); if ( entityName == null ) { throw new MappingException( "Unable to determine entity name" ); @@ -87,7 +87,7 @@ public void process(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClaz getHibernateXmlBinder().getMetadata().addEntity( entityBinding ); } - private void basicTableBinding(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClazz, + private void basicTableBinding(XMLClass xmlClazz, EntityBinding entityBinding) { final Schema schema = getHibernateXmlBinder().getMetadata().getDatabase().getSchema( getSchemaName() ); @@ -119,7 +119,7 @@ private void basicTableBinding(org.hibernate.metamodel.source.hbm.xml.mapping.Cl } } - private void bindIdentifier(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClazz, + private void bindIdentifier(XMLClass xmlClazz, EntityBinding entityBinding) { if ( xmlClazz.getId() != null ) { bindSimpleId( xmlClazz.getId(), entityBinding ); @@ -136,7 +136,7 @@ private void bindIdentifier(org.hibernate.metamodel.source.hbm.xml.mapping.Class ); } - private void bindSimpleId(org.hibernate.metamodel.source.hbm.xml.mapping.Id id, EntityBinding entityBinding) { + private void bindSimpleId(XMLId id, EntityBinding entityBinding) { // Handle the domain portion of the binding... final String explicitName = id.getName(); final String attributeName = explicitName == null ? RootClass.DEFAULT_IDENTIFIER_COLUMN_NAME : explicitName; @@ -199,7 +199,7 @@ private void bindSimpleId(org.hibernate.metamodel.source.hbm.xml.mapping.Id id, // makeIdentifier( idNode, id, mappings ); } - private static void bindCompositeId(org.hibernate.metamodel.source.hbm.xml.mapping.CompositeId compositeId, EntityBinding entityBinding) { + private static void bindCompositeId(XMLCompositeId compositeId, EntityBinding entityBinding) { final String explicitName = compositeId.getName(); // String propertyName = idNode.attributeValue( "name" ); @@ -229,7 +229,7 @@ private static void bindCompositeId(org.hibernate.metamodel.source.hbm.xml.mappi } - private void bindDiscriminator(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlEntityClazz, + private void bindDiscriminator(XMLClass xmlEntityClazz, EntityBinding entityBinding) { if ( xmlEntityClazz.getDiscriminator() == null ) { return; @@ -244,7 +244,7 @@ private void bindDiscriminator(org.hibernate.metamodel.source.hbm.xml.mapping.Cl entityBinding.getEntityDiscriminator().setForced( MappingHelper.getBooleanValue( xmlEntityClazz.getDiscriminator().getForce(), false ) ); } - private void bindVersion(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlEntityClazz, + private void bindVersion(XMLClass xmlEntityClazz, EntityBinding entityBinding) { if ( xmlEntityClazz.getVersion() == null && xmlEntityClazz.getTimestamp() == null ) { return; @@ -274,9 +274,9 @@ private void bindVersion(org.hibernate.metamodel.source.hbm.xml.mapping.Class xm } } - private void bindCaching(org.hibernate.metamodel.source.hbm.xml.mapping.Class xmlClazz, + private void bindCaching(XMLClass xmlClazz, EntityBinding entityBinding) { - org.hibernate.metamodel.source.hbm.xml.mapping.Cache cache = xmlClazz.getCache(); + XMLCache cache = xmlClazz.getCache(); if ( cache == null ) { return; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/AbstractHbmAttributeDomainState.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/AbstractHbmAttributeDomainState.java index 64c4c8612a..ae9f3b024c 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/AbstractHbmAttributeDomainState.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/AbstractHbmAttributeDomainState.java @@ -32,6 +32,12 @@ import org.hibernate.metamodel.domain.Attribute; import org.hibernate.metamodel.domain.MetaAttribute; import org.hibernate.metamodel.source.hbm.HbmHelper; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLBag; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLDiscriminator; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLId; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLProperty; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLTimestamp; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLVersion; import org.hibernate.metamodel.source.util.MappingHelper; /** @@ -50,7 +56,7 @@ public abstract class AbstractHbmAttributeDomainState implements AbstractAttribu public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Id id) { + XMLId id) { this.defaults = defaults; this.attribute = attribute; this.hibernateTypeDescriptor = new HibernateTypeDescriptor(); @@ -66,7 +72,7 @@ public AbstractHbmAttributeDomainState(MappingDefaults defaults, public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, - org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator) { + XMLDiscriminator discriminator) { this.defaults = defaults; this.attribute = attribute; @@ -83,7 +89,7 @@ public AbstractHbmAttributeDomainState(MappingDefaults defaults, public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Version version) { + XMLVersion version) { this.defaults = defaults; this.attribute = attribute; this.hibernateTypeDescriptor = new HibernateTypeDescriptor(); @@ -102,7 +108,7 @@ public AbstractHbmAttributeDomainState(MappingDefaults defaults, public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Timestamp timestamp) { + XMLTimestamp timestamp) { this.defaults = defaults; this.attribute = attribute; this.hibernateTypeDescriptor = new HibernateTypeDescriptor(); @@ -124,7 +130,7 @@ public AbstractHbmAttributeDomainState(MappingDefaults defaults, public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Property property) { + XMLProperty property) { this.defaults = defaults; this.attribute = attribute; this.hibernateTypeDescriptor = new HibernateTypeDescriptor(); @@ -141,7 +147,7 @@ public AbstractHbmAttributeDomainState(MappingDefaults defaults, public AbstractHbmAttributeDomainState(MappingDefaults defaults, Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection) { + XMLBag collection) { this.defaults = defaults; this.attribute = attribute; this.hibernateTypeDescriptor = new HibernateTypeDescriptor(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmCollectionElementDomainState.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmCollectionElementDomainState.java index 22a6a02339..af1b6f6bbe 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmCollectionElementDomainState.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmCollectionElementDomainState.java @@ -25,14 +25,15 @@ import org.hibernate.metamodel.binding.CollectionElement; import org.hibernate.metamodel.binding.HibernateTypeDescriptor; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLElement; /** * @author Gail Badner */ public class HbmCollectionElementDomainState implements CollectionElement.DomainState { - private final org.hibernate.metamodel.source.hbm.xml.mapping.Element element; + private final XMLElement element; - HbmCollectionElementDomainState(org.hibernate.metamodel.source.hbm.xml.mapping.Element element) { + HbmCollectionElementDomainState(XMLElement element) { this.element = element; } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmPluralAttributeDomainState.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmPluralAttributeDomainState.java index d3e5bd923e..08f3d3fb6d 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmPluralAttributeDomainState.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmPluralAttributeDomainState.java @@ -25,12 +25,9 @@ import java.util.Comparator; import java.util.HashSet; -import java.util.Iterator; import java.util.HashMap; import java.util.Map; -import org.dom4j.Element; - import org.hibernate.FetchMode; import org.hibernate.MappingException; import org.hibernate.metamodel.binding.CollectionElement; @@ -41,6 +38,13 @@ import org.hibernate.metamodel.domain.Attribute; import org.hibernate.metamodel.domain.MetaAttribute; import org.hibernate.metamodel.source.hbm.HbmHelper; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLBag; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronize; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDelete; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteAll; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlInsert; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdate; + import org.hibernate.metamodel.source.util.MappingHelper; @@ -48,10 +52,10 @@ * @author Gail Badner */ public class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainState implements PluralAttributeBinding.DomainState { - private final org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection; + private final XMLBag collection; public HbmPluralAttributeDomainState(MappingDefaults defaults, - org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection, + XMLBag collection, Map entityMetaAttributes, Attribute attribute) { super( defaults, attribute, entityMetaAttributes, collection ); @@ -200,14 +204,14 @@ public java.util.Map getFilters() { } public java.util.Set getSynchronizedTables() { java.util.Set synchronizedTables = new HashSet(); - for ( org.hibernate.metamodel.source.hbm.xml.mapping.Synchronize sync : collection.getSynchronize() ) { + for ( XMLSynchronize sync : collection.getSynchronize() ) { synchronizedTables.add( sync.getTable() ); } return synchronizedTables; } public CustomSQL getCustomSQLInsert() { - org.hibernate.metamodel.source.hbm.xml.mapping.SqlInsert sqlInsert = collection.getSqlInsert(); + XMLSqlInsert sqlInsert = collection.getSqlInsert(); return sqlInsert == null ? null : HbmHelper.getCustomSql( @@ -217,7 +221,7 @@ public CustomSQL getCustomSQLInsert() { ); } public CustomSQL getCustomSQLUpdate() { - org.hibernate.metamodel.source.hbm.xml.mapping.SqlUpdate sqlUpdate = collection.getSqlUpdate(); + XMLSqlUpdate sqlUpdate = collection.getSqlUpdate(); return sqlUpdate == null ? null : HbmHelper.getCustomSql( @@ -227,7 +231,7 @@ public CustomSQL getCustomSQLUpdate() { ); } public CustomSQL getCustomSQLDelete() { - org.hibernate.metamodel.source.hbm.xml.mapping.SqlDelete sqlDelete = collection.getSqlDelete(); + XMLSqlDelete sqlDelete = collection.getSqlDelete(); return sqlDelete == null ? null : HbmHelper.getCustomSql( @@ -237,7 +241,7 @@ public CustomSQL getCustomSQLDelete() { ); } public CustomSQL getCustomSQLDeleteAll() { - org.hibernate.metamodel.source.hbm.xml.mapping.SqlDeleteAll sqlDeleteAll = collection.getSqlDeleteAll(); + XMLSqlDeleteAll sqlDeleteAll = collection.getSqlDeleteAll(); return sqlDeleteAll == null ? null : HbmHelper.getCustomSql( diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmSimpleAttributeDomainState.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmSimpleAttributeDomainState.java index 1108dd18ef..df4c665d09 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmSimpleAttributeDomainState.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/domain/HbmSimpleAttributeDomainState.java @@ -30,6 +30,11 @@ import org.hibernate.metamodel.binding.MappingDefaults; import org.hibernate.metamodel.binding.SimpleAttributeBinding; import org.hibernate.metamodel.domain.MetaAttribute; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLId; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLDiscriminator; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLProperty; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLTimestamp; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLVersion; import org.hibernate.metamodel.source.util.MappingHelper; /** @@ -44,7 +49,7 @@ public class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainSta public HbmSimpleAttributeDomainState(MappingDefaults defaults, org.hibernate.metamodel.domain.Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Id id) { + XMLId id) { super( defaults, attribute, entityMetaAttributes, id ); this.isLazy = false; @@ -58,7 +63,7 @@ public HbmSimpleAttributeDomainState(MappingDefaults defaults, public HbmSimpleAttributeDomainState(MappingDefaults defaults, org.hibernate.metamodel.domain.Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator) { + XMLDiscriminator discriminator) { super( defaults, attribute, discriminator ); this.isLazy = false; @@ -70,7 +75,7 @@ public HbmSimpleAttributeDomainState(MappingDefaults defaults, public HbmSimpleAttributeDomainState(MappingDefaults defaults, org.hibernate.metamodel.domain.Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Version version) { + XMLVersion version) { super( defaults, attribute, entityMetaAttributes, version ); this.isLazy = false; @@ -89,7 +94,7 @@ public HbmSimpleAttributeDomainState(MappingDefaults defaults, public HbmSimpleAttributeDomainState(MappingDefaults defaults, org.hibernate.metamodel.domain.Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Timestamp timestamp) { + XMLTimestamp timestamp) { super( defaults, attribute, entityMetaAttributes, timestamp ); this.isLazy = false; @@ -108,7 +113,7 @@ public HbmSimpleAttributeDomainState(MappingDefaults defaults, public HbmSimpleAttributeDomainState(MappingDefaults defaults, org.hibernate.metamodel.domain.Attribute attribute, Map entityMetaAttributes, - org.hibernate.metamodel.source.hbm.xml.mapping.Property property) { + XMLProperty property) { super( defaults, attribute, entityMetaAttributes, property ); this.isLazy = MappingHelper.getBooleanValue( property.getLazy(), false ); ; diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmColumnRelationalState.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmColumnRelationalState.java index 01e5ef309e..8ee8608b9e 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmColumnRelationalState.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmColumnRelationalState.java @@ -29,6 +29,12 @@ import org.hibernate.cfg.NamingStrategy; import org.hibernate.metamodel.binding.SimpleAttributeBinding; import org.hibernate.metamodel.relational.Size; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLDiscriminator; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLId; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLProperty; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLTimestamp; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLVersion; import org.hibernate.metamodel.source.util.MappingHelper; // TODO: remove duplication after Id, Discriminator, Version, Timestamp, and Property extend a common interface. @@ -52,7 +58,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe private final Set indexes; /* package-protected */ - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.ColumnElement columnElement, + HbmColumnRelationalState(XMLColumnElement columnElement, HbmSimpleValueRelationalStateContainer container) { this.container = container; this.explicitColumnName = columnElement.getName(); @@ -74,7 +80,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe this.indexes.addAll( container.getPropertyIndexes() ); } - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.Property property, + HbmColumnRelationalState(XMLProperty property, HbmSimpleValueRelationalStateContainer container) { this.container = container; this.explicitColumnName = property.getName(); @@ -93,7 +99,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe this.indexes.addAll( container.getPropertyIndexes() ); } - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.Id id, + HbmColumnRelationalState(XMLId id, HbmSimpleValueRelationalStateContainer container) { if ( id.getColumnElement() != null && ! id.getColumnElement().isEmpty() ) { throw new IllegalArgumentException( "This method should not be called with non-empty id.getColumnElement()" ); @@ -113,7 +119,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe this.indexes = container.getPropertyIndexes(); } - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator, + HbmColumnRelationalState(XMLDiscriminator discriminator, HbmSimpleValueRelationalStateContainer container) { if ( discriminator.getColumnElement() != null ) { throw new IllegalArgumentException( "This method should not be called with null discriminator.getColumnElement()" ); @@ -133,7 +139,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe this.indexes = container.getPropertyIndexes(); } - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.Version version, + HbmColumnRelationalState(XMLVersion version, HbmSimpleValueRelationalStateContainer container) { this.container = container; this.explicitColumnName = version.getColumn(); @@ -154,7 +160,7 @@ public class HbmColumnRelationalState implements SimpleAttributeBinding.ColumnRe this.indexes = container.getPropertyIndexes(); } - HbmColumnRelationalState(org.hibernate.metamodel.source.hbm.xml.mapping.Timestamp timestamp, + HbmColumnRelationalState(XMLTimestamp timestamp, HbmSimpleValueRelationalStateContainer container) { this.container = container; this.explicitColumnName = timestamp.getColumn(); diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmSimpleValueRelationalStateContainer.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmSimpleValueRelationalStateContainer.java index 4d2805ac89..74a2b803e1 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmSimpleValueRelationalStateContainer.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/hbm/state/relational/HbmSimpleValueRelationalStateContainer.java @@ -32,6 +32,12 @@ import org.hibernate.cfg.NamingStrategy; import org.hibernate.metamodel.binding.MappingDefaults; import org.hibernate.metamodel.binding.SimpleAttributeBinding; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLDiscriminator; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLId; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLProperty; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLTimestamp; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLVersion; /** * @author Gail Badner @@ -50,7 +56,7 @@ public NamingStrategy getNamingStrategy() { public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, boolean autoColumnCreation, - org.hibernate.metamodel.source.hbm.xml.mapping.Id id) { + XMLId id) { this( defaults, id.getColumnElement() ); if ( singleValueStates.isEmpty() ) { if ( id.getColumn() == null && ! autoColumnCreation ) { @@ -65,7 +71,7 @@ else if ( id.getColumn() != null ) { public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, boolean autoColumnCreation, - org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator) { + XMLDiscriminator discriminator) { this( defaults, discriminator.getFormulaElement(), discriminator.getColumnElement() ); if ( singleValueStates.isEmpty() ) { if ( discriminator.getColumn() == null && discriminator.getFormula() == null && ! autoColumnCreation ) { @@ -80,7 +86,7 @@ else if ( discriminator.getColumn() != null || discriminator.getFormula() != nul public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, boolean autoColumnCreation, - org.hibernate.metamodel.source.hbm.xml.mapping.Version version) { + XMLVersion version) { this( defaults, version.getColumnElement() ); if ( singleValueStates.isEmpty() ) { if ( version.getColumn() == null && ! autoColumnCreation ) { @@ -95,7 +101,7 @@ else if ( version.getColumn() != null ) { public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, boolean autoColumnCreation, - org.hibernate.metamodel.source.hbm.xml.mapping.Timestamp timestamp) { + XMLTimestamp timestamp) { this( defaults, null ); if ( singleValueStates.isEmpty() ) { if ( timestamp.getColumn() == null && ! autoColumnCreation ) { @@ -110,7 +116,7 @@ else if ( timestamp.getColumn() != null ) { public HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, boolean autoColumnCreation, - org.hibernate.metamodel.source.hbm.xml.mapping.Property property) { + XMLProperty property) { this( defaults, property.getColumnElementOrFormulaElement() ); if ( singleValueStates.isEmpty() ) { if ( property.getColumn() == null && property.getFormula() == null && ! autoColumnCreation ) { @@ -125,7 +131,7 @@ else if ( property.getColumn() != null || property.getFormula() != null) { private HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, String formulaElement, - org.hibernate.metamodel.source.hbm.xml.mapping.ColumnElement columnElement + XMLColumnElement columnElement ) { this( defaults, formulaElement != null ? @@ -154,9 +160,9 @@ private HbmSimpleValueRelationalStateContainer(MappingDefaults defaults, private static SimpleAttributeBinding.SingleValueRelationalState createColumnOrFormulaRelationalState( HbmSimpleValueRelationalStateContainer container, Object columnOrFormula) { - if ( org.hibernate.metamodel.source.hbm.xml.mapping.ColumnElement.class.isInstance( columnOrFormula ) ) { + if ( XMLColumnElement.class.isInstance( columnOrFormula ) ) { return new HbmColumnRelationalState( - org.hibernate.metamodel.source.hbm.xml.mapping.ColumnElement.class.cast( columnOrFormula ), + XMLColumnElement.class.cast( columnOrFormula ), container ); } diff --git a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java index 1e153ee10e..fe049b9bee 100644 --- a/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java +++ b/hibernate-core/src/main/java/org/hibernate/metamodel/source/internal/JaxbHelper.java @@ -51,8 +51,8 @@ import org.hibernate.metamodel.source.MetadataSources; import org.hibernate.metamodel.source.Origin; import org.hibernate.metamodel.source.XsdException; -import org.hibernate.metamodel.source.annotation.xml.EntityMappings; -import org.hibernate.metamodel.source.hbm.xml.mapping.HibernateMapping; +import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings; +import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping; import org.hibernate.service.classloading.spi.ClassLoaderService; /** @@ -132,11 +132,11 @@ private JaxbRoot unmarshal(XMLEventReader staxEventReader, Origin origin) { final Attribute attribute = event.asStartElement().getAttributeByName( ORM_VERSION_ATTRIBUTE_QNAME ); final String explicitVersion = attribute == null ? null : attribute.getValue(); validationSchema = resolveSupportedOrmXsd( explicitVersion ); - jaxbTarget = EntityMappings.class; + jaxbTarget = XMLEntityMappings.class; } else { validationSchema = hbmSchema(); - jaxbTarget = HibernateMapping.class; + jaxbTarget = XMLHibernateMapping.class; } final Object target; @@ -166,11 +166,11 @@ public JaxbRoot unmarshal(Document document, Origin origin) { if ( "entity-mappings".equals( rootElement.getNodeName() ) ) { final String explicitVersion = rootElement.getAttribute( "version" ); validationSchema = resolveSupportedOrmXsd( explicitVersion ); - jaxbTarget = EntityMappings.class; + jaxbTarget = XMLEntityMappings.class; } else { validationSchema = hbmSchema(); - jaxbTarget = HibernateMapping.class; + jaxbTarget = XMLHibernateMapping.class; } final Object target;