HHH-6371 - Develop metamodel binding creation using a push approach
This commit is contained in:
parent
9e95d41689
commit
a7179fbc49
|
@ -51,8 +51,11 @@ public @interface Entity {
|
|||
boolean selectBeforeUpdate() default false;
|
||||
/** polymorphism strategy for this entity */
|
||||
PolymorphismType polymorphism() default PolymorphismType.IMPLICIT;
|
||||
/** persister of this entity, default is hibernate internal one */
|
||||
String persister() default "";
|
||||
/** optimistic locking strategy */
|
||||
OptimisticLockType optimisticLock() default OptimisticLockType.VERSION;
|
||||
/**
|
||||
* persister of this entity, default is hibernate internal one
|
||||
* @deprecated use {@link Persister} instead
|
||||
*/
|
||||
String persister() default "";
|
||||
}
|
||||
|
|
|
@ -30,6 +30,9 @@ import org.hibernate.MappingException;
|
|||
* @author Emmanuel Bernard
|
||||
*/
|
||||
public class NotYetImplementedException extends MappingException {
|
||||
public NotYetImplementedException() {
|
||||
this( "Not yet implemented!" );
|
||||
}
|
||||
|
||||
public NotYetImplementedException(String msg, Throwable root) {
|
||||
super( msg, root );
|
||||
|
|
|
@ -31,14 +31,11 @@ import org.jboss.jandex.Index;
|
|||
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClass;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.EntityBinder;
|
||||
import org.hibernate.metamodel.binder.source.internal.OverriddenMappingDefaults;
|
||||
import org.hibernate.metamodel.binding.EntityBinding;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
||||
|
@ -52,7 +49,7 @@ public class AnnotationsMetadataProcessor implements AnnotationsBindingContext {
|
|||
|
||||
private final MappingDefaults mappingDefaults;
|
||||
|
||||
private final org.hibernate.metamodel.binder.EntityBinder entityBinder;
|
||||
private final EntityBinder entityBinder;
|
||||
|
||||
public AnnotationsMetadataProcessor(
|
||||
AnnotationsBindingContext parentBindingContext,
|
||||
|
@ -84,41 +81,12 @@ public class AnnotationsMetadataProcessor implements AnnotationsBindingContext {
|
|||
null // association laziness
|
||||
);
|
||||
|
||||
this.entityBinder = new org.hibernate.metamodel.binder.EntityBinder( this );
|
||||
this.entityBinder = new EntityBinder( configuredClass, this );
|
||||
}
|
||||
|
||||
|
||||
public void processMappingMetadata(List<String> processedEntityNames) {
|
||||
final EntityDescriptor entityDescriptor;
|
||||
switch ( configuredClass.getInheritanceType() ) {
|
||||
case NO_INHERITANCE: {
|
||||
entityDescriptor = new RootEntityDescriptorImpl( configuredClass, this );
|
||||
break;
|
||||
}
|
||||
// else if ( XMLSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new DiscriminatedSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
// else if ( XMLJoinedSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new JoinedSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
// else if ( XMLUnionSubclassElement.class.isInstance( entityElement ) ) {
|
||||
// entityDescriptor = new UnionSubClassEntityDescriptorImpl( entityElement, this );
|
||||
// }
|
||||
default: {
|
||||
throw new MappingException(
|
||||
"unknown type of class or subclass: " + configuredClass.getName(),
|
||||
null
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if ( processedEntityNames.contains( configuredClass.getName() ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
final EntityBinding entityBinding = entityBinder.createEntityBinding( entityDescriptor );
|
||||
getMetadataImplementor().addEntity( entityBinding );
|
||||
processedEntityNames.add( configuredClass.getName() );
|
||||
entityBinder.bind( processedEntityNames );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -176,8 +176,8 @@ public class AnnotationsSourceProcessor implements SourceProcessor, AnnotationsB
|
|||
// for classes annotated w/ @Entity we create a EntityBinding
|
||||
if ( ConfiguredClassType.ENTITY.equals( entityClass.getConfiguredClassType() ) ) {
|
||||
LOG.debugf( "Binding entity from annotated class: %s", entityClass.getName() );
|
||||
EntityBinder entityBinder = new EntityBinder( metadata, entityClass, parent );
|
||||
EntityBinding binding = entityBinder.bind();
|
||||
EntityBinder entityBinder = new EntityBinder( entityClass, parent, this );
|
||||
EntityBinding binding = entityBinder.bind( processedEntityNames );
|
||||
parent = binding.getEntity();
|
||||
}
|
||||
// for classes annotated w/ @MappedSuperclass we just create the domain instance
|
||||
|
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -30,8 +31,6 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.DotName;
|
||||
|
@ -41,7 +40,6 @@ import org.hibernate.AssertionFailure;
|
|||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
||||
/**
|
||||
* Given a (jandex) annotation index build processes all classes with JPA relevant annotations and pre-orders
|
||||
|
@ -55,15 +53,14 @@ public class ConfiguredClassHierarchyBuilder {
|
|||
* Pre-processes the annotated entities from the index and put them into a structure which can
|
||||
* bound to the Hibernate metamodel.
|
||||
*
|
||||
* @param context the annotation binding context with access to the service registry and the annotation index
|
||||
* @param bindingContext The binding context, giving access to needed services and information
|
||||
*
|
||||
* @return a set of {@code ConfiguredClassHierarchy}s. One for each "leaf" entity.
|
||||
*/
|
||||
public static Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(AnnotationsBindingContext context) {
|
||||
ClassLoaderService classLoaderService = context.getServiceRegistry().getService( ClassLoaderService.class );
|
||||
public static Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(AnnotationsBindingContext bindingContext) {
|
||||
Map<ClassInfo, List<ClassInfo>> processedClassInfos = new HashMap<ClassInfo, List<ClassInfo>>();
|
||||
|
||||
for ( ClassInfo info : context.getIndex().getKnownClasses() ) {
|
||||
for ( ClassInfo info : bindingContext.getIndex().getKnownClasses() ) {
|
||||
if ( !isEntityClass( info ) ) {
|
||||
continue;
|
||||
}
|
||||
|
@ -74,9 +71,9 @@ public class ConfiguredClassHierarchyBuilder {
|
|||
|
||||
List<ClassInfo> configuredClassList = new ArrayList<ClassInfo>();
|
||||
ClassInfo tmpClassInfo = info;
|
||||
Class<?> clazz = classLoaderService.classForName( tmpClassInfo.toString() );
|
||||
Class<?> clazz = bindingContext.locateClassByName( tmpClassInfo.toString() );
|
||||
while ( clazz != null && !clazz.equals( Object.class ) ) {
|
||||
tmpClassInfo = context.getIndex().getClassByName( DotName.createSimple( clazz.getName() ) );
|
||||
tmpClassInfo = bindingContext.getIndex().getClassByName( DotName.createSimple( clazz.getName() ) );
|
||||
clazz = clazz.getSuperclass();
|
||||
if ( tmpClassInfo == null ) {
|
||||
continue;
|
||||
|
@ -101,7 +98,7 @@ public class ConfiguredClassHierarchyBuilder {
|
|||
List<List<ClassInfo>> processedList = new ArrayList<List<ClassInfo>>();
|
||||
for ( List<ClassInfo> classInfoList : processedClassInfos.values() ) {
|
||||
if ( !processedList.contains( classInfoList ) ) {
|
||||
hierarchies.add( ConfiguredClassHierarchy.createEntityClassHierarchy( classInfoList, context ) );
|
||||
hierarchies.add( ConfiguredClassHierarchy.createEntityClassHierarchy( classInfoList, bindingContext ) );
|
||||
processedList.add( classInfoList );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.annotations;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UnknownInheritanceTypeException extends HibernateException {
|
||||
public UnknownInheritanceTypeException(String message) {
|
||||
super( message );
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,316 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
import org.hibernate.metamodel.binder.Origin;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.UnifiedDescriptorObject;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlDeleteElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlInsertElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSqlUpdateElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSynchronizeElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLTuplizerElement;
|
||||
import org.hibernate.persister.entity.EntityPersister;
|
||||
import org.hibernate.tuple.entity.EntityTuplizer;
|
||||
|
||||
/**
|
||||
* Convenience base class for handling commonality between the different type of {@link EntityDescriptor}
|
||||
* implementations.
|
||||
*
|
||||
* @author Gail Badner
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public abstract class AbstractEntityDescriptorImpl implements EntityDescriptor {
|
||||
private final HbmBindingContext bindingContext;
|
||||
|
||||
private final String entityName;
|
||||
private final EntityMode entityMode;
|
||||
|
||||
private final String className;
|
||||
private final String proxyInterfaceName;
|
||||
|
||||
private final Class<EntityPersister> entityPersisterClass;
|
||||
private final Class<EntityTuplizer> tuplizerClass;
|
||||
|
||||
private final MetaAttributeContext metaAttributeContext;
|
||||
|
||||
private final String superEntityName;
|
||||
private final InheritanceType entityInheritanceType;
|
||||
|
||||
private final boolean lazy;
|
||||
|
||||
private final boolean dynamicUpdate;
|
||||
private final boolean dynamicInsert;
|
||||
|
||||
private final int batchSize;
|
||||
private final boolean selectBeforeUpdate;
|
||||
|
||||
private final Boolean isAbstract;
|
||||
|
||||
private final String customLoaderName;
|
||||
private final CustomSQL customInsert;
|
||||
private final CustomSQL customUpdate;
|
||||
private final CustomSQL customDelete;
|
||||
|
||||
private final Set<String> synchronizedTableNames;
|
||||
|
||||
|
||||
public AbstractEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
String superEntityName,
|
||||
InheritanceType inheritanceType,
|
||||
HbmBindingContext bindingContext) {
|
||||
|
||||
this.bindingContext = bindingContext;
|
||||
|
||||
this.superEntityName = superEntityName;
|
||||
this.entityName = bindingContext.determineEntityName( entityClazz );
|
||||
|
||||
final String verbatimClassName = entityClazz.getName();
|
||||
this.entityMode = verbatimClassName == null ? EntityMode.MAP : EntityMode.POJO;
|
||||
|
||||
if ( this.entityMode == EntityMode.POJO ) {
|
||||
this.className = bindingContext.qualifyClassName( verbatimClassName );
|
||||
this.proxyInterfaceName = entityClazz.getProxy();
|
||||
}
|
||||
else {
|
||||
this.className = null;
|
||||
this.proxyInterfaceName = null;
|
||||
}
|
||||
|
||||
final String customTuplizerClassName = extractCustomTuplizerClassName( entityClazz, entityMode );
|
||||
this.tuplizerClass = customTuplizerClassName != null
|
||||
? bindingContext.<EntityTuplizer>locateClassByName( customTuplizerClassName )
|
||||
: null;
|
||||
this.entityPersisterClass = entityClazz.getPersister() == null
|
||||
? null
|
||||
: bindingContext.<EntityPersister>locateClassByName( entityClazz.getPersister() );
|
||||
|
||||
this.entityInheritanceType = inheritanceType;
|
||||
|
||||
|
||||
this.metaAttributeContext = HbmHelper.extractMetaAttributeContext(
|
||||
entityClazz.getMeta(), true, bindingContext.getMetaAttributeContext()
|
||||
);
|
||||
|
||||
// go ahead and set the lazy here, since pojo.proxy can override it.
|
||||
this.lazy = MappingHelper.getBooleanValue(
|
||||
entityClazz.isLazy(), bindingContext.getMappingDefaults().areAssociationsLazy()
|
||||
);
|
||||
|
||||
this.dynamicUpdate = entityClazz.isDynamicUpdate();
|
||||
this.dynamicInsert = entityClazz.isDynamicInsert();
|
||||
this.batchSize = MappingHelper.getIntValue( entityClazz.getBatchSize(), 0 );
|
||||
this.selectBeforeUpdate = entityClazz.isSelectBeforeUpdate();
|
||||
|
||||
this.customLoaderName = entityClazz.getLoader().getQueryRef();
|
||||
|
||||
XMLSqlInsertElement sqlInsert = entityClazz.getSqlInsert();
|
||||
if ( sqlInsert != null ) {
|
||||
this.customInsert = HbmHelper.getCustomSql(
|
||||
sqlInsert.getValue(),
|
||||
sqlInsert.isCallable(),
|
||||
sqlInsert.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
this.customInsert = null;
|
||||
}
|
||||
|
||||
XMLSqlDeleteElement sqlDelete = entityClazz.getSqlDelete();
|
||||
if ( sqlDelete != null ) {
|
||||
this.customDelete = HbmHelper.getCustomSql(
|
||||
sqlDelete.getValue(),
|
||||
sqlDelete.isCallable(),
|
||||
sqlDelete.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
this.customDelete = null;
|
||||
}
|
||||
|
||||
XMLSqlUpdateElement sqlUpdate = entityClazz.getSqlUpdate();
|
||||
if ( sqlUpdate != null ) {
|
||||
this.customUpdate = HbmHelper.getCustomSql(
|
||||
sqlUpdate.getValue(),
|
||||
sqlUpdate.isCallable(),
|
||||
sqlUpdate.getCheck().value()
|
||||
);
|
||||
}
|
||||
else {
|
||||
this.customUpdate = null;
|
||||
}
|
||||
|
||||
if ( entityClazz.getSynchronize() != null ) {
|
||||
this.synchronizedTableNames = new HashSet<String>( entityClazz.getSynchronize().size() );
|
||||
for ( XMLSynchronizeElement synchronize : entityClazz.getSynchronize() ) {
|
||||
this.synchronizedTableNames.add( synchronize.getTable() );
|
||||
}
|
||||
}
|
||||
else {
|
||||
this.synchronizedTableNames = null;
|
||||
}
|
||||
|
||||
this.isAbstract = entityClazz.isAbstract();
|
||||
}
|
||||
|
||||
protected boolean isRoot() {
|
||||
return entityInheritanceType == InheritanceType.NO_INHERITANCE;
|
||||
}
|
||||
|
||||
private String extractCustomTuplizerClassName(EntityElement entityMapping, EntityMode entityMode) {
|
||||
if ( entityMapping.getTuplizer() == null ) {
|
||||
return null;
|
||||
}
|
||||
for ( XMLTuplizerElement tuplizerElement : entityMapping.getTuplizer() ) {
|
||||
if ( entityMode == EntityMode.parse( tuplizerElement.getEntityMode() ) ) {
|
||||
return tuplizerElement.getClazz();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getEntityName() {
|
||||
return entityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getJpaEntityName() {
|
||||
return null; // no such notion in hbm.xml files
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityMode getEntityMode() {
|
||||
return entityMode;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getClassName() {
|
||||
return className;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProxyInterfaceName() {
|
||||
return proxyInterfaceName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EntityPersister> getCustomEntityPersisterClass() {
|
||||
return entityPersisterClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<EntityTuplizer> getCustomEntityTuplizerClass() {
|
||||
return tuplizerClass;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuperEntityName() {
|
||||
return superEntityName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InheritanceType getEntityInheritanceType() {
|
||||
return entityInheritanceType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return metaAttributeContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isLazy() {
|
||||
return lazy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamicUpdate() {
|
||||
return dynamicUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDynamicInsert() {
|
||||
return dynamicInsert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getBatchSize() {
|
||||
return batchSize;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSelectBeforeUpdate() {
|
||||
return selectBeforeUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean isAbstract() {
|
||||
return isAbstract;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomInsert() {
|
||||
return customInsert;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomUpdate() {
|
||||
return customUpdate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CustomSQL getCustomDelete() {
|
||||
return customDelete;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<String> getSynchronizedTableNames() {
|
||||
return synchronizedTableNames;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCustomLoaderName() {
|
||||
return customLoaderName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDescriptorObject getContainingDescriptor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
return bindingContext.getOrigin();
|
||||
}
|
||||
}
|
|
@ -23,6 +23,7 @@
|
|||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.hibernate.EntityMode;
|
||||
|
@ -54,12 +55,27 @@ import org.hibernate.tuple.entity.EntityTuplizer;
|
|||
*/
|
||||
public class BindingCreator {
|
||||
private final HbmBindingContext bindingContext;
|
||||
private final List<String> processedEntityNames;
|
||||
|
||||
public BindingCreator(HbmBindingContext bindingContext) {
|
||||
public BindingCreator(HbmBindingContext bindingContext, List<String> processedEntityNames) {
|
||||
this.bindingContext = bindingContext;
|
||||
this.processedEntityNames = processedEntityNames;
|
||||
}
|
||||
|
||||
public EntityBinding createEntityBinding(EntityElement entityElement, String containingSuperEntityName) {
|
||||
final String entityName = bindingContext.determineEntityName( entityElement );
|
||||
if ( processedEntityNames.contains( entityName ) ) {
|
||||
return bindingContext.getMetadataImplementor().getEntityBinding( entityName );
|
||||
}
|
||||
|
||||
final EntityBinding entityBinding = doEntityBindingCreation( entityElement, containingSuperEntityName );
|
||||
|
||||
bindingContext.getMetadataImplementor().addEntity( entityBinding );
|
||||
processedEntityNames.add( entityBinding.getEntity().getName() );
|
||||
return entityBinding;
|
||||
}
|
||||
|
||||
private EntityBinding doEntityBindingCreation(EntityElement entityElement, String containingSuperEntityName) {
|
||||
if ( XMLHibernateMapping.XMLClass.class.isInstance( entityElement ) ) {
|
||||
return makeEntityBinding( (XMLHibernateMapping.XMLClass) entityElement );
|
||||
}
|
||||
|
@ -97,7 +113,11 @@ public class BindingCreator {
|
|||
|
||||
protected EntityBinding makeEntityBinding(XMLHibernateMapping.XMLClass xmlClass) {
|
||||
final EntityBinding entityBinding = new EntityBinding();
|
||||
// todo : this is actually not correct
|
||||
// the problem is that we need to know whether we have mapped subclasses which happens later
|
||||
// one option would be to simply reset the InheritanceType at that time.
|
||||
entityBinding.setInheritanceType( InheritanceType.NO_INHERITANCE );
|
||||
entityBinding.setRoot( true );
|
||||
|
||||
final String entityName = bindingContext.determineEntityName( xmlClass );
|
||||
final String verbatimClassName = xmlClass.getName();
|
||||
|
@ -140,7 +160,7 @@ public class BindingCreator {
|
|||
}
|
||||
|
||||
private OptimisticLockStyle interpretOptimisticLockStyle(XMLHibernateMapping.XMLClass entityClazz) {
|
||||
final String optimisticLockModeString = MappingHelper.getStringValue(
|
||||
final String optimisticLockModeString = Helper.getStringValue(
|
||||
entityClazz.getOptimisticLock(),
|
||||
"version"
|
||||
);
|
||||
|
@ -245,14 +265,16 @@ public class BindingCreator {
|
|||
entityBinding.setJpaEntityName( null );
|
||||
|
||||
final String proxy = entityElement.getProxy();
|
||||
final Boolean isLazy = entityElement.isLazy();
|
||||
final boolean isLazy = entityElement.isLazy() == null
|
||||
? true
|
||||
: entityElement.isLazy();
|
||||
if ( entityBinding.getEntityMode() == EntityMode.POJO ) {
|
||||
if ( proxy != null ) {
|
||||
entityBinding.setProxyInterfaceType( bindingContext.makeClassReference(
|
||||
bindingContext.qualifyClassName(
|
||||
proxy
|
||||
entityBinding.setProxyInterfaceType(
|
||||
bindingContext.makeClassReference(
|
||||
bindingContext.qualifyClassName( proxy )
|
||||
)
|
||||
) );
|
||||
);
|
||||
entityBinding.setLazy( true );
|
||||
}
|
||||
else if ( isLazy ) {
|
||||
|
@ -275,50 +297,34 @@ public class BindingCreator {
|
|||
}
|
||||
|
||||
entityBinding.setMetaAttributeContext(
|
||||
HbmHelper.extractMetaAttributeContext(
|
||||
Helper.extractMetaAttributeContext(
|
||||
entityElement.getMeta(), true, bindingContext.getMetaAttributeContext()
|
||||
)
|
||||
);
|
||||
|
||||
entityBinding.setDynamicUpdate( entityElement.isDynamicUpdate() );
|
||||
entityBinding.setDynamicInsert( entityElement.isDynamicInsert() );
|
||||
entityBinding.setBatchSize( MappingHelper.getIntValue( entityElement.getBatchSize(), 0 ) );
|
||||
entityBinding.setBatchSize( Helper.getIntValue( entityElement.getBatchSize(), 0 ) );
|
||||
entityBinding.setSelectBeforeUpdate( entityElement.isSelectBeforeUpdate() );
|
||||
entityBinding.setAbstract( entityElement.isAbstract() );
|
||||
|
||||
entityBinding.setCustomLoaderName( entityElement.getLoader().getQueryRef() );
|
||||
if ( entityElement.getLoader() != null ) {
|
||||
entityBinding.setCustomLoaderName( entityElement.getLoader().getQueryRef() );
|
||||
}
|
||||
|
||||
final XMLSqlInsertElement sqlInsert = entityElement.getSqlInsert();
|
||||
if ( sqlInsert != null ) {
|
||||
entityBinding.setCustomInsert(
|
||||
HbmHelper.getCustomSql(
|
||||
sqlInsert.getValue(),
|
||||
sqlInsert.isCallable(),
|
||||
sqlInsert.getCheck().value()
|
||||
)
|
||||
);
|
||||
entityBinding.setCustomInsert( Helper.buildCustomSql( sqlInsert ) );
|
||||
}
|
||||
|
||||
final XMLSqlDeleteElement sqlDelete = entityElement.getSqlDelete();
|
||||
if ( sqlDelete != null ) {
|
||||
entityBinding.setCustomDelete(
|
||||
HbmHelper.getCustomSql(
|
||||
sqlDelete.getValue(),
|
||||
sqlDelete.isCallable(),
|
||||
sqlDelete.getCheck().value()
|
||||
)
|
||||
);
|
||||
entityBinding.setCustomDelete( Helper.buildCustomSql( sqlDelete ) );
|
||||
}
|
||||
|
||||
final XMLSqlUpdateElement sqlUpdate = entityElement.getSqlUpdate();
|
||||
if ( sqlUpdate != null ) {
|
||||
entityBinding.setCustomUpdate(
|
||||
HbmHelper.getCustomSql(
|
||||
sqlUpdate.getValue(),
|
||||
sqlUpdate.isCallable(),
|
||||
sqlUpdate.getCheck().value()
|
||||
)
|
||||
);
|
||||
entityBinding.setCustomUpdate( Helper.buildCustomSql( sqlUpdate ) );
|
||||
}
|
||||
|
||||
if ( entityElement.getSynchronize() != null ) {
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.DiscriminatorSubClassEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLSubclassElement;
|
||||
|
||||
/**
|
||||
* Unified descriptor for discriminator-based inheritance strategies.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class DiscriminatedSubClassEntityDescriptorImpl
|
||||
extends AbstractEntityDescriptorImpl
|
||||
implements DiscriminatorSubClassEntityDescriptor {
|
||||
/**
|
||||
* This form used when an explicit {@code extends} attribute names this mapping's super entity.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public DiscriminatedSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
HbmBindingContext bindingContext) {
|
||||
this( entityClazz, extractExtendsName( entityClazz, bindingContext ), bindingContext );
|
||||
}
|
||||
|
||||
private static String extractExtendsName(EntityElement entityClazz, HbmBindingContext bindingContext) {
|
||||
final String extendsName = ( (XMLSubclassElement) entityClazz ).getExtends();
|
||||
if ( StringHelper.isEmpty( extendsName ) ) {
|
||||
throw new MappingException(
|
||||
"Subclass entity mapping [" + bindingContext.determineEntityName( entityClazz )
|
||||
+ "] was not contained in super entity mapping",
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
}
|
||||
return extendsName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This form would be used when the subclass definition if nested within its super type mapping.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param superEntityName The name of the containing (and thus super) entity
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public DiscriminatedSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
String superEntityName,
|
||||
HbmBindingContext bindingContext) {
|
||||
super( entityClazz, superEntityName, InheritanceType.SINGLE_TABLE, bindingContext );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,171 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.dom4j.Attribute;
|
||||
import org.dom4j.Element;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLHibernateMapping;
|
||||
import org.hibernate.metamodel.source.hbm.jaxb.mapping.XMLMetaElement;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class HbmHelper {
|
||||
|
||||
// todo : merge this and MappingHelper together
|
||||
|
||||
public static boolean isCallable(Element e) {
|
||||
return isCallable( e, true );
|
||||
}
|
||||
|
||||
public static boolean isCallable(Element element, boolean supportsCallable) {
|
||||
Attribute attrib = element.attribute( "callable" );
|
||||
if ( attrib != null && "true".equals( attrib.getValue() ) ) {
|
||||
if ( !supportsCallable ) {
|
||||
throw new MappingException( "callable attribute not supported yet!" );
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static ExecuteUpdateResultCheckStyle getResultCheckStyle(String check, boolean callable) {
|
||||
if ( check == null ) {
|
||||
// use COUNT as the default. This mimics the old behavior, although
|
||||
// NONE might be a better option moving forward in the case of callable
|
||||
return ExecuteUpdateResultCheckStyle.COUNT;
|
||||
}
|
||||
return ExecuteUpdateResultCheckStyle.fromExternalName( check );
|
||||
}
|
||||
|
||||
public static final Map<String, MetaAttribute> extractMetas(List<XMLMetaElement> meta, Map<String, MetaAttribute> baseline) {
|
||||
return extractMetas( meta, false, baseline );
|
||||
}
|
||||
|
||||
public static final Map<String, MetaAttribute> extractMetas(List<XMLMetaElement> metaList, boolean onlyInheritable, Map<String, MetaAttribute> baseline) {
|
||||
Map<String, MetaAttribute> extractedMetas = new HashMap<String, MetaAttribute>();
|
||||
extractedMetas.putAll( baseline );
|
||||
for ( XMLMetaElement meta : metaList ) {
|
||||
boolean inheritable = meta.isInherit();
|
||||
if ( onlyInheritable & !inheritable ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String name = meta.getAttribute();
|
||||
final MetaAttribute inheritedMetaAttribute = baseline.get( name );
|
||||
MetaAttribute metaAttribute = extractedMetas.get( name );
|
||||
if ( metaAttribute == null || metaAttribute == inheritedMetaAttribute ) {
|
||||
metaAttribute = new MetaAttribute( name );
|
||||
extractedMetas.put( name, metaAttribute );
|
||||
}
|
||||
metaAttribute.addValue( meta.getValue() );
|
||||
}
|
||||
return extractedMetas;
|
||||
}
|
||||
|
||||
public static String extractEntityName(XMLHibernateMapping.XMLClass entityClazz, String unqualifiedPackageName) {
|
||||
return extractEntityName( entityClazz.getEntityName(), entityClazz.getName(), unqualifiedPackageName );
|
||||
}
|
||||
|
||||
public static String extractEntityName(String entityName, String entityClassName, String unqualifiedPackageName) {
|
||||
return entityName == null ? getClassName( entityClassName, unqualifiedPackageName ) : entityName;
|
||||
}
|
||||
|
||||
public static String determineEntityName(EntityElement entityElement, String packageName) {
|
||||
return extractEntityName( entityElement.getEntityName(), entityElement.getName(), packageName );
|
||||
}
|
||||
|
||||
public static String determineClassName(EntityElement entityElement, String packageName) {
|
||||
return getClassName( entityElement.getName(), packageName );
|
||||
}
|
||||
|
||||
public static String getClassName(Attribute att, String unqualifiedPackageName) {
|
||||
if ( att == null ) {
|
||||
return null;
|
||||
}
|
||||
return getClassName( att.getValue(), unqualifiedPackageName );
|
||||
}
|
||||
|
||||
public static String getClassName(String unqualifiedName, String unqualifiedPackageName) {
|
||||
if ( unqualifiedName == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( unqualifiedName.indexOf( '.' ) < 0 && unqualifiedPackageName != null ) {
|
||||
return unqualifiedPackageName + '.' + unqualifiedName;
|
||||
}
|
||||
return unqualifiedName;
|
||||
}
|
||||
|
||||
public static CustomSQL getCustomSql(String sql, boolean isCallable, String check) {
|
||||
return new CustomSQL( sql.trim(), isCallable, getResultCheckStyle( check, isCallable ) );
|
||||
}
|
||||
|
||||
public static String getPropertyAccessorName(String access, boolean isEmbedded, String defaultAccess) {
|
||||
return MappingHelper.getStringValue(
|
||||
access,
|
||||
isEmbedded ? "embedded" : defaultAccess
|
||||
);
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
MetaAttributeContext parentContext) {
|
||||
return extractMetaAttributeContext( metaElementList, false, parentContext );
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
boolean onlyInheritable,
|
||||
MetaAttributeContext parentContext) {
|
||||
final MetaAttributeContext subContext = new MetaAttributeContext( parentContext );
|
||||
|
||||
for ( XMLMetaElement metaElement : metaElementList ) {
|
||||
if ( onlyInheritable & !metaElement.isInherit() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String name = metaElement.getAttribute();
|
||||
final MetaAttribute inheritedMetaAttribute = parentContext.getMetaAttribute( name );
|
||||
MetaAttribute metaAttribute = subContext.getLocalMetaAttribute( name );
|
||||
if ( metaAttribute == null || metaAttribute == inheritedMetaAttribute ) {
|
||||
metaAttribute = new MetaAttribute( name );
|
||||
subContext.add( metaAttribute );
|
||||
}
|
||||
metaAttribute.addValue( metaElement.getValue() );
|
||||
}
|
||||
|
||||
return subContext;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,176 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.engine.spi.ExecuteUpdateResultCheckStyle;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.CustomSqlElement;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.MetaAttribute;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLMetaElement;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.classloading.spi.ClassLoadingException;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class Helper {
|
||||
|
||||
/**
|
||||
* Given a user-specified description of how to perform custom SQL, build the {@link CustomSQL} representation.
|
||||
*
|
||||
* @param customSqlElement User-specified description of how to perform custom SQL
|
||||
*
|
||||
* @return The {@link CustomSQL} representation
|
||||
*/
|
||||
public static CustomSQL buildCustomSql(CustomSqlElement customSqlElement) {
|
||||
if ( customSqlElement == null ) {
|
||||
return null;
|
||||
}
|
||||
final ExecuteUpdateResultCheckStyle checkStyle = customSqlElement.getCheck() == null
|
||||
? customSqlElement.isCallable()
|
||||
? ExecuteUpdateResultCheckStyle.NONE
|
||||
: ExecuteUpdateResultCheckStyle.COUNT
|
||||
: ExecuteUpdateResultCheckStyle.fromExternalName( customSqlElement.getCheck().value() );
|
||||
return new CustomSQL( customSqlElement.getValue(), customSqlElement.isCallable(), checkStyle );
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the user-specified entity mapping, determine the appropriate entity name
|
||||
*
|
||||
* @param entityElement The user-specified entity mapping
|
||||
* @param unqualifiedClassPackage The package to use for unqualified class names
|
||||
*
|
||||
* @return The appropriate entity name
|
||||
*/
|
||||
public static String determineEntityName(EntityElement entityElement, String unqualifiedClassPackage) {
|
||||
return entityElement.getEntityName() != null
|
||||
? entityElement.getEntityName()
|
||||
: qualifyIfNeeded( entityElement.getName(), unqualifiedClassPackage );
|
||||
}
|
||||
|
||||
/**
|
||||
* Qualify a (supposed class) name with the unqualified-class package name if it is not already qualified
|
||||
*
|
||||
* @param name The name
|
||||
* @param unqualifiedClassPackage The unqualified-class package name
|
||||
*
|
||||
* @return {@code null} if the incoming name was {@code null}; or the qualified name.
|
||||
*/
|
||||
public static String qualifyIfNeeded(String name, String unqualifiedClassPackage) {
|
||||
if ( name == null ) {
|
||||
return null;
|
||||
}
|
||||
if ( name.indexOf( '.' ) < 0 && unqualifiedClassPackage != null ) {
|
||||
return unqualifiedClassPackage + '.' + name;
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
public static String getPropertyAccessorName(String access, boolean isEmbedded, String defaultAccess) {
|
||||
return getStringValue( access, isEmbedded ? "embedded" : defaultAccess );
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
MetaAttributeContext parentContext) {
|
||||
return extractMetaAttributeContext( metaElementList, false, parentContext );
|
||||
}
|
||||
|
||||
public static MetaAttributeContext extractMetaAttributeContext(
|
||||
List<XMLMetaElement> metaElementList,
|
||||
boolean onlyInheritable,
|
||||
MetaAttributeContext parentContext) {
|
||||
final MetaAttributeContext subContext = new MetaAttributeContext( parentContext );
|
||||
|
||||
for ( XMLMetaElement metaElement : metaElementList ) {
|
||||
if ( onlyInheritable & !metaElement.isInherit() ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final String name = metaElement.getAttribute();
|
||||
final MetaAttribute inheritedMetaAttribute = parentContext.getMetaAttribute( name );
|
||||
MetaAttribute metaAttribute = subContext.getLocalMetaAttribute( name );
|
||||
if ( metaAttribute == null || metaAttribute == inheritedMetaAttribute ) {
|
||||
metaAttribute = new MetaAttribute( name );
|
||||
subContext.add( metaAttribute );
|
||||
}
|
||||
metaAttribute.addValue( metaElement.getValue() );
|
||||
}
|
||||
|
||||
return subContext;
|
||||
}
|
||||
|
||||
public static String getStringValue(String value, String defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static int getIntValue(String value, int defaultValue) {
|
||||
return value == null ? defaultValue : Integer.parseInt( value );
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(String value, boolean defaultValue) {
|
||||
return value == null ? defaultValue : Boolean.valueOf( value );
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(Boolean value, boolean defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static Set<String> getStringValueTokens(String str, String delimiters) {
|
||||
if ( str == null ) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
else {
|
||||
StringTokenizer tokenizer = new StringTokenizer( str, delimiters );
|
||||
Set<String> tokens = new HashSet<String>();
|
||||
while ( tokenizer.hasMoreTokens() ) {
|
||||
tokens.add( tokenizer.nextToken() );
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
|
||||
// todo : remove this once the state objects are cleaned up
|
||||
|
||||
public static Class classForName(String className, ServiceRegistry serviceRegistry) {
|
||||
ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
try {
|
||||
return classLoaderService.classForName( className );
|
||||
}
|
||||
catch ( ClassLoadingException e ) {
|
||||
throw new MappingException( "Could not find class: " + className );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -76,9 +76,6 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
private final MappingDefaults mappingDefaults;
|
||||
private final MetaAttributeContext metaAttributeContext;
|
||||
|
||||
|
||||
private final BindingCreator bindingCreator;
|
||||
|
||||
private final boolean autoImport;
|
||||
|
||||
public HibernateMappingProcessor(HbmSourceProcessorImpl hbmHandler, JaxbRoot<XMLHibernateMapping> jaxbRoot) {
|
||||
|
@ -99,16 +96,18 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
);
|
||||
|
||||
this.autoImport = hibernateMapping.isAutoImport();
|
||||
|
||||
this.bindingCreator = new BindingCreator( this );
|
||||
|
||||
this.metaAttributeContext = extractMetaAttributes();
|
||||
}
|
||||
|
||||
private MetaAttributeContext extractMetaAttributes() {
|
||||
return hibernateMapping.getMeta() == null
|
||||
? new MetaAttributeContext( hbmHandler.getMetadataImplementor().getGlobalMetaAttributeContext() )
|
||||
: HbmHelper.extractMetaAttributeContext( hibernateMapping.getMeta(), true, hbmHandler.getMetadataImplementor().getGlobalMetaAttributeContext() );
|
||||
: Helper.extractMetaAttributeContext(
|
||||
hibernateMapping.getMeta(),
|
||||
true,
|
||||
hbmHandler.getMetadataImplementor()
|
||||
.getGlobalMetaAttributeContext()
|
||||
);
|
||||
}
|
||||
|
||||
XMLHibernateMapping getHibernateMapping() {
|
||||
|
@ -289,17 +288,11 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
return;
|
||||
}
|
||||
|
||||
final BindingCreator bindingCreator = new BindingCreator( this, processedEntityNames );
|
||||
|
||||
for ( Object entityElementO : hibernateMapping.getClazzOrSubclassOrJoinedSubclass() ) {
|
||||
final EntityElement entityElement = (EntityElement) entityElementO;
|
||||
|
||||
final String entityName = this.determineEntityName( entityElement );
|
||||
if ( processedEntityNames.contains( entityName ) ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
final EntityBinding entityBinding = bindingCreator.createEntityBinding( entityElement, null );
|
||||
getMetadataImplementor().addEntity( entityBinding );
|
||||
processedEntityNames.add( entityBinding.getEntity().getName() );
|
||||
bindingCreator.createEntityBinding( entityElement, null );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -386,11 +379,11 @@ public class HibernateMappingProcessor implements HbmBindingContext {
|
|||
|
||||
@Override
|
||||
public String qualifyClassName(String unqualifiedName) {
|
||||
return HbmHelper.getClassName( unqualifiedName, mappingDefaults.getPackageName() );
|
||||
return Helper.qualifyIfNeeded( unqualifiedName, mappingDefaults.getPackageName() );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String determineEntityName(EntityElement entityElement) {
|
||||
return HbmHelper.determineEntityName( entityElement, mappingDefaults.getPackageName() );
|
||||
return Helper.determineEntityName( entityElement, mappingDefaults.getPackageName() );
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.JoinedSubClassEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLJoinedSubclassElement;
|
||||
|
||||
import static org.hibernate.metamodel.binding.InheritanceType.JOINED;
|
||||
|
||||
/**
|
||||
* Unified descriptor for (SQL) join-based inheritance strategies.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class JoinedSubClassEntityDescriptorImpl
|
||||
extends AbstractEntityDescriptorImpl
|
||||
implements JoinedSubClassEntityDescriptor {
|
||||
|
||||
/**
|
||||
* This form used when an explicit {@code extends} attribute names this mapping's super entity.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public JoinedSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
HbmBindingContext bindingContext) {
|
||||
this( entityClazz, extractExtendsName( entityClazz, bindingContext ), bindingContext );
|
||||
}
|
||||
|
||||
private static String extractExtendsName(EntityElement entityClazz, HbmBindingContext bindingContext) {
|
||||
final String extendsName = ( (XMLJoinedSubclassElement) entityClazz ).getExtends();
|
||||
if ( StringHelper.isEmpty( extendsName ) ) {
|
||||
throw new MappingException(
|
||||
"Subclass entity mapping [" + bindingContext.determineEntityName( entityClazz )
|
||||
+ "] was not contained in super entity mapping",
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
}
|
||||
return extendsName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This form would be used when the subclass definition if nested within its super type mapping.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param superEntityName The name of the containing (and thus super) entity
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public JoinedSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
String superEntityName,
|
||||
HbmBindingContext bindingContext) {
|
||||
super( entityClazz, superEntityName, JOINED, bindingContext );
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.StringTokenizer;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.classloading.spi.ClassLoadingException;
|
||||
|
||||
/**
|
||||
* Helper class.
|
||||
*
|
||||
* @author Gail Badner
|
||||
*/
|
||||
public class MappingHelper {
|
||||
|
||||
// todo : merge this and HbmHelper together
|
||||
|
||||
private MappingHelper() {
|
||||
}
|
||||
|
||||
public static String getStringValue(String value, String defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static int getIntValue(String value, int defaultValue) {
|
||||
return value == null ? defaultValue : Integer.parseInt( value );
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(String value, boolean defaultValue) {
|
||||
return value == null ? defaultValue : Boolean.valueOf( value );
|
||||
}
|
||||
|
||||
public static boolean getBooleanValue(Boolean value, boolean defaultValue) {
|
||||
return value == null ? defaultValue : value;
|
||||
}
|
||||
|
||||
public static Set<String> getStringValueTokens(String str, String delimiters) {
|
||||
if ( str == null ) {
|
||||
return Collections.emptySet();
|
||||
}
|
||||
else {
|
||||
StringTokenizer tokenizer = new StringTokenizer( str, delimiters );
|
||||
Set<String> tokens = new HashSet<String>();
|
||||
while ( tokenizer.hasMoreTokens() ) {
|
||||
tokens.add( tokenizer.nextToken() );
|
||||
}
|
||||
return tokens;
|
||||
}
|
||||
}
|
||||
|
||||
public static Class classForName(String className, ServiceRegistry serviceRegistry) {
|
||||
ClassLoaderService classLoaderService = serviceRegistry.getService( ClassLoaderService.class );
|
||||
try {
|
||||
return classLoaderService.classForName( className );
|
||||
}
|
||||
catch ( ClassLoadingException e ) {
|
||||
throw new MappingException( "Could not find class: " + className );
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,134 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import org.hibernate.cache.spi.access.AccessType;
|
||||
import org.hibernate.engine.OptimisticLockStyle;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.RootEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.TableDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.binding.Caching;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLCacheElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
|
||||
/**
|
||||
* Unified descriptor for root entity (no inheritance strategy).
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class RootEntityDescriptorImpl extends AbstractEntityDescriptorImpl implements RootEntityDescriptor {
|
||||
private final boolean mutable;
|
||||
private final boolean explicitPolymorphism;
|
||||
private final String whereFilter;
|
||||
private final String rowId;
|
||||
private final Caching caching;
|
||||
private final OptimisticLockStyle optimisticLockStyle;
|
||||
|
||||
private final TableDescriptor baseTableDescriptor;
|
||||
|
||||
public RootEntityDescriptorImpl(EntityElement entityClazz, HbmBindingContext bindingContext) {
|
||||
super( entityClazz, null, InheritanceType.NO_INHERITANCE, bindingContext );
|
||||
|
||||
// the mapping has to be <class/>
|
||||
final XMLHibernateMapping.XMLClass xmlClass = (XMLHibernateMapping.XMLClass) entityClazz;
|
||||
|
||||
this.mutable = xmlClass.isMutable();
|
||||
this.explicitPolymorphism = "explicit".equals( xmlClass.getPolymorphism() );
|
||||
this.whereFilter = xmlClass.getWhere();
|
||||
this.rowId = xmlClass.getRowid();
|
||||
this.caching = interpretCaching( xmlClass, getEntityName() );
|
||||
this.optimisticLockStyle = interpretOptimisticLockStyle( xmlClass, bindingContext );
|
||||
|
||||
this.baseTableDescriptor = new TableDescriptorImpl(
|
||||
xmlClass.getSchema(),
|
||||
xmlClass.getCatalog(),
|
||||
xmlClass.getTable(),
|
||||
this,
|
||||
bindingContext
|
||||
);
|
||||
}
|
||||
|
||||
private static Caching interpretCaching(XMLHibernateMapping.XMLClass xmlClass, String entityName) {
|
||||
final XMLCacheElement cache = xmlClass.getCache();
|
||||
if ( cache == null ) {
|
||||
return null;
|
||||
}
|
||||
final String region = cache.getRegion() != null ? cache.getRegion() : entityName;
|
||||
final AccessType accessType = Enum.valueOf( AccessType.class, cache.getUsage() );
|
||||
final boolean cacheLazyProps = !"non-lazy".equals( cache.getInclude() );
|
||||
return new Caching( region, accessType, cacheLazyProps );
|
||||
}
|
||||
|
||||
private static OptimisticLockStyle interpretOptimisticLockStyle(
|
||||
XMLHibernateMapping.XMLClass entityClazz,
|
||||
HbmBindingContext bindingContext) {
|
||||
final String optimisticLockModeString = MappingHelper.getStringValue( entityClazz.getOptimisticLock(), "version" );
|
||||
try {
|
||||
return OptimisticLockStyle.valueOf( optimisticLockModeString.toUpperCase() );
|
||||
}
|
||||
catch (Exception e) {
|
||||
throw new MappingException(
|
||||
"Unknown optimistic-lock value : " + optimisticLockModeString,
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMutable() {
|
||||
return mutable;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isExplicitPolymorphism() {
|
||||
return explicitPolymorphism;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getWhereFilter() {
|
||||
return whereFilter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRowId() {
|
||||
return rowId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Caching getCaching() {
|
||||
return caching;
|
||||
}
|
||||
|
||||
@Override
|
||||
public OptimisticLockStyle getOptimisticLockStyle() {
|
||||
return optimisticLockStyle;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableDescriptor getBaseTable() {
|
||||
return baseTableDescriptor;
|
||||
}
|
||||
}
|
|
@ -1,86 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import org.hibernate.metamodel.binder.Origin;
|
||||
import org.hibernate.metamodel.binder.source.EntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.TableDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.UnifiedDescriptorObject;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TableDescriptorImpl implements TableDescriptor {
|
||||
private final String explicitSchemaName;
|
||||
private final String explicitCatalogName;
|
||||
private final String tableName;
|
||||
|
||||
private final EntityDescriptor entityDescriptor;
|
||||
private final HbmBindingContext bindingContext;
|
||||
|
||||
public TableDescriptorImpl(
|
||||
String explicitSchemaName,
|
||||
String explicitCatalogName,
|
||||
String tableName,
|
||||
EntityDescriptor entityDescriptor,
|
||||
HbmBindingContext bindingContext) {
|
||||
this.explicitSchemaName = explicitSchemaName;
|
||||
this.explicitCatalogName = explicitCatalogName;
|
||||
this.tableName = tableName;
|
||||
|
||||
this.entityDescriptor = entityDescriptor;
|
||||
this.bindingContext = bindingContext;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitSchemaName() {
|
||||
return explicitSchemaName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getExplicitCatalogName() {
|
||||
return explicitCatalogName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTableName() {
|
||||
return tableName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Origin getOrigin() {
|
||||
return bindingContext.getOrigin();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UnifiedDescriptorObject getContainingDescriptor() {
|
||||
return entityDescriptor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetaAttributeContext getMetaAttributeContext() {
|
||||
return bindingContext.getMetaAttributeContext();
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm;
|
||||
|
||||
import org.hibernate.internal.util.StringHelper;
|
||||
import org.hibernate.metamodel.binder.MappingException;
|
||||
import org.hibernate.metamodel.binder.source.JoinedSubClassEntityDescriptor;
|
||||
import org.hibernate.metamodel.binder.source.hbm.xml.mapping.EntityElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLUnionSubclassElement;
|
||||
|
||||
import static org.hibernate.metamodel.binding.InheritanceType.JOINED;
|
||||
|
||||
/**
|
||||
* Unified descriptor for (SQL) union-based inheritance strategies.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class UnionSubClassEntityDescriptorImpl
|
||||
extends AbstractEntityDescriptorImpl
|
||||
implements JoinedSubClassEntityDescriptor {
|
||||
|
||||
/**
|
||||
* This form used when an explicit {@code extends} attribute names this mapping's super entity.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public UnionSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
HbmBindingContext bindingContext) {
|
||||
this( entityClazz, extractExtendsName( entityClazz, bindingContext ), bindingContext );
|
||||
}
|
||||
|
||||
private static String extractExtendsName(EntityElement entityClazz, HbmBindingContext bindingContext) {
|
||||
final String extendsName = ( (XMLUnionSubclassElement) entityClazz ).getExtends();
|
||||
if ( StringHelper.isEmpty( extendsName ) ) {
|
||||
throw new MappingException(
|
||||
"Subclass entity mapping [" + bindingContext.determineEntityName( entityClazz )
|
||||
+ "] was not contained in super entity mapping",
|
||||
bindingContext.getOrigin()
|
||||
);
|
||||
}
|
||||
return extendsName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This form would be used when the subclass definition if nested within its super type mapping.
|
||||
*
|
||||
* @param entityClazz The JAXB entity mapping
|
||||
* @param superEntityName The name of the containing (and thus super) entity
|
||||
* @param bindingContext The context for the binding process.
|
||||
*/
|
||||
public UnionSubClassEntityDescriptorImpl(
|
||||
EntityElement entityClazz,
|
||||
String superEntityName,
|
||||
HbmBindingContext bindingContext) {
|
||||
super( entityClazz, superEntityName, JOINED, bindingContext );
|
||||
}
|
||||
}
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.binding;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
|
@ -33,7 +33,7 @@ import org.hibernate.mapping.PropertyGeneration;
|
|||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.AttributeBindingState;
|
||||
|
||||
|
@ -78,8 +78,12 @@ public abstract class AbstractHbmAttributeBindingState implements AttributeBindi
|
|||
}
|
||||
|
||||
protected Set<CascadeType> determineCascadeTypes(String cascade) {
|
||||
String commaSeparatedCascades = MappingHelper.getStringValue( cascade, getBindingContext().getMappingDefaults().getCascadeStyle() );
|
||||
Set<String> cascades = MappingHelper.getStringValueTokens( commaSeparatedCascades, "," );
|
||||
String commaSeparatedCascades = Helper.getStringValue(
|
||||
cascade,
|
||||
getBindingContext().getMappingDefaults()
|
||||
.getCascadeStyle()
|
||||
);
|
||||
Set<String> cascades = Helper.getStringValueTokens( commaSeparatedCascades, "," );
|
||||
Set<CascadeType> cascadeTypes = new HashSet<CascadeType>( cascades.size() );
|
||||
for ( String s : cascades ) {
|
||||
CascadeType cascadeType = CascadeType.getCascadeType( s );
|
|
@ -21,12 +21,12 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.binding;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.DiscriminatorBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping;
|
||||
|
@ -58,7 +58,7 @@ public class HbmDiscriminatorBindingState
|
|||
true
|
||||
);
|
||||
XMLDiscriminator discriminator = xmlEntityClazz.getDiscriminator();
|
||||
this.discriminatorValue = MappingHelper.getStringValue(
|
||||
this.discriminatorValue = Helper.getStringValue(
|
||||
xmlEntityClazz.getDiscriminatorValue(), entityName
|
||||
);
|
||||
this.isForced = xmlEntityClazz.getDiscriminator().isForce();
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.binding;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -29,8 +29,7 @@ import org.hibernate.FetchMode;
|
|||
import org.hibernate.internal.util.ReflectHelper;
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.ManyToOneAttributeBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLManyToOneElement;
|
||||
|
@ -63,8 +62,8 @@ public class HbmManyToOneAttributeBindingState
|
|||
manyToOne.getName(),
|
||||
bindingContext,
|
||||
manyToOne.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( manyToOne.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName(
|
||||
Helper.extractMetaAttributeContext( manyToOne.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
manyToOne.getAccess(),
|
||||
manyToOne.isEmbedXml(),
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
|
@ -100,12 +99,12 @@ public class HbmManyToOneAttributeBindingState
|
|||
referencedEntityName = manyToOne.getEntityName();
|
||||
}
|
||||
else if ( manyToOne.getClazz() != null ) {
|
||||
referencedEntityName = HbmHelper.getClassName(
|
||||
referencedEntityName = Helper.qualifyIfNeeded(
|
||||
manyToOne.getClazz(), bindingContext.getMappingDefaults().getPackageName()
|
||||
);
|
||||
}
|
||||
else {
|
||||
Class ownerClazz = MappingHelper.classForName( ownerClassName, bindingContext.getServiceRegistry() );
|
||||
Class ownerClazz = Helper.classForName( ownerClassName, bindingContext.getServiceRegistry() );
|
||||
referencedEntityName = ReflectHelper.reflectedPropertyClass( ownerClazz, manyToOne.getName() ).getName();
|
||||
}
|
||||
return referencedEntityName;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.binding;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
|
@ -31,8 +31,7 @@ import java.util.Set;
|
|||
import org.hibernate.FetchMode;
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.CustomSQL;
|
||||
import org.hibernate.metamodel.binding.state.PluralAttributeBindingState;
|
||||
|
@ -63,14 +62,16 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
collection.getName(),
|
||||
bindingContext,
|
||||
collection.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( collection.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName(
|
||||
collection.getAccess(), collection.isEmbedXml(), bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
Helper.extractMetaAttributeContext( collection.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
collection.getAccess(),
|
||||
collection.isEmbedXml(),
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
),
|
||||
collection.isOptimisticLock()
|
||||
);
|
||||
this.collection = collection;
|
||||
this.collectionPersisterClass = MappingHelper.classForName(
|
||||
this.collectionPersisterClass = Helper.classForName(
|
||||
collection.getPersister(), getBindingContext().getServiceRegistry()
|
||||
);
|
||||
this.cascadeTypes = determineCascadeTypes( collection.getCascade() );
|
||||
|
@ -116,7 +117,7 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public boolean isLazy() {
|
||||
return isExtraLazy() ||
|
||||
MappingHelper.getBooleanValue(
|
||||
Helper.getBooleanValue(
|
||||
collection.getLazy().value(), getBindingContext().getMappingDefaults().areAssociationsLazy()
|
||||
);
|
||||
}
|
||||
|
@ -202,7 +203,7 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
}
|
||||
|
||||
public int getBatchSize() {
|
||||
return MappingHelper.getIntValue( collection.getBatchSize(), 0 );
|
||||
return Helper.getIntValue( collection.getBatchSize(), 0 );
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -238,46 +239,22 @@ public class HbmPluralAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
|
||||
public CustomSQL getCustomSQLInsert() {
|
||||
XMLSqlInsertElement sqlInsert = collection.getSqlInsert();
|
||||
return sqlInsert == null ?
|
||||
null :
|
||||
HbmHelper.getCustomSql(
|
||||
collection.getSqlInsert().getValue(),
|
||||
collection.getSqlInsert().isCallable(),
|
||||
collection.getSqlInsert().getCheck().value()
|
||||
);
|
||||
return Helper.buildCustomSql( sqlInsert );
|
||||
}
|
||||
|
||||
public CustomSQL getCustomSQLUpdate() {
|
||||
XMLSqlUpdateElement sqlUpdate = collection.getSqlUpdate();
|
||||
return sqlUpdate == null ?
|
||||
null :
|
||||
HbmHelper.getCustomSql(
|
||||
collection.getSqlUpdate().getValue(),
|
||||
collection.getSqlUpdate().isCallable(),
|
||||
collection.getSqlUpdate().getCheck().value()
|
||||
);
|
||||
return Helper.buildCustomSql( sqlUpdate );
|
||||
}
|
||||
|
||||
public CustomSQL getCustomSQLDelete() {
|
||||
XMLSqlDeleteElement sqlDelete = collection.getSqlDelete();
|
||||
return sqlDelete == null ?
|
||||
null :
|
||||
HbmHelper.getCustomSql(
|
||||
collection.getSqlDelete().getValue(),
|
||||
collection.getSqlDelete().isCallable(),
|
||||
collection.getSqlDelete().getCheck().value()
|
||||
);
|
||||
return Helper.buildCustomSql( sqlDelete );
|
||||
}
|
||||
|
||||
public CustomSQL getCustomSQLDeleteAll() {
|
||||
XMLSqlDeleteAllElement sqlDeleteAll = collection.getSqlDeleteAll();
|
||||
return sqlDeleteAll == null ?
|
||||
null :
|
||||
HbmHelper.getCustomSql(
|
||||
collection.getSqlDeleteAll().getValue(),
|
||||
collection.getSqlDeleteAll().isCallable(),
|
||||
collection.getSqlDeleteAll().getCheck().value()
|
||||
);
|
||||
return Helper.buildCustomSql( sqlDeleteAll );
|
||||
}
|
||||
|
||||
public String getLoaderName() {
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.binding;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.binding;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
@ -32,8 +32,7 @@ import org.hibernate.mapping.PropertyGeneration;
|
|||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetaAttributeContext;
|
||||
import org.hibernate.metamodel.binder.source.hbm.HbmHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.binding.CascadeType;
|
||||
import org.hibernate.metamodel.binding.state.SimpleAttributeBindingState;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLId;
|
||||
|
@ -65,8 +64,12 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
id.getName() != null ? id.getName() : bindingContext.getMappingDefaults().getIdColumnName(),
|
||||
bindingContext,
|
||||
id.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( id.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( id.getAccess(), false, bindingContext.getMappingDefaults().getPropertyAccessorName() ),
|
||||
Helper.extractMetaAttributeContext( id.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
id.getAccess(),
|
||||
false,
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -108,8 +111,12 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
version.getName(),
|
||||
bindingContext,
|
||||
version.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( version.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( version.getAccess(), false, bindingContext.getMappingDefaults().getPropertyAccessorName() ),
|
||||
Helper.extractMetaAttributeContext( version.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
version.getAccess(),
|
||||
false,
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
),
|
||||
true
|
||||
);
|
||||
this.typeName = version.getType() == null ? "integer" : version.getType();
|
||||
|
@ -123,7 +130,7 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
if ( propertyGeneration == PropertyGeneration.INSERT ) {
|
||||
throw new MappingException( "'generated' attribute cannot be 'insert' for versioning property" );
|
||||
}
|
||||
this.isInsertable = MappingHelper.getBooleanValue( version.isInsert(), true );
|
||||
this.isInsertable = Helper.getBooleanValue( version.isInsert(), true );
|
||||
this.isUpdatable = true;
|
||||
}
|
||||
|
||||
|
@ -138,8 +145,12 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
timestamp.getName(),
|
||||
bindingContext,
|
||||
timestamp.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( timestamp.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName( timestamp.getAccess(), false, bindingContext.getMappingDefaults().getPropertyAccessorName() ),
|
||||
Helper.extractMetaAttributeContext( timestamp.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
timestamp.getAccess(),
|
||||
false,
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
),
|
||||
true
|
||||
);
|
||||
|
||||
|
@ -168,8 +179,8 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
property.getName(),
|
||||
bindingContext,
|
||||
property.getNode(),
|
||||
HbmHelper.extractMetaAttributeContext( property.getMeta(), parentMetaAttributeContext ),
|
||||
HbmHelper.getPropertyAccessorName(
|
||||
Helper.extractMetaAttributeContext( property.getMeta(), parentMetaAttributeContext ),
|
||||
Helper.getPropertyAccessorName(
|
||||
property.getAccess(),
|
||||
false,
|
||||
bindingContext.getMappingDefaults().getPropertyAccessorName()
|
||||
|
@ -192,7 +203,7 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
isInsertable = false;
|
||||
}
|
||||
else {
|
||||
isInsertable = MappingHelper.getBooleanValue( property.isInsert(), true );
|
||||
isInsertable = Helper.getBooleanValue( property.isInsert(), true );
|
||||
}
|
||||
if ( propertyGeneration == PropertyGeneration.ALWAYS ) {
|
||||
if ( property.isUpdate() != null && property.isUpdate() ) {
|
||||
|
@ -207,7 +218,7 @@ public class HbmSimpleAttributeBindingState extends AbstractHbmAttributeBindingS
|
|||
isUpdatable = false;
|
||||
}
|
||||
else {
|
||||
isUpdatable = MappingHelper.getBooleanValue( property.isUpdate(), true );
|
||||
isUpdatable = Helper.getBooleanValue( property.isUpdate(), true );
|
||||
}
|
||||
|
||||
if ( property.getTypeAttribute() != null ) {
|
|
@ -21,13 +21,13 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.relational;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.relational;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
import org.hibernate.MappingException;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.metamodel.binder.source.hbm.MappingHelper;
|
||||
import org.hibernate.metamodel.binder.source.hbm.Helper;
|
||||
import org.hibernate.metamodel.relational.Size;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLColumnElement;
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLHibernateMapping.XMLClass.XMLDiscriminator;
|
||||
|
@ -64,8 +64,8 @@ public class HbmColumnRelationalState implements ColumnRelationalState {
|
|||
this.container = container;
|
||||
this.explicitColumnName = columnElement.getName();
|
||||
this.size = createSize( columnElement.getLength(), columnElement.getScale(), columnElement.getPrecision() );
|
||||
this.isNullable = !MappingHelper.getBooleanValue( columnElement.isNotNull(), true );
|
||||
this.isUnique = MappingHelper.getBooleanValue( columnElement.isUnique(), true );
|
||||
this.isNullable = !Helper.getBooleanValue( columnElement.isNotNull(), true );
|
||||
this.isUnique = Helper.getBooleanValue( columnElement.isUnique(), true );
|
||||
this.checkCondition = columnElement.getCheck();
|
||||
this.defaultColumnValue = columnElement.getDefault();
|
||||
this.sqlType = columnElement.getSqlType();
|
||||
|
@ -75,9 +75,9 @@ public class HbmColumnRelationalState implements ColumnRelationalState {
|
|||
}
|
||||
this.customRead = columnElement.getRead();
|
||||
this.comment = columnElement.getComment() == null ? null : columnElement.getComment().trim();
|
||||
this.uniqueKeys = MappingHelper.getStringValueTokens( columnElement.getUniqueKey(), ", " );
|
||||
this.uniqueKeys = Helper.getStringValueTokens( columnElement.getUniqueKey(), ", " );
|
||||
this.uniqueKeys.addAll( container.getPropertyUniqueKeys() );
|
||||
this.indexes = MappingHelper.getStringValueTokens( columnElement.getIndex(), ", " );
|
||||
this.indexes = Helper.getStringValueTokens( columnElement.getIndex(), ", " );
|
||||
this.indexes.addAll( container.getPropertyIndexes() );
|
||||
}
|
||||
|
||||
|
@ -86,17 +86,17 @@ public class HbmColumnRelationalState implements ColumnRelationalState {
|
|||
this.container = container;
|
||||
this.explicitColumnName = property.getName();
|
||||
this.size = createSize( property.getLength(), property.getScale(), property.getPrecision() );
|
||||
this.isUnique = MappingHelper.getBooleanValue( property.isUnique(), true );
|
||||
this.isNullable = !MappingHelper.getBooleanValue( property.isNotNull(), true );
|
||||
this.isUnique = Helper.getBooleanValue( property.isUnique(), true );
|
||||
this.isNullable = !Helper.getBooleanValue( property.isNotNull(), true );
|
||||
this.checkCondition = null;
|
||||
this.defaultColumnValue = null;
|
||||
this.sqlType = null;
|
||||
this.customWrite = null;
|
||||
this.customRead = null;
|
||||
this.comment = null;
|
||||
this.uniqueKeys = MappingHelper.getStringValueTokens( property.getUniqueKey(), ", " );
|
||||
this.uniqueKeys = Helper.getStringValueTokens( property.getUniqueKey(), ", " );
|
||||
this.uniqueKeys.addAll( container.getPropertyUniqueKeys() );
|
||||
this.indexes = MappingHelper.getStringValueTokens( property.getIndex(), ", " );
|
||||
this.indexes = Helper.getStringValueTokens( property.getIndex(), ", " );
|
||||
this.indexes.addAll( container.getPropertyIndexes() );
|
||||
}
|
||||
|
||||
|
@ -105,7 +105,7 @@ public class HbmColumnRelationalState implements ColumnRelationalState {
|
|||
this.container = container;
|
||||
this.explicitColumnName = manyToOne.getName();
|
||||
this.size = new Size();
|
||||
this.isNullable = !MappingHelper.getBooleanValue( manyToOne.isNotNull(), false );
|
||||
this.isNullable = !Helper.getBooleanValue( manyToOne.isNotNull(), false );
|
||||
this.isUnique = manyToOne.isUnique();
|
||||
this.checkCondition = null;
|
||||
this.defaultColumnValue = null;
|
||||
|
@ -113,9 +113,9 @@ public class HbmColumnRelationalState implements ColumnRelationalState {
|
|||
this.customWrite = null;
|
||||
this.customRead = null;
|
||||
this.comment = null;
|
||||
this.uniqueKeys = MappingHelper.getStringValueTokens( manyToOne.getUniqueKey(), ", " );
|
||||
this.uniqueKeys = Helper.getStringValueTokens( manyToOne.getUniqueKey(), ", " );
|
||||
this.uniqueKeys.addAll( container.getPropertyUniqueKeys() );
|
||||
this.indexes = MappingHelper.getStringValueTokens( manyToOne.getIndex(), ", " );
|
||||
this.indexes = Helper.getStringValueTokens( manyToOne.getIndex(), ", " );
|
||||
this.indexes.addAll( container.getPropertyIndexes() );
|
||||
}
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.relational;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.relational;
|
||||
|
||||
import org.hibernate.metamodel.relational.state.DerivedValueRelationalState;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.relational;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.relational;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.BindingContext;
|
||||
import org.hibernate.metamodel.relational.state.ManyToOneRelationalState;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.hbm.state.relational;
|
||||
package org.hibernate.metamodel.binder.source.hbm.state.relational;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2011, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.binder.source.hbm.xml.mapping;
|
||||
|
||||
import org.hibernate.metamodel.source.hbm.xml.mapping.XMLCheckAttribute;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public interface CustomSqlElement {
|
||||
public String getValue();
|
||||
public boolean isCallable();
|
||||
public XMLCheckAttribute getCheck();
|
||||
}
|
|
@ -35,9 +35,9 @@ import org.jboss.jandex.DotName;
|
|||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.annotations.GenerationTime;
|
||||
import org.hibernate.mapping.PropertyGeneration;
|
||||
import org.hibernate.metamodel.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.source.annotations.util.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.HibernateDotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
|
||||
/**
|
||||
* Represent a mapped attribute (explicitly or implicitly mapped). Also used for synthetic attributes like a
|
||||
|
|
|
@ -30,6 +30,18 @@
|
|||
<jaxb:bindings node="//xsd:complexType[@name='union-subclass-element']">
|
||||
<inheritance:implements>org.hibernate.metamodel.binder.source.hbm.xml.mapping.SubclassEntityElement</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='sql-insert-element']">
|
||||
<inheritance:implements>org.hibernate.metamodel.binder.source.hbm.xml.mapping.CustomSqlElement</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='sql-update-element']">
|
||||
<inheritance:implements>org.hibernate.metamodel.binder.source.hbm.xml.mapping.CustomSqlElement</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='sql-delete-element']">
|
||||
<inheritance:implements>org.hibernate.metamodel.binder.source.hbm.xml.mapping.CustomSqlElement</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
<jaxb:bindings node="//xsd:complexType[@name='sql-delete-all-element']">
|
||||
<inheritance:implements>org.hibernate.metamodel.binder.source.hbm.xml.mapping.CustomSqlElement</inheritance:implements>
|
||||
</jaxb:bindings>
|
||||
|
||||
<jaxb:bindings node="//xsd:element[@name='class']//xsd:attribute[@name='subselect']">
|
||||
<jaxb:property name="subselectAttribute"/>
|
||||
|
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
@ -38,8 +38,6 @@ import org.jboss.jandex.Indexer;
|
|||
|
||||
import org.hibernate.AnnotationException;
|
||||
import org.hibernate.HibernateException;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntityMappings;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
|
@ -57,7 +55,7 @@ public abstract class AbstractMockerTest {
|
|||
private IndexBuilder indexBuilder;
|
||||
private Index index;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
protected String packagePrefix = "org/hibernate/metamodel/source/annotations/xml/mocker/";
|
||||
protected String packagePrefix = getClass().getPackage().getName().replace( '.', '/' ) + '/';
|
||||
|
||||
protected IndexBuilder getIndexBuilder() {
|
||||
if ( indexBuilder == null ) {
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.AnnotationInstance;
|
||||
import org.jboss.jandex.AnnotationValue;
|
||||
|
@ -29,9 +29,6 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLAttributes;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLGeneratedValue;
|
||||
|
@ -67,7 +64,7 @@ public class BasicMockerTest extends AbstractMockerTest {
|
|||
entity.setClazz( "Item" );
|
||||
IndexBuilder indexBuilder = getIndexBuilder();
|
||||
EntityMappingsMocker.Default defaults = new EntityMappingsMocker.Default();
|
||||
defaults.setPackageName( "org.hibernate.metamodel.source.annotations.xml.mocker" );
|
||||
defaults.setPackageName( getClass().getPackage().getName() );
|
||||
defaults.setSchema( "HIBERNATE_SCHEMA" );
|
||||
defaults.setCatalog( "HIBERNATE_CATALOG" );
|
||||
EntityMocker entityMocker = new EntityMocker( indexBuilder, entity, defaults );
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
|
@ -1,4 +1,4 @@
|
|||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
|
@ -18,9 +18,6 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.DefaultConfigurationHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.SchemaAware;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.jboss.jandex.ClassInfo;
|
||||
import org.jboss.jandex.DotName;
|
|
@ -1,6 +1,4 @@
|
|||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import org.junit.Test;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
/**
|
||||
* @author Strong Liu
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
@ -32,9 +32,6 @@ import org.jboss.jandex.DotName;
|
|||
import org.jboss.jandex.Index;
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMappingsMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.EntityMocker;
|
||||
import org.hibernate.metamodel.binder.source.annotations.xml.mocker.IndexBuilder;
|
||||
import org.hibernate.metamodel.source.annotation.xml.XMLEntity;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JPADotNames;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import javax.persistence.AccessType;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import javax.persistence.Embeddable;
|
||||
|
|
@ -21,7 +21,7 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.xml.mocker;
|
||||
package org.hibernate.metamodel.binder.source.annotations.xml.mocker;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.net.URL;
|
|
@ -27,6 +27,7 @@ import java.sql.Types;
|
|||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.domain.Entity;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.metamodel.domain.SingularAttribute;
|
||||
|
@ -35,6 +36,8 @@ import org.hibernate.metamodel.relational.Datatype;
|
|||
import org.hibernate.metamodel.relational.Schema;
|
||||
import org.hibernate.metamodel.relational.Size;
|
||||
import org.hibernate.metamodel.relational.Table;
|
||||
import org.hibernate.service.classloading.spi.ClassLoadingException;
|
||||
|
||||
import org.hibernate.testing.junit4.BaseUnitTestCase;
|
||||
|
||||
import static org.junit.Assert.assertSame;
|
||||
|
@ -52,7 +55,7 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
@Test
|
||||
public void testBasicMiddleOutBuilding() {
|
||||
Table table = new Table( new Schema( null, null ), "the_table" );
|
||||
Entity entity = new Entity( "TheEntity", null, new JavaType( "NoSuchClass", null ) );
|
||||
Entity entity = new Entity( "TheEntity", "NoSuchClass", makeJavaType( "NoSuchClass" ), null );
|
||||
EntityBinding entityBinding = new EntityBinding();
|
||||
entityBinding.setRoot( true );
|
||||
entityBinding.setEntity( entity );
|
||||
|
@ -72,4 +75,20 @@ public class SimpleValueBindingTests extends BaseUnitTestCase {
|
|||
table.getPrimaryKey().setName( "my_table_pk" );
|
||||
//attributeBinding.setValue( idColumn );
|
||||
}
|
||||
|
||||
Value<Class<?>> makeJavaType(final String name) {
|
||||
return new Value<Class<?>>(
|
||||
new Value.DeferredInitializer<Class<?>>() {
|
||||
@Override
|
||||
public Class<?> initialize() {
|
||||
try {
|
||||
return Class.forName( name );
|
||||
}
|
||||
catch ( Exception e ) {
|
||||
throw new ClassLoadingException( "Could not load class : " + name, e );
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,11 +21,12 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.metamodel.source.annotations.entity;
|
||||
package org.hibernate.metamodel.source.annotations;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.fasterxml.classmate.MemberResolver;
|
||||
import com.fasterxml.classmate.ResolvedType;
|
||||
import com.fasterxml.classmate.ResolvedTypeWithMembers;
|
||||
import com.fasterxml.classmate.TypeResolver;
|
||||
|
@ -35,25 +36,28 @@ import org.jboss.jandex.Index;
|
|||
|
||||
import org.hibernate.cfg.EJB3NamingStrategy;
|
||||
import org.hibernate.cfg.NamingStrategy;
|
||||
import org.hibernate.cfg.NotYetImplementedException;
|
||||
import org.hibernate.internal.util.Value;
|
||||
import org.hibernate.metamodel.binder.source.MappingDefaults;
|
||||
import org.hibernate.metamodel.binder.source.MetadataImplementor;
|
||||
import org.hibernate.metamodel.binder.source.annotations.AnnotationsBindingContext;
|
||||
import org.hibernate.metamodel.domain.JavaType;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
||||
/**
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AnnotationsBindingContextImpl implements AnnotationsBindingContext {
|
||||
private final Index index;
|
||||
private final BasicServiceRegistryImpl serviceRegistry;
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class TestAnnotationsBindingContextImpl implements AnnotationsBindingContext {
|
||||
private Index index;
|
||||
private ServiceRegistry serviceRegistry;
|
||||
|
||||
private NamingStrategy namingStrategy = EJB3NamingStrategy.INSTANCE;
|
||||
|
||||
private final TypeResolver typeResolver = new TypeResolver();
|
||||
private final Map<Class<?>, ResolvedType> resolvedTypeCache = new HashMap<Class<?>, ResolvedType>();
|
||||
|
||||
public AnnotationsBindingContextImpl(Index index, BasicServiceRegistryImpl serviceRegistry) {
|
||||
public TestAnnotationsBindingContextImpl(Index index, ServiceRegistry serviceRegistry) {
|
||||
this.index = index;
|
||||
this.serviceRegistry = serviceRegistry;
|
||||
}
|
||||
|
@ -63,6 +67,40 @@ public class AnnotationsBindingContextImpl implements AnnotationsBindingContext
|
|||
return index;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return namingStrategy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return serviceRegistry.getService( ClassLoaderService.class ).classForName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Value<Class<?>> makeClassReference(String className) {
|
||||
throw new NotYetImplementedException();
|
||||
}
|
||||
@Override
|
||||
public ClassInfo getClassInfo(String name) {
|
||||
DotName dotName = DotName.createSimple( name );
|
||||
|
@ -91,37 +129,9 @@ public class AnnotationsBindingContextImpl implements AnnotationsBindingContext
|
|||
|
||||
@Override
|
||||
public ResolvedTypeWithMembers resolveMemberTypes(ResolvedType type) {
|
||||
return null; //To change body of implemented methods use File | Settings | File Templates.
|
||||
}
|
||||
|
||||
@Override
|
||||
public ServiceRegistry getServiceRegistry() {
|
||||
return serviceRegistry;
|
||||
}
|
||||
|
||||
@Override
|
||||
public NamingStrategy getNamingStrategy() {
|
||||
return EJB3NamingStrategy.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MappingDefaults getMappingDefaults() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MetadataImplementor getMetadataImplementor() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> Class<T> locateClassByName(String name) {
|
||||
return serviceRegistry.getService( ClassLoaderService.class ).classForName( name );
|
||||
}
|
||||
|
||||
@Override
|
||||
public JavaType makeJavaType(String className) {
|
||||
return null;
|
||||
// todo : is there a reason we create this resolver every time?
|
||||
MemberResolver memberResolver = new MemberResolver( typeResolver );
|
||||
return memberResolver.resolve( type, null, null );
|
||||
}
|
||||
|
||||
@Override
|
|
@ -46,7 +46,7 @@ public class ProxyBindingTests extends BaseAnnotationBindingTestCase {
|
|||
buildMetadataSources( ProxiedEntity.class );
|
||||
EntityBinding binding = getEntityBinding( ProxiedEntity.class );
|
||||
assertTrue( "Wrong laziness", binding.isLazy() );
|
||||
assertEquals( "Wrong proxy interface", ProxiedEntity.class, binding.getProxyInterfaceType().getClassReference() );
|
||||
assertEquals( "Wrong proxy interface", ProxiedEntity.class, binding.getProxyInterfaceType().getValue() );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -54,7 +54,7 @@ public class ProxyBindingTests extends BaseAnnotationBindingTestCase {
|
|||
buildMetadataSources(NoProxyEntity.class);
|
||||
EntityBinding binding = getEntityBinding( NoProxyEntity.class );
|
||||
assertTrue( "Wrong laziness", binding.isLazy() );
|
||||
assertEquals( "Wrong proxy interface", NoProxyEntity.class, binding.getProxyInterfaceType().getClassReference() );
|
||||
assertEquals( "Wrong proxy interface", NoProxyEntity.class, binding.getProxyInterfaceType().getValue() );
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -73,7 +73,7 @@ public class ProxyBindingTests extends BaseAnnotationBindingTestCase {
|
|||
assertEquals(
|
||||
"Wrong proxy interface",
|
||||
"org.hibernate.metamodel.source.annotations.entity.ProxyBindingTests$ProxyInterfaceEntity",
|
||||
binding.getProxyInterfaceType().getName()
|
||||
binding.getProxyInterfaceType().getValue().getName()
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ import org.hibernate.metamodel.binder.source.annotations.ConfiguredClassHierarch
|
|||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.binding.InheritanceType;
|
||||
import org.hibernate.metamodel.source.annotations.TestAnnotationsBindingContextImpl;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
import org.hibernate.service.classloading.spi.ClassLoaderService;
|
||||
import org.hibernate.service.internal.BasicServiceRegistryImpl;
|
||||
|
@ -86,9 +87,8 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, A.class, B.class );
|
||||
AnnotationsBindingContext context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
new TestAnnotationsBindingContextImpl( index, serviceRegistry )
|
||||
);
|
||||
assertEquals( "There should be only one hierarchy", 1, hierarchies.size() );
|
||||
|
||||
|
@ -134,9 +134,8 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, A.class, B.class );
|
||||
AnnotationsBindingContext context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
new TestAnnotationsBindingContextImpl( index, serviceRegistry )
|
||||
);
|
||||
assertEquals( "There should be only one hierarchy", 1, hierarchies.size() );
|
||||
|
||||
|
@ -183,9 +182,8 @@ public class TableNameTest extends BaseUnitTestCase {
|
|||
}
|
||||
|
||||
Index index = JandexHelper.indexForClass( service, B.class, A.class );
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
Set<ConfiguredClassHierarchy<EntityClass>> hierarchies = ConfiguredClassHierarchyBuilder.createEntityHierarchies(
|
||||
context
|
||||
new TestAnnotationsBindingContextImpl( index, serviceRegistry )
|
||||
);
|
||||
assertEquals( "There should be only one hierarchy", 1, hierarchies.size() );
|
||||
|
||||
|
|
|
@ -34,7 +34,7 @@ import org.junit.Before;
|
|||
import org.hibernate.metamodel.binder.source.annotations.ConfiguredClassHierarchyBuilder;
|
||||
import org.hibernate.metamodel.binder.source.annotations.JandexHelper;
|
||||
import org.hibernate.metamodel.binder.source.annotations.entity.ConfiguredClassHierarchy;
|
||||
import org.hibernate.metamodel.source.annotations.entity.AnnotationsBindingContextImpl;
|
||||
import org.hibernate.metamodel.source.annotations.TestAnnotationsBindingContextImpl;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EmbeddableClass;
|
||||
import org.hibernate.metamodel.source.annotations.entity.EntityClass;
|
||||
import org.hibernate.service.ServiceRegistryBuilder;
|
||||
|
@ -60,7 +60,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
|
|||
|
||||
public Set<ConfiguredClassHierarchy<EntityClass>> createEntityHierarchies(Class<?>... clazz) {
|
||||
Index index = JandexHelper.indexForClass( serviceRegistry.getService( ClassLoaderService.class ), clazz );
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
TestAnnotationsBindingContextImpl context = new TestAnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
return ConfiguredClassHierarchyBuilder.createEntityHierarchies( context );
|
||||
}
|
||||
|
||||
|
@ -69,7 +69,7 @@ public abstract class BaseAnnotationIndexTestCase extends BaseUnitTestCase {
|
|||
serviceRegistry.getService( ClassLoaderService.class ),
|
||||
configuredClasses
|
||||
);
|
||||
AnnotationsBindingContextImpl context = new AnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
TestAnnotationsBindingContextImpl context = new TestAnnotationsBindingContextImpl( index, serviceRegistry );
|
||||
return ConfiguredClassHierarchyBuilder.createEmbeddableHierarchy( configuredClasses[0], accessType, context );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
<cascade-persist/>
|
||||
</persistence-unit-defaults>
|
||||
</persistence-unit-metadata>
|
||||
<package>org.hibernate.metamodel.source.annotations.xml.mocker</package>
|
||||
<package>org.hibernate.metamodel.binder.source.annotations.xml.mocker</package>
|
||||
|
||||
<entity class="Book">
|
||||
<attributes>
|
|
@ -3,7 +3,7 @@
|
|||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="2.0">
|
||||
<package>org.hibernate.metamodel.source.annotations.xml.mocker</package>
|
||||
<package>org.hibernate.metamodel.binder.source.annotations.xml.mocker</package>
|
||||
<schema>XML_SCHEMA</schema>
|
||||
<catalog>XML_CATALOG</catalog>
|
||||
</entity-mappings>
|
|
@ -3,7 +3,7 @@
|
|||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="2.0">
|
||||
<package>org.hibernate.metamodel.source.annotations.xml.mocker</package>
|
||||
<package>org.hibernate.metamodel.binder.source.annotations.xml.mocker</package>
|
||||
<entity class="Author" metadata-complete="true">
|
||||
<id-class class="Topic"/>
|
||||
</entity>
|
|
@ -8,17 +8,17 @@
|
|||
<delimited-identifiers/>
|
||||
<access>FIELD</access>
|
||||
<entity-listeners>
|
||||
<entity-listener class="org.hibernate.metamodel.source.annotations.xml.mocker.ItemListener">
|
||||
<entity-listener class="org.hibernate.metamodel.binder.source.annotations.xml.mocker.ItemListener">
|
||||
<pre-persist method-name="prePersist"/>
|
||||
<post-persist method-name="postPersist"/>
|
||||
</entity-listener>
|
||||
</entity-listeners>
|
||||
</persistence-unit-defaults>
|
||||
</persistence-unit-metadata>
|
||||
<package>org.hibernate.metamodel.source.annotations.xml.mocker</package>
|
||||
<package>org.hibernate.metamodel.binder.source.annotations.xml.mocker</package>
|
||||
<entity class="Item">
|
||||
<entity-listeners>
|
||||
<entity-listener class="org.hibernate.metamodel.source.annotations.xml.mocker.ItemListener">
|
||||
<entity-listener class="org.hibernate.metamodel.binder.source.annotations.xml.mocker.ItemListener">
|
||||
<pre-persist method-name="prePersist"/>
|
||||
<post-persist method-name="postPersist"/>
|
||||
</entity-listener>
|
|
@ -3,7 +3,7 @@
|
|||
<entity-mappings xmlns="http://java.sun.com/xml/ns/persistence/orm"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
version="2.0">
|
||||
<package>org.hibernate.metamodel.source.annotations.xml.mocker</package>
|
||||
<package>org.hibernate.metamodel.binder.source.annotations.xml.mocker</package>
|
||||
|
||||
<mapped-superclass class="Book">
|
||||
<attributes>
|
|
@ -8,7 +8,7 @@
|
|||
<delimited-identifiers/>
|
||||
<access>FIELD</access>
|
||||
<entity-listeners>
|
||||
<entity-listener class="org.hibernate.metamodel.source.annotations.xml.mocker.ItemListener">
|
||||
<entity-listener class="org.hibernate.metamodel.binder.source.annotations.xml.mocker.ItemListener">
|
||||
<pre-persist method-name="prePersist"/>
|
||||
<post-persist method-name="postPersist"/>
|
||||
</entity-listener>
|
Loading…
Reference in New Issue