HH-6131 : Updates for "XML" prefix for jaxb-generated classes

This commit is contained in:
Gail Badner 2011-04-19 14:29:03 -07:00
parent 0362f64ba9
commit bd82732dee
16 changed files with 185 additions and 145 deletions

View File

@ -25,8 +25,6 @@ package org.hibernate;
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.

View File

@ -25,7 +25,6 @@ package org.hibernate.metamodel.binding;
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.domain.MetaAttribute;
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<String> 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 @@ public class EntityBinding {
}
// 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 @@ public class EntityBinding {
);
}
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 @@ public class EntityBinding {
);
}
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 @@ public class EntityBinding {
}
if ( entityClazz.getSynchronize() != null ) {
for ( org.hibernate.metamodel.source.hbm.xml.mapping.Synchronize synchronize : entityClazz.getSynchronize() ) {
for ( XMLSynchronize synchronize : entityClazz.getSynchronize() ) {
addSynchronizedTable( synchronize.getTable() );
}
}

View File

@ -9,7 +9,7 @@ import org.jboss.jandex.Index;
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 class OrmXmlParser {
Set<InputStream> mappingStreams = new HashSet<InputStream>();
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 ) {

View File

@ -47,6 +47,7 @@ import org.hibernate.metamodel.relational.Schema;
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 @@ abstract class AbstractEntityBinder {
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 @@ abstract class AbstractEntityBinder {
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 @@ abstract class AbstractEntityBinder {
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 @@ abstract class AbstractEntityBinder {
}
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 @@ abstract class AbstractEntityBinder {
*
* @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 @@ abstract class AbstractEntityBinder {
}
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 @@ abstract class AbstractEntityBinder {
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 @@ abstract class AbstractEntityBinder {
* @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 @@ abstract class AbstractEntityBinder {
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 @@ abstract class AbstractEntityBinder {
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 @@ PrimitiveArray
}
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 @@ PrimitiveArray
}
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 @@ PrimitiveArray
}
}
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 @@ PrimitiveArray
}
}
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 @@ PrimitiveArray
}
}
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 @@ PrimitiveArray
}
}
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 @@ PrimitiveArray
}
protected void bindBag(
org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection,
XMLBag collection,
PluralAttributeBinding collectionBinding,
EntityBinding entityBinding) {
if ( collectionBinding.getAttribute() == null ) {

View File

@ -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.dom4j.Element;
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 class HbmHelper {
return ExecuteUpdateResultCheckStyle.parse( check );
}
public static final Map<String, MetaAttribute> extractMetas(List<org.hibernate.metamodel.source.hbm.xml.mapping.Meta> meta, Map<String, MetaAttribute> baseline) {
public static final Map<String, MetaAttribute> extractMetas(List<XMLMeta> meta, Map<String, MetaAttribute> baseline) {
return extractMetas( meta, false, baseline );
}
public static final Map<String, MetaAttribute> extractMetas(List<org.hibernate.metamodel.source.hbm.xml.mapping.Meta> metaList, boolean onlyInheritable, Map<String, MetaAttribute> baseline) {
public static final Map<String, MetaAttribute> extractMetas(List<XMLMeta> metaList, boolean onlyInheritable, Map<String, MetaAttribute> baseline) {
Map<String, MetaAttribute> extractedMetas = new HashMap<String, MetaAttribute>();
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 class HbmHelper {
return extractedMetas;
}
public static String extractEntityName( org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz, String unqualifiedPackageName) {
public static String extractEntityName( XMLClass entityClazz, String unqualifiedPackageName) {
String entityName = entityClazz.getEntityName();
return entityName == null ? getClassName( entityClazz.getName(), unqualifiedPackageName ) : entityName;
}

View File

@ -36,7 +36,16 @@ import org.hibernate.metamodel.binding.MappingDefaults;
import org.hibernate.metamodel.domain.MetaAttribute;
import org.hibernate.metamodel.source.Origin;
import org.hibernate.metamodel.source.internal.JaxbRoot;
import org.hibernate.metamodel.source.hbm.xml.mapping.HibernateMapping;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLClass;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetch;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLFetchProfile;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLImport;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLJoinedSubclass;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLQuery;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlQuery;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSubclass;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLUnionSubclass;
import org.hibernate.metamodel.source.util.MappingHelper;
/**
@ -44,8 +53,8 @@ import org.hibernate.metamodel.source.util.MappingHelper;
*/
class HibernateMappingBinder implements MappingDefaults {
private final HibernateXmlBinder hibernateXmlBinder;
private final JaxbRoot<HibernateMapping> jaxbRoot;
private final HibernateMapping hibernateMapping;
private final JaxbRoot<XMLHibernateMapping> jaxbRoot;
private final XMLHibernateMapping hibernateMapping;
private final String defaultSchemaName;
private final String defaultCatalogName;
@ -58,7 +67,7 @@ class HibernateMappingBinder implements MappingDefaults {
private Map<String, MetaAttribute> mappingMetas;
HibernateMappingBinder(HibernateXmlBinder hibernateXmlBinder, JaxbRoot<HibernateMapping> jaxbRoot) {
HibernateMappingBinder(HibernateXmlBinder hibernateXmlBinder, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
this.hibernateXmlBinder = hibernateXmlBinder;
this.jaxbRoot = jaxbRoot;
this.hibernateMapping = jaxbRoot.getRoot();
@ -79,7 +88,7 @@ class HibernateMappingBinder implements MappingDefaults {
return hibernateXmlBinder;
}
HibernateMapping getHibernateMapping() {
XMLHibernateMapping getHibernateMapping() {
return hibernateMapping;
}
@ -138,20 +147,20 @@ class HibernateMappingBinder implements MappingDefaults {
}
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 @@ class HibernateMappingBinder implements MappingDefaults {
}
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 @@ class HibernateMappingBinder implements MappingDefaults {
}
}
private void processImports(List<org.hibernate.metamodel.source.hbm.xml.mapping.Import> imports) {
for ( org.hibernate.metamodel.source.hbm.xml.mapping.Import importValue : imports ) {
private void processImports(List<XMLImport> 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 @@ class HibernateMappingBinder implements MappingDefaults {
}
}
protected void parseFetchProfiles(List<org.hibernate.metamodel.source.hbm.xml.mapping.FetchProfile> fetchProfiles, String containingEntityName) {
for ( org.hibernate.metamodel.source.hbm.xml.mapping.FetchProfile fetchProfile : fetchProfiles ) {
protected void parseFetchProfiles(List<XMLFetchProfile> 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 @@ class HibernateMappingBinder implements MappingDefaults {
}
}
String extractEntityName( org.hibernate.metamodel.source.hbm.xml.mapping.Class entityClazz) {
String extractEntityName( XMLClass entityClazz) {
return HbmHelper.extractEntityName( entityClazz, packageName );
}

View File

@ -24,15 +24,15 @@
package org.hibernate.metamodel.source.hbm;
import org.hibernate.metamodel.source.Origin;
import org.hibernate.metamodel.source.hbm.xml.mapping.HibernateMapping;
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
import org.hibernate.metamodel.source.internal.JaxbRoot;
/**
* @author Gail Badner
*/
public class HibernateMappingJaxbRoot extends JaxbRoot<HibernateMapping> {
public class HibernateMappingJaxbRoot extends JaxbRoot<XMLHibernateMapping> {
public HibernateMappingJaxbRoot(HibernateMapping root, Origin origin) {
public HibernateMappingJaxbRoot(XMLHibernateMapping root, Origin origin) {
super(root, origin);
}
}

View File

@ -41,7 +41,7 @@ import org.hibernate.internal.util.xml.XmlDocument;
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 class HibernateXmlBinder {
this.globalMetas = globalMetas;
}
public void bindRoot(JaxbRoot<HibernateMapping> jaxbRoot) {
public void bindRoot(JaxbRoot<XMLHibernateMapping> jaxbRoot) {
log.debug( jaxbRoot.toString() );
bindRoot( jaxbRoot, Collections.<String>emptySet() );
}
public void bindRoot(JaxbRoot<HibernateMapping> jaxbRoot, Set<String> entityNames) {
public void bindRoot(JaxbRoot<XMLHibernateMapping> jaxbRoot, Set<String> entityNames) {
final HibernateMappingBinder mappingBinder = new HibernateMappingBinder( this, jaxbRoot );
// this is irrelevant due to HHH-6118 and the fact that now all sources should be

View File

@ -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.Column;
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 @@ import org.hibernate.metamodel.source.util.MappingHelper;
*/
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 @@ class RootEntityBinder extends AbstractEntityBinder {
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 @@ class RootEntityBinder extends AbstractEntityBinder {
}
}
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 @@ class RootEntityBinder extends AbstractEntityBinder {
);
}
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 @@ class RootEntityBinder extends AbstractEntityBinder {
// 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 @@ class RootEntityBinder extends AbstractEntityBinder {
}
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 @@ class RootEntityBinder extends AbstractEntityBinder {
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 @@ class RootEntityBinder extends AbstractEntityBinder {
}
}
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;
}

View File

@ -32,6 +32,12 @@ import org.hibernate.metamodel.binding.MappingDefaults;
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<String, MetaAttribute> 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 abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
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 abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
public AbstractHbmAttributeDomainState(MappingDefaults defaults,
Attribute attribute,
Map<String, MetaAttribute> 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 abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
public AbstractHbmAttributeDomainState(MappingDefaults defaults,
Attribute attribute,
Map<String, MetaAttribute> 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 abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
public AbstractHbmAttributeDomainState(MappingDefaults defaults,
Attribute attribute,
Map<String, MetaAttribute> 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 abstract class AbstractHbmAttributeDomainState implements AbstractAttribu
public AbstractHbmAttributeDomainState(MappingDefaults defaults,
Attribute attribute,
Map<String, MetaAttribute> entityMetaAttributes,
org.hibernate.metamodel.source.hbm.xml.mapping.Bag collection) {
XMLBag collection) {
this.defaults = defaults;
this.attribute = attribute;
this.hibernateTypeDescriptor = new HibernateTypeDescriptor();

View File

@ -25,14 +25,15 @@ package org.hibernate.metamodel.source.hbm.state.domain;
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;
}

View File

@ -25,12 +25,9 @@ package org.hibernate.metamodel.source.hbm.state.domain;
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.binding.PluralAttributeBinding;
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 @@ import org.hibernate.metamodel.source.util.MappingHelper;
* @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<String, MetaAttribute> entityMetaAttributes,
Attribute attribute) {
super( defaults, attribute, entityMetaAttributes, collection );
@ -200,14 +204,14 @@ public class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainSta
}
public java.util.Set getSynchronizedTables() {
java.util.Set<String> synchronizedTables = new HashSet<String>();
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 class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainSta
);
}
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 class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainSta
);
}
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 class HbmPluralAttributeDomainState extends AbstractHbmAttributeDomainSta
);
}
public CustomSQL getCustomSQLDeleteAll() {
org.hibernate.metamodel.source.hbm.xml.mapping.SqlDeleteAll sqlDeleteAll = collection.getSqlDeleteAll();
XMLSqlDeleteAll sqlDeleteAll = collection.getSqlDeleteAll();
return sqlDeleteAll == null ?
null :
HbmHelper.getCustomSql(

View File

@ -30,6 +30,11 @@ import org.hibernate.mapping.PropertyGeneration;
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<String, MetaAttribute> 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 class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainSta
public HbmSimpleAttributeDomainState(MappingDefaults defaults,
org.hibernate.metamodel.domain.Attribute attribute,
Map<String, MetaAttribute> entityMetaAttributes,
org.hibernate.metamodel.source.hbm.xml.mapping.Discriminator discriminator) {
XMLDiscriminator discriminator) {
super( defaults, attribute, discriminator );
this.isLazy = false;
@ -70,7 +75,7 @@ public class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainSta
public HbmSimpleAttributeDomainState(MappingDefaults defaults,
org.hibernate.metamodel.domain.Attribute attribute,
Map<String, MetaAttribute> 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 class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainSta
public HbmSimpleAttributeDomainState(MappingDefaults defaults,
org.hibernate.metamodel.domain.Attribute attribute,
Map<String, MetaAttribute> 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 class HbmSimpleAttributeDomainState extends AbstractHbmAttributeDomainSta
public HbmSimpleAttributeDomainState(MappingDefaults defaults,
org.hibernate.metamodel.domain.Attribute attribute,
Map<String, MetaAttribute> entityMetaAttributes,
org.hibernate.metamodel.source.hbm.xml.mapping.Property property) {
XMLProperty property) {
super( defaults, attribute, entityMetaAttributes, property );
this.isLazy = MappingHelper.getBooleanValue( property.getLazy(), false );
;

View File

@ -29,6 +29,12 @@ import org.hibernate.MappingException;
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<String> 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();

View File

@ -32,6 +32,12 @@ import org.hibernate.MappingException;
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 class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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 @@ public class HbmSimpleValueRelationalStateContainer implements SimpleAttributeBi
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
);
}

View File

@ -51,8 +51,8 @@ import org.hibernate.metamodel.source.MappingException;
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 @@ public class JaxbHelper {
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 class JaxbHelper {
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;