HHH-5474 - Clean up usages of now deprecated ExtendedMappings

git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@20136 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
Steve Ebersole 2010-08-12 19:13:48 +00:00
parent 74eb608be6
commit f0f82e4f1b
31 changed files with 552 additions and 380 deletions

View File

@ -54,13 +54,15 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
private Map<String, JoinTable> holderJoinTableOverride; private Map<String, JoinTable> holderJoinTableOverride;
private Map<String, JoinTable> currentPropertyJoinTableOverride; private Map<String, JoinTable> currentPropertyJoinTableOverride;
private String path; private String path;
private ExtendedMappings mappings; private Mappings mappings;
private Boolean isInIdClass; private Boolean isInIdClass;
public AbstractPropertyHolder( public AbstractPropertyHolder(
String path, PropertyHolder parent, XClass clazzToProcess, ExtendedMappings mappings String path,
) { PropertyHolder parent,
XClass clazzToProcess,
Mappings mappings) {
this.path = path; this.path = path;
this.parent = (AbstractPropertyHolder) parent; this.parent = (AbstractPropertyHolder) parent;
this.mappings = mappings; this.mappings = mappings;
@ -80,7 +82,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
return path; return path;
} }
protected ExtendedMappings getMappings() { protected Mappings getMappings() {
return mappings; return mappings;
} }

View File

@ -21,9 +21,6 @@
* 51 Franklin Street, Fifth Floor * 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA * Boston, MA 02110-1301 USA
*/ */
// $Id$
package org.hibernate.cfg; package org.hibernate.cfg;
import java.lang.annotation.Annotation; import java.lang.annotation.Annotation;
@ -203,7 +200,7 @@ public final class AnnotationBinder {
private static final Logger log = LoggerFactory.getLogger( AnnotationBinder.class ); private static final Logger log = LoggerFactory.getLogger( AnnotationBinder.class );
public static void bindDefaults(ExtendedMappings mappings) { public static void bindDefaults(Mappings mappings) {
Map defaults = mappings.getReflectionManager().getDefaults(); Map defaults = mappings.getReflectionManager().getDefaults();
{ {
List<SequenceGenerator> anns = ( List<SequenceGenerator> ) defaults.get( SequenceGenerator.class ); List<SequenceGenerator> anns = ( List<SequenceGenerator> ) defaults.get( SequenceGenerator.class );
@ -253,7 +250,7 @@ public final class AnnotationBinder {
} }
} }
public static void bindPackage(String packageName, ExtendedMappings mappings) { public static void bindPackage(String packageName, Mappings mappings) {
XPackage pckg; XPackage pckg;
try { try {
pckg = mappings.getReflectionManager().packageForName( packageName ); pckg = mappings.getReflectionManager().packageForName( packageName );
@ -282,7 +279,7 @@ public final class AnnotationBinder {
BinderHelper.bindAnyMetaDefs( pckg, mappings ); BinderHelper.bindAnyMetaDefs( pckg, mappings );
} }
private static void bindGenericGenerators(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { private static void bindGenericGenerators(XAnnotatedElement annotatedElement, Mappings mappings) {
GenericGenerator defAnn = annotatedElement.getAnnotation( GenericGenerator.class ); GenericGenerator defAnn = annotatedElement.getAnnotation( GenericGenerator.class );
GenericGenerators defsAnn = annotatedElement.getAnnotation( GenericGenerators.class ); GenericGenerators defsAnn = annotatedElement.getAnnotation( GenericGenerators.class );
if ( defAnn != null ) { if ( defAnn != null ) {
@ -295,12 +292,12 @@ public final class AnnotationBinder {
} }
} }
private static void bindGenericGenerator(GenericGenerator def, ExtendedMappings mappings) { private static void bindGenericGenerator(GenericGenerator def, Mappings mappings) {
IdGenerator idGen = buildIdGenerator( def, mappings ); IdGenerator idGen = buildIdGenerator( def, mappings );
mappings.addGenerator( idGen ); mappings.addGenerator( idGen );
} }
private static void bindQueries(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { private static void bindQueries(XAnnotatedElement annotatedElement, Mappings mappings) {
{ {
SqlResultSetMapping ann = annotatedElement.getAnnotation( SqlResultSetMapping.class ); SqlResultSetMapping ann = annotatedElement.getAnnotation( SqlResultSetMapping.class );
QueryBinder.bindSqlResultsetMapping( ann, mappings, false ); QueryBinder.bindSqlResultsetMapping( ann, mappings, false );
@ -355,7 +352,7 @@ public final class AnnotationBinder {
} }
} }
private static IdGenerator buildIdGenerator(java.lang.annotation.Annotation ann, ExtendedMappings mappings) { private static IdGenerator buildIdGenerator(java.lang.annotation.Annotation ann, Mappings mappings) {
IdGenerator idGen = new IdGenerator(); IdGenerator idGen = new IdGenerator();
if ( mappings.getSchemaName() != null ) { if ( mappings.getSchemaName() != null ) {
idGen.addParam( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() ); idGen.addParam( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() );
@ -470,7 +467,7 @@ public final class AnnotationBinder {
if ( seqGen.initialValue() != 1 ) { if ( seqGen.initialValue() != 1 ) {
log.warn( log.warn(
"Hibernate does not support SequenceGenerator.initialValue() unless '{}' set", "Hibernate does not support SequenceGenerator.initialValue() unless '{}' set",
AnnotationConfiguration.USE_NEW_ID_GENERATOR_MAPPINGS Configuration.USE_NEW_ID_GENERATOR_MAPPINGS
); );
} }
idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) ); idGen.addParam( SequenceHiLoGenerator.MAX_LO, String.valueOf( seqGen.allocationSize() - 1 ) );
@ -503,8 +500,9 @@ public final class AnnotationBinder {
* @throws MappingException in case there is an configuration error * @throws MappingException in case there is an configuration error
*/ */
public static void bindClass( public static void bindClass(
XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings XClass clazzToProcess,
) throws MappingException { Map<XClass, InheritanceState> inheritanceStatePerClass,
Mappings mappings) throws MappingException {
//@Entity and @MappedSuperclass on the same class leads to a NPE down the road //@Entity and @MappedSuperclass on the same class leads to a NPE down the road
if ( clazzToProcess.isAnnotationPresent( Entity.class ) if ( clazzToProcess.isAnnotationPresent( Entity.class )
&& clazzToProcess.isAnnotationPresent( MappedSuperclass.class ) ) { && clazzToProcess.isAnnotationPresent( MappedSuperclass.class ) ) {
@ -763,7 +761,16 @@ public final class AnnotationBinder {
} }
private static void processIdPropertiesIfNotAlready(Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, PersistentClass persistentClass, EntityBinder entityBinder, PropertyHolder propertyHolder, HashMap<String, IdGenerator> classGenerators, InheritanceState.ElementsToProcess elementsToProcess, boolean subclassAndSingleTableStrategy, Set<String> idPropertiesIfIdClass) { private static void processIdPropertiesIfNotAlready(
Map<XClass, InheritanceState> inheritanceStatePerClass,
Mappings mappings,
PersistentClass persistentClass,
EntityBinder entityBinder,
PropertyHolder propertyHolder,
HashMap<String, IdGenerator> classGenerators,
InheritanceState.ElementsToProcess elementsToProcess,
boolean subclassAndSingleTableStrategy,
Set<String> idPropertiesIfIdClass) {
Set<String> missingIdProperties = new HashSet<String>( idPropertiesIfIdClass ); Set<String> missingIdProperties = new HashSet<String>( idPropertiesIfIdClass );
for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) { for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) {
String propertyName = propertyAnnotatedElement.getPropertyName(); String propertyName = propertyAnnotatedElement.getPropertyName();
@ -795,7 +802,15 @@ public final class AnnotationBinder {
} }
} }
private static boolean mapAsIdClass(Map<XClass, InheritanceState> inheritanceStatePerClass, InheritanceState inheritanceState, PersistentClass persistentClass, EntityBinder entityBinder, PropertyHolder propertyHolder, InheritanceState.ElementsToProcess elementsToProcess, Set<String> idPropertiesIfIdClass, ExtendedMappings mappings) { private static boolean mapAsIdClass(
Map<XClass, InheritanceState> inheritanceStatePerClass,
InheritanceState inheritanceState,
PersistentClass persistentClass,
EntityBinder entityBinder,
PropertyHolder propertyHolder,
InheritanceState.ElementsToProcess elementsToProcess,
Set<String> idPropertiesIfIdClass,
Mappings mappings) {
/* /*
* We are looking for @IdClass * We are looking for @IdClass
* In general we map the id class as identifier using the mapping metadata of the main entity's properties * In general we map the id class as identifier using the mapping metadata of the main entity's properties
@ -916,7 +931,7 @@ public final class AnnotationBinder {
PropertyData baseInferredData, PropertyData baseInferredData,
AccessType propertyAccessor, AccessType propertyAccessor,
Map<XClass, InheritanceState> inheritanceStatePerClass, Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings) { Mappings mappings) {
if ( elementsToProcess.getIdPropertyCount() == 1 ) { if ( elementsToProcess.getIdPropertyCount() == 1 ) {
final PropertyData idPropertyOnBaseClass = getUniqueIdPropertyFromBaseClass( final PropertyData idPropertyOnBaseClass = getUniqueIdPropertyFromBaseClass(
inferredData, baseInferredData, propertyAccessor, mappings inferredData, baseInferredData, propertyAccessor, mappings
@ -946,7 +961,7 @@ public final class AnnotationBinder {
} }
} }
private static Cache determineCacheSettings(XClass clazzToProcess, ExtendedMappings mappings) { private static Cache determineCacheSettings(XClass clazzToProcess, Mappings mappings) {
Cache cacheAnn = clazzToProcess.getAnnotation( Cache.class ); Cache cacheAnn = clazzToProcess.getAnnotation( Cache.class );
if ( cacheAnn != null ) { if ( cacheAnn != null ) {
return cacheAnn; return cacheAnn;
@ -979,7 +994,7 @@ public final class AnnotationBinder {
return cacheAnn; return cacheAnn;
} }
private static SharedCacheMode determineSharedCacheMode(ExtendedMappings mappings) { private static SharedCacheMode determineSharedCacheMode(Mappings mappings) {
SharedCacheMode mode; SharedCacheMode mode;
final Object value = mappings.getConfigurationProperties().get( "javax.persistence.sharedCache.mode" ); final Object value = mappings.getConfigurationProperties().get( "javax.persistence.sharedCache.mode" );
if ( value == null ) { if ( value == null ) {
@ -1006,7 +1021,7 @@ public final class AnnotationBinder {
return mode; return mode;
} }
private static Cache buildCacheMock(String region, ExtendedMappings mappings) { private static Cache buildCacheMock(String region, Mappings mappings) {
return new LocalCacheAnnotationImpl( region, determineCacheConcurrencyStrategy( mappings ) ); return new LocalCacheAnnotationImpl( region, determineCacheConcurrencyStrategy( mappings ) );
} }
@ -1018,12 +1033,12 @@ public final class AnnotationBinder {
return; return;
} }
if ( !properties.containsKey( AnnotationConfiguration.DEFAULT_CACHE_CONCURRENCY_STRATEGY ) ) { if ( !properties.containsKey( Configuration.DEFAULT_CACHE_CONCURRENCY_STRATEGY ) ) {
log.trace( "Given properties did not contain any default cache concurrency strategy setting" ); log.trace( "Given properties did not contain any default cache concurrency strategy setting" );
return; return;
} }
final String strategyName = properties.getProperty( AnnotationConfiguration.DEFAULT_CACHE_CONCURRENCY_STRATEGY ); final String strategyName = properties.getProperty( Configuration.DEFAULT_CACHE_CONCURRENCY_STRATEGY );
log.trace( "Discovered default cache concurrency strategy via config [" + strategyName + "]" ); log.trace( "Discovered default cache concurrency strategy via config [" + strategyName + "]" );
CacheConcurrencyStrategy strategy = CacheConcurrencyStrategy.parse( strategyName ); CacheConcurrencyStrategy strategy = CacheConcurrencyStrategy.parse( strategyName );
if ( strategy == null ) { if ( strategy == null ) {
@ -1035,7 +1050,7 @@ public final class AnnotationBinder {
DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy; DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
} }
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(ExtendedMappings mappings) { private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) { if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory( final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
mappings.getConfigurationProperties(), true mappings.getConfigurationProperties(), true
@ -1094,7 +1109,11 @@ public final class AnnotationBinder {
return persistentClass; return persistentClass;
} }
private static Ejb3JoinColumn[] makeInheritanceJoinColumns(XClass clazzToProcess, ExtendedMappings mappings, InheritanceState inheritanceState, PersistentClass superEntity) { private static Ejb3JoinColumn[] makeInheritanceJoinColumns(
XClass clazzToProcess,
Mappings mappings,
InheritanceState inheritanceState,
PersistentClass superEntity) {
Ejb3JoinColumn[] inheritanceJoinedColumns = null; Ejb3JoinColumn[] inheritanceJoinedColumns = null;
final boolean hasJoinedColumns = inheritanceState.hasParents() final boolean hasJoinedColumns = inheritanceState.hasParents()
&& InheritanceType.JOINED.equals( inheritanceState.getType() ); && InheritanceType.JOINED.equals( inheritanceState.getType() );
@ -1133,7 +1152,7 @@ public final class AnnotationBinder {
return inheritanceJoinedColumns; return inheritanceJoinedColumns;
} }
private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings, InheritanceState inheritanceState) { private static PersistentClass getSuperEntity(XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings, InheritanceState inheritanceState) {
InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity( InheritanceState superEntityState = InheritanceState.getInheritanceStateOfSuperEntity(
clazzToProcess, inheritanceStatePerClass clazzToProcess, inheritanceStatePerClass
); );
@ -1185,7 +1204,7 @@ public final class AnnotationBinder {
*/ */
private static void bindFilters(XClass annotatedClass, EntityBinder entityBinder, private static void bindFilters(XClass annotatedClass, EntityBinder entityBinder,
ExtendedMappings mappings) { Mappings mappings) {
bindFilters( annotatedClass, entityBinder ); bindFilters( annotatedClass, entityBinder );
@ -1215,7 +1234,7 @@ public final class AnnotationBinder {
} }
} }
private static void bindFilterDefs(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { private static void bindFilterDefs(XAnnotatedElement annotatedElement, Mappings mappings) {
FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class ); FilterDef defAnn = annotatedElement.getAnnotation( FilterDef.class );
FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class ); FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class );
if ( defAnn != null ) { if ( defAnn != null ) {
@ -1228,7 +1247,7 @@ public final class AnnotationBinder {
} }
} }
private static void bindFilterDef(FilterDef defAnn, ExtendedMappings mappings) { private static void bindFilterDef(FilterDef defAnn, Mappings mappings) {
Map<String, org.hibernate.type.Type> params = new HashMap<String, org.hibernate.type.Type>(); Map<String, org.hibernate.type.Type> params = new HashMap<String, org.hibernate.type.Type>();
for ( ParamDef param : defAnn.parameters() ) { for ( ParamDef param : defAnn.parameters() ) {
params.put( param.name(), mappings.getTypeResolver().heuristicType( param.type() ) ); params.put( param.name(), mappings.getTypeResolver().heuristicType( param.type() ) );
@ -1238,7 +1257,7 @@ public final class AnnotationBinder {
mappings.addFilterDefinition( def ); mappings.addFilterDefinition( def );
} }
private static void bindTypeDefs(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { private static void bindTypeDefs(XAnnotatedElement annotatedElement, Mappings mappings) {
TypeDef defAnn = annotatedElement.getAnnotation( TypeDef.class ); TypeDef defAnn = annotatedElement.getAnnotation( TypeDef.class );
TypeDefs defsAnn = annotatedElement.getAnnotation( TypeDefs.class ); TypeDefs defsAnn = annotatedElement.getAnnotation( TypeDefs.class );
if ( defAnn != null ) { if ( defAnn != null ) {
@ -1251,7 +1270,7 @@ public final class AnnotationBinder {
} }
} }
private static void bindFetchProfiles(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { private static void bindFetchProfiles(XAnnotatedElement annotatedElement, Mappings mappings) {
FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class ); FetchProfile fetchProfileAnnotation = annotatedElement.getAnnotation( FetchProfile.class );
FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class ); FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );
if ( fetchProfileAnnotation != null ) { if ( fetchProfileAnnotation != null ) {
@ -1264,7 +1283,7 @@ public final class AnnotationBinder {
} }
} }
private static void bindFetchProfile(FetchProfile fetchProfileAnnotation, ExtendedMappings mappings) { private static void bindFetchProfile(FetchProfile fetchProfileAnnotation, Mappings mappings) {
for ( FetchProfile.FetchOverride fetch : fetchProfileAnnotation.fetchOverrides() ) { for ( FetchProfile.FetchOverride fetch : fetchProfileAnnotation.fetchOverrides() ) {
org.hibernate.annotations.FetchMode mode = fetch.mode(); org.hibernate.annotations.FetchMode mode = fetch.mode();
if ( !mode.equals( org.hibernate.annotations.FetchMode.JOIN ) ) { if ( !mode.equals( org.hibernate.annotations.FetchMode.JOIN ) ) {
@ -1276,7 +1295,7 @@ public final class AnnotationBinder {
} }
} }
private static void bindTypeDef(TypeDef defAnn, ExtendedMappings mappings) { private static void bindTypeDef(TypeDef defAnn, Mappings mappings) {
Properties params = new Properties(); Properties params = new Properties();
for ( Parameter param : defAnn.parameters() ) { for ( Parameter param : defAnn.parameters() ) {
params.setProperty( param.name(), param.value() ); params.setProperty( param.name(), param.value() );
@ -1306,7 +1325,7 @@ public final class AnnotationBinder {
Ejb3DiscriminatorColumn discriminatorColumn, Ejb3DiscriminatorColumn discriminatorColumn,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
ExtendedMappings mappings) { Mappings mappings) {
if ( rootClass.getDiscriminator() == null ) { if ( rootClass.getDiscriminator() == null ) {
if ( discriminatorColumn == null ) { if ( discriminatorColumn == null ) {
throw new AssertionFailure( "discriminator column should have been built" ); throw new AssertionFailure( "discriminator column should have been built" );
@ -1333,8 +1352,10 @@ public final class AnnotationBinder {
* the determined access strategy, {@code false} otherwise. * the determined access strategy, {@code false} otherwise.
*/ */
static int addElementsOfClass( static int addElementsOfClass(
List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, ExtendedMappings mappings List<PropertyData> elements,
) { AccessType defaultAccessType,
PropertyContainer propertyContainer,
Mappings mappings) {
int idPropertyCounter = 0; int idPropertyCounter = 0;
AccessType accessType = defaultAccessType; AccessType accessType = defaultAccessType;
@ -1353,9 +1374,11 @@ public final class AnnotationBinder {
} }
private static int addProperty( private static int addProperty(
PropertyContainer propertyContainer, XProperty property, List<PropertyData> annElts, PropertyContainer propertyContainer,
String propertyAccessor, ExtendedMappings mappings XProperty property,
) { List<PropertyData> annElts,
String propertyAccessor,
Mappings mappings) {
final XClass declaringClass = propertyContainer.getDeclaringClass(); final XClass declaringClass = propertyContainer.getDeclaringClass();
final XClass entity = propertyContainer.getEntityAtStake(); final XClass entity = propertyContainer.getEntityAtStake();
int idPropertyCounter = 0; int idPropertyCounter = 0;
@ -1391,12 +1414,16 @@ public final class AnnotationBinder {
*/ */
private static void processElementAnnotations( private static void processElementAnnotations(
PropertyHolder propertyHolder, Nullability nullability, PropertyHolder propertyHolder,
PropertyData inferredData, HashMap<String, IdGenerator> classGenerators, Nullability nullability,
EntityBinder entityBinder, boolean isIdentifierMapper, PropertyData inferredData,
boolean isComponentEmbedded, boolean inSecondPass, ExtendedMappings mappings, HashMap<String, IdGenerator> classGenerators,
Map<XClass, InheritanceState> inheritanceStatePerClass EntityBinder entityBinder,
) throws MappingException { boolean isIdentifierMapper,
boolean isComponentEmbedded,
boolean inSecondPass,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) throws MappingException {
/** /**
* inSecondPass can only be used to apply right away the second pass of a composite-element * inSecondPass can only be used to apply right away the second pass of a composite-element
* Because it's a value type, there is no bidirectional association, hence second pass * Because it's a value type, there is no bidirectional association, hence second pass
@ -2065,7 +2092,7 @@ public final class AnnotationBinder {
SimpleValue idValue, SimpleValue idValue,
HashMap<String, IdGenerator> classGenerators, HashMap<String, IdGenerator> classGenerators,
boolean isIdentifierMapper, boolean isIdentifierMapper,
ExtendedMappings mappings) { Mappings mappings) {
if ( isIdentifierMapper ) { if ( isIdentifierMapper ) {
throw new AnnotationException( throw new AnnotationException(
"@IdClass class should not have @Id nor @EmbeddedId properties: " "@IdClass class should not have @Id nor @EmbeddedId properties: "
@ -2103,10 +2130,13 @@ public final class AnnotationBinder {
//TODO move that to collection binder? //TODO move that to collection binder?
private static void bindJoinedTableAssociation( private static void bindJoinedTableAssociation(
XProperty property, ExtendedMappings mappings, EntityBinder entityBinder, XProperty property,
CollectionBinder collectionBinder, PropertyHolder propertyHolder, PropertyData inferredData, Mappings mappings,
String mappedBy EntityBinder entityBinder,
) { CollectionBinder collectionBinder,
PropertyHolder propertyHolder,
PropertyData inferredData,
String mappedBy) {
TableBinder associationTableBinder = new TableBinder(); TableBinder associationTableBinder = new TableBinder();
JoinColumn[] annJoins; JoinColumn[] annJoins;
JoinColumn[] annInverseJoins; JoinColumn[] annInverseJoins;
@ -2181,7 +2211,7 @@ public final class AnnotationBinder {
AccessType propertyAccessor, AccessType propertyAccessor,
EntityBinder entityBinder, EntityBinder entityBinder,
boolean isIdentifierMapper, boolean isIdentifierMapper,
ExtendedMappings mappings, Mappings mappings,
boolean isComponentEmbedded, boolean isComponentEmbedded,
boolean isId, //is a identifier boolean isId, //is a identifier
Map<XClass, InheritanceState> inheritanceStatePerClass, Map<XClass, InheritanceState> inheritanceStatePerClass,
@ -2240,13 +2270,16 @@ public final class AnnotationBinder {
} }
public static Component fillComponent( public static Component fillComponent(
PropertyHolder propertyHolder, PropertyData inferredData, PropertyHolder propertyHolder,
AccessType propertyAccessor, boolean isNullable, PropertyData inferredData,
AccessType propertyAccessor,
boolean isNullable,
EntityBinder entityBinder, EntityBinder entityBinder,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, boolean isComponentEmbedded,
ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass boolean isIdentifierMapper,
) { boolean inSecondPass,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
return fillComponent( return fillComponent(
propertyHolder, inferredData, null, propertyAccessor, propertyHolder, inferredData, null, propertyAccessor,
isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, mappings, isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, mappings,
@ -2255,13 +2288,17 @@ public final class AnnotationBinder {
} }
public static Component fillComponent( public static Component fillComponent(
PropertyHolder propertyHolder, PropertyData inferredData, PropertyHolder propertyHolder,
PropertyData inferredData,
PropertyData baseInferredData, //base inferred data correspond to the entity reproducing inferredData's properties (ie IdClass) PropertyData baseInferredData, //base inferred data correspond to the entity reproducing inferredData's properties (ie IdClass)
AccessType propertyAccessor, boolean isNullable, EntityBinder entityBinder, AccessType propertyAccessor,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mappings, boolean isNullable,
Map<XClass, InheritanceState> inheritanceStatePerClass EntityBinder entityBinder,
) { boolean isComponentEmbedded,
boolean isIdentifierMapper,
boolean inSecondPass,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
/** /**
* inSecondPass can only be used to apply right away the second pass of a composite-element * inSecondPass can only be used to apply right away the second pass of a composite-element
* Because it's a value type, there is no bidirectional association, hence second pass * Because it's a value type, there is no bidirectional association, hence second pass
@ -2380,7 +2417,7 @@ public final class AnnotationBinder {
PropertyData inferredData, PropertyData inferredData,
boolean isComponentEmbedded, boolean isComponentEmbedded,
boolean isIdentifierMapper, boolean isIdentifierMapper,
ExtendedMappings mappings) { Mappings mappings) {
Component comp = new Component( mappings, propertyHolder.getPersistentClass() ); Component comp = new Component( mappings, propertyHolder.getPersistentClass() );
comp.setEmbedded( isComponentEmbedded ); comp.setEmbedded( isComponentEmbedded );
//yuk //yuk
@ -2397,13 +2434,19 @@ public final class AnnotationBinder {
} }
private static void bindIdClass( private static void bindIdClass(
String generatorType, String generatorName, PropertyData inferredData, String generatorType,
PropertyData baseInferredData, Ejb3Column[] columns, PropertyHolder propertyHolder, String generatorName,
PropertyData inferredData,
PropertyData baseInferredData,
Ejb3Column[] columns,
PropertyHolder propertyHolder,
boolean isComposite, boolean isComposite,
AccessType propertyAccessor, EntityBinder entityBinder, boolean isEmbedded, AccessType propertyAccessor,
boolean isIdentifierMapper, ExtendedMappings mappings, EntityBinder entityBinder,
Map<XClass, InheritanceState> inheritanceStatePerClass boolean isEmbedded,
) { boolean isIdentifierMapper,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
/* /*
* Fill simple value and property since and Id is a property * Fill simple value and property since and Id is a property
@ -2485,7 +2528,7 @@ public final class AnnotationBinder {
PropertyData inferredData, PropertyData inferredData,
PropertyData baseInferredData, PropertyData baseInferredData,
AccessType propertyAccessor, AccessType propertyAccessor,
ExtendedMappings mappings) { Mappings mappings) {
List<PropertyData> baseClassElements = new ArrayList<PropertyData>(); List<PropertyData> baseClassElements = new ArrayList<PropertyData>();
XClass baseReturnedClassOrElement = baseInferredData.getClassOrElement(); XClass baseReturnedClassOrElement = baseInferredData.getClassOrElement();
PropertyContainer propContainer = new PropertyContainer( PropertyContainer propContainer = new PropertyContainer(
@ -2514,14 +2557,19 @@ public final class AnnotationBinder {
} }
private static void bindManyToOne( private static void bindManyToOne(
String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional, String cascadeStrategy,
boolean ignoreNotFound, boolean cascadeOnDelete, Ejb3JoinColumn[] columns,
XClass targetEntity, PropertyHolder propertyHolder, boolean optional,
PropertyData inferredData, boolean unique, boolean ignoreNotFound,
boolean isIdentifierMapper, boolean inSecondPass, boolean cascadeOnDelete,
XClass targetEntity,
PropertyHolder propertyHolder,
PropertyData inferredData,
boolean unique,
boolean isIdentifierMapper,
boolean inSecondPass,
PropertyBinder propertyBinder, PropertyBinder propertyBinder,
ExtendedMappings mappings Mappings mappings) {
) {
//All FK columns should be in the same table //All FK columns should be in the same table
org.hibernate.mapping.ManyToOne value = new org.hibernate.mapping.ManyToOne( mappings, columns[0].getTable() ); org.hibernate.mapping.ManyToOne value = new org.hibernate.mapping.ManyToOne( mappings, columns[0].getTable() );
// This is a @OneToOne mapped to a physical o.h.mapping.ManyToOne // This is a @OneToOne mapped to a physical o.h.mapping.ManyToOne
@ -2655,8 +2703,7 @@ public final class AnnotationBinder {
boolean isIdentifierMapper, boolean isIdentifierMapper,
boolean inSecondPass, boolean inSecondPass,
PropertyBinder propertyBinder, PropertyBinder propertyBinder,
ExtendedMappings mappings Mappings mappings) {
) {
//column.getTable() => persistentClass.getTable() //column.getTable() => persistentClass.getTable()
final String propertyName = inferredData.getPropertyName(); final String propertyName = inferredData.getPropertyName();
log.trace( "Fetching {} with {}", propertyName, fetchMode ); log.trace( "Fetching {} with {}", propertyName, fetchMode );
@ -2721,10 +2768,15 @@ public final class AnnotationBinder {
} }
private static void bindAny( private static void bindAny(
String cascadeStrategy, Ejb3JoinColumn[] columns, boolean cascadeOnDelete, Nullability nullability, String cascadeStrategy,
PropertyHolder propertyHolder, PropertyData inferredData, EntityBinder entityBinder, Ejb3JoinColumn[] columns,
boolean isIdentifierMapper, ExtendedMappings mappings boolean cascadeOnDelete,
) { Nullability nullability,
PropertyHolder propertyHolder,
PropertyData inferredData,
EntityBinder entityBinder,
boolean isIdentifierMapper,
Mappings mappings) {
org.hibernate.annotations.Any anyAnn = inferredData.getProperty() org.hibernate.annotations.Any anyAnn = inferredData.getProperty()
.getAnnotation( org.hibernate.annotations.Any.class ); .getAnnotation( org.hibernate.annotations.Any.class );
if ( anyAnn == null ) { if ( anyAnn == null ) {
@ -2759,7 +2811,7 @@ public final class AnnotationBinder {
propertyHolder.addProperty( prop, columns, inferredData.getDeclaringClass() ); propertyHolder.addProperty( prop, columns, inferredData.getDeclaringClass() );
} }
private static String generatorType(GenerationType generatorEnum, ExtendedMappings mappings) { private static String generatorType(GenerationType generatorEnum, Mappings mappings) {
boolean useNewGeneratorMappings = mappings.useNewGeneratorMappings(); boolean useNewGeneratorMappings = mappings.useNewGeneratorMappings();
switch ( generatorEnum ) { switch ( generatorEnum ) {
case IDENTITY: case IDENTITY:
@ -2811,8 +2863,10 @@ public final class AnnotationBinder {
} }
private static String getCascadeStrategy( private static String getCascadeStrategy(
javax.persistence.CascadeType[] ejbCascades, Cascade hibernateCascadeAnnotation, javax.persistence.CascadeType[] ejbCascades,
boolean orphanRemoval, boolean forcePersist) { Cascade hibernateCascadeAnnotation,
boolean orphanRemoval,
boolean forcePersist) {
EnumSet<CascadeType> hibernateCascadeSet = convertToHibernateCascadeType( ejbCascades ); EnumSet<CascadeType> hibernateCascadeSet = convertToHibernateCascadeType( ejbCascades );
CascadeType[] hibernateCascades = hibernateCascadeAnnotation == null ? CascadeType[] hibernateCascades = hibernateCascadeAnnotation == null ?
null : null :
@ -2883,7 +2937,7 @@ public final class AnnotationBinder {
} }
} }
private static HashMap<String, IdGenerator> buildLocalGenerators(XAnnotatedElement annElt, ExtendedMappings mappings) { private static HashMap<String, IdGenerator> buildLocalGenerators(XAnnotatedElement annElt, Mappings mappings) {
HashMap<String, IdGenerator> generators = new HashMap<String, IdGenerator>(); HashMap<String, IdGenerator> generators = new HashMap<String, IdGenerator>();
TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class ); TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class );
SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class ); SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class );
@ -2903,7 +2957,7 @@ public final class AnnotationBinder {
return generators; return generators;
} }
public static boolean isDefault(XClass clazz, ExtendedMappings mappings) { public static boolean isDefault(XClass clazz, Mappings mappings) {
return mappings.getReflectionManager().equals( clazz, void.class ); return mappings.getReflectionManager().equals( clazz, void.class );
} }
@ -2917,7 +2971,7 @@ public final class AnnotationBinder {
*/ */
public static Map<XClass, InheritanceState> buildInheritanceStates( public static Map<XClass, InheritanceState> buildInheritanceStates(
List<XClass> orderedClasses, List<XClass> orderedClasses,
ExtendedMappings mappings) { Mappings mappings) {
ReflectionManager reflectionManager = mappings.getReflectionManager(); ReflectionManager reflectionManager = mappings.getReflectionManager();
Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>( Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>(
orderedClasses.size() orderedClasses.size()

View File

@ -118,8 +118,8 @@ public class BinderHelper {
PersistentClass ownerEntity, PersistentClass ownerEntity,
PersistentClass associatedEntity, PersistentClass associatedEntity,
Value value, Value value,
boolean inverse, ExtendedMappings mappings boolean inverse,
) { Mappings mappings) {
//associated entity only used for more precise exception, yuk! //associated entity only used for more precise exception, yuk!
if ( columns[0].isImplicit() || StringHelper.isNotEmpty( columns[0].getMappedBy() ) ) return; if ( columns[0].isImplicit() || StringHelper.isNotEmpty( columns[0].getMappedBy() ) ) return;
int fkEnum = Ejb3JoinColumn.checkReferencedColumnsType( columns, ownerEntity, mappings ); int fkEnum = Ejb3JoinColumn.checkReferencedColumnsType( columns, ownerEntity, mappings );
@ -232,9 +232,9 @@ public class BinderHelper {
private static List<Property> findPropertiesByColumns( private static List<Property> findPropertiesByColumns(
Object columnOwner, Ejb3JoinColumn[] columns, Object columnOwner,
ExtendedMappings mappings Ejb3JoinColumn[] columns,
) { Mappings mappings) {
Map<Column, Set<Property>> columnsToProperty = new HashMap<Column, Set<Property>>(); Map<Column, Set<Property>> columnsToProperty = new HashMap<Column, Set<Property>>();
List<Column> orderedColumns = new ArrayList<Column>( columns.length ); List<Column> orderedColumns = new ArrayList<Column>( columns.length );
Table referencedTable = null; Table referencedTable = null;
@ -434,8 +434,9 @@ public class BinderHelper {
* If columnName is null or empty, persistentClass is returned * If columnName is null or empty, persistentClass is returned
*/ */
public static Object findColumnOwner( public static Object findColumnOwner(
PersistentClass persistentClass, String columnName, ExtendedMappings mappings PersistentClass persistentClass,
) { String columnName,
Mappings mappings) {
if ( StringHelper.isEmpty( columnName ) ) { if ( StringHelper.isEmpty( columnName ) ) {
return persistentClass; //shortcut for implicit referenced column names return persistentClass; //shortcut for implicit referenced column names
} }
@ -474,9 +475,11 @@ public class BinderHelper {
* apply an id generator to a SimpleValue * apply an id generator to a SimpleValue
*/ */
public static void makeIdGenerator( public static void makeIdGenerator(
SimpleValue id, String generatorType, String generatorName, ExtendedMappings mappings, SimpleValue id,
Map<String, IdGenerator> localGenerators String generatorType,
) { String generatorName,
Mappings mappings,
Map<String, IdGenerator> localGenerators) {
Table table = id.getTable(); Table table = id.getTable();
table.setIdentifierValue( id ); table.setIdentifierValue( id );
//generator settings //generator settings
@ -528,9 +531,17 @@ public class BinderHelper {
//equivalent to (but faster) ANNOTATION_STRING_DEFAULT.equals( annotationString ); //equivalent to (but faster) ANNOTATION_STRING_DEFAULT.equals( annotationString );
} }
public static Any buildAnyValue(String anyMetaDefName, Ejb3JoinColumn[] columns, javax.persistence.Column metaColumn, PropertyData inferredData, public static Any buildAnyValue(
boolean cascadeOnDelete, Nullability nullability, PropertyHolder propertyHolder, String anyMetaDefName,
EntityBinder entityBinder, boolean optional, ExtendedMappings mappings) { Ejb3JoinColumn[] columns,
javax.persistence.Column metaColumn,
PropertyData inferredData,
boolean cascadeOnDelete,
Nullability nullability,
PropertyHolder propertyHolder,
EntityBinder entityBinder,
boolean optional,
Mappings mappings) {
//All FK columns should be in the same table //All FK columns should be in the same table
Any value = new Any( mappings, columns[0].getTable() ); Any value = new Any( mappings, columns[0].getTable() );
AnyMetaDef metaAnnDef = inferredData.getProperty().getAnnotation( AnyMetaDef.class ); AnyMetaDef metaAnnDef = inferredData.getProperty().getAnnotation( AnyMetaDef.class );
@ -577,8 +588,10 @@ public class BinderHelper {
} }
} }
Ejb3Column[] metaColumns = Ejb3Column.buildColumnFromAnnotation( new javax.persistence.Column[] { metaColumn }, null, Ejb3Column[] metaColumns = Ejb3Column.buildColumnFromAnnotation(
nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings ); new javax.persistence.Column[] { metaColumn }, null,
nullability, propertyHolder, inferredData, entityBinder.getSecondaryTables(), mappings
);
//set metaColumn to the right table //set metaColumn to the right table
for (Ejb3Column column : metaColumns) { for (Ejb3Column column : metaColumns) {
column.setTable( value.getTable() ); column.setTable( value.getTable() );
@ -597,7 +610,7 @@ public class BinderHelper {
return value; return value;
} }
public static void bindAnyMetaDefs(XAnnotatedElement annotatedElement, ExtendedMappings mappings) { public static void bindAnyMetaDefs(XAnnotatedElement annotatedElement, Mappings mappings) {
AnyMetaDef defAnn = annotatedElement.getAnnotation( AnyMetaDef.class ); AnyMetaDef defAnn = annotatedElement.getAnnotation( AnyMetaDef.class );
AnyMetaDefs defsAnn = annotatedElement.getAnnotation( AnyMetaDefs.class ); AnyMetaDefs defsAnn = annotatedElement.getAnnotation( AnyMetaDefs.class );
boolean mustHaveName = XClass.class.isAssignableFrom( annotatedElement.getClass() ) boolean mustHaveName = XClass.class.isAssignableFrom( annotatedElement.getClass() )
@ -623,15 +636,16 @@ public class BinderHelper {
} }
} }
private static void bindAnyMetaDef(AnyMetaDef defAnn, ExtendedMappings mappings) { private static void bindAnyMetaDef(AnyMetaDef defAnn, Mappings mappings) {
if ( isDefault( defAnn.name() ) ) return; //don't map not named definitions if ( isDefault( defAnn.name() ) ) return; //don't map not named definitions
log.info( "Binding Any Meta definition: {}", defAnn.name() ); log.info( "Binding Any Meta definition: {}", defAnn.name() );
mappings.addAnyMetaDef( defAnn ); mappings.addAnyMetaDef( defAnn );
} }
public static MappedSuperclass getMappedSuperclassOrNull(XClass declaringClass, public static MappedSuperclass getMappedSuperclassOrNull(
XClass declaringClass,
Map<XClass, InheritanceState> inheritanceStatePerClass, Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings) { Mappings mappings) {
boolean retrieve = false; boolean retrieve = false;
if ( declaringClass != null ) { if ( declaringClass != null ) {
final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass ); final InheritanceState inheritanceState = inheritanceStatePerClass.get( declaringClass );
@ -653,7 +667,11 @@ public class BinderHelper {
return StringHelper.qualify( holder.getPath(), property.getPropertyName() ); return StringHelper.qualify( holder.getPath(), property.getPropertyName() );
} }
static PropertyData getPropertyOverriddenByMapperOrMapsId(boolean isId, PropertyHolder propertyHolder, String propertyName, ExtendedMappings mappings) { static PropertyData getPropertyOverriddenByMapperOrMapsId(
boolean isId,
PropertyHolder propertyHolder,
String propertyName,
Mappings mappings) {
final XClass persistentXClass; final XClass persistentXClass;
try { try {
persistentXClass = mappings.getReflectionManager() persistentXClass = mappings.getReflectionManager()

View File

@ -49,9 +49,11 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
private final Map<XClass, InheritanceState> inheritanceStatePerClass; private final Map<XClass, InheritanceState> inheritanceStatePerClass;
public ClassPropertyHolder( public ClassPropertyHolder(
PersistentClass persistentClass, XClass clazzToProcess, PersistentClass persistentClass,
Map<String, Join> joins, ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass XClass clazzToProcess,
) { Map<String, Join> joins,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
super( persistentClass.getEntityName(), null, clazzToProcess, mappings ); super( persistentClass.getEntityName(), null, clazzToProcess, mappings );
this.persistentClass = persistentClass; this.persistentClass = persistentClass;
this.joins = joins; this.joins = joins;
@ -59,9 +61,11 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
} }
public ClassPropertyHolder( public ClassPropertyHolder(
PersistentClass persistentClass, XClass clazzToProcess, EntityBinder entityBinder, PersistentClass persistentClass,
ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass XClass clazzToProcess,
) { EntityBinder entityBinder,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
this( persistentClass, clazzToProcess, entityBinder.getSecondaryTables(), mappings, inheritanceStatePerClass ); this( persistentClass, clazzToProcess, entityBinder.getSecondaryTables(), mappings, inheritanceStatePerClass );
this.entityBinder = entityBinder; this.entityBinder = entityBinder;
} }
@ -127,7 +131,7 @@ public class ClassPropertyHolder extends AbstractPropertyHolder {
} }
private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) { private void addPropertyToMappedSuperclass(Property prop, XClass declaringClass) {
final ExtendedMappings mappings = getMappings(); final Mappings mappings = getMappings();
final Class type = mappings.getReflectionManager().toClass( declaringClass ); final Class type = mappings.getReflectionManager().toClass( declaringClass );
MappedSuperclass superclass = mappings.getMappedSuperclass( type ); MappedSuperclass superclass = mappings.getMappedSuperclass( type );
superclass.addDeclaredProperty( prop ); superclass.addDeclaredProperty( prop );

View File

@ -42,9 +42,12 @@ public class CollectionPropertyHolder extends AbstractPropertyHolder {
Collection collection; Collection collection;
public CollectionPropertyHolder( public CollectionPropertyHolder(
Collection collection, String path, XClass clazzToProcess, XProperty property, Collection collection,
PropertyHolder parentPropertyHolder, ExtendedMappings mappings String path,
) { XClass clazzToProcess,
XProperty property,
PropertyHolder parentPropertyHolder,
Mappings mappings) {
super( path, parentPropertyHolder, clazzToProcess, mappings ); super( path, parentPropertyHolder, clazzToProcess, mappings );
this.collection = collection; this.collection = collection;
setCurrentProperty( property ); setCurrentProperty( property );

View File

@ -46,7 +46,7 @@ import org.hibernate.util.StringHelper;
/** /**
* Do the initial discovery of columns metadata and apply defaults. * Do the initial discovery of columns metadata and apply defaults.
* Also hosts some convinient methods related to column processing * Also hosts some convenient methods related to column processing
* *
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
@ -56,11 +56,17 @@ class ColumnsBuilder {
private XProperty property; private XProperty property;
private PropertyData inferredData; private PropertyData inferredData;
private EntityBinder entityBinder; private EntityBinder entityBinder;
private ExtendedMappings mappings; private Mappings mappings;
private Ejb3Column[] columns; private Ejb3Column[] columns;
private Ejb3JoinColumn[] joinColumns; private Ejb3JoinColumn[] joinColumns;
public ColumnsBuilder(PropertyHolder propertyHolder, Nullability nullability, XProperty property, PropertyData inferredData, EntityBinder entityBinder, ExtendedMappings mappings) { public ColumnsBuilder(
PropertyHolder propertyHolder,
Nullability nullability,
XProperty property,
PropertyData inferredData,
EntityBinder entityBinder,
Mappings mappings) {
this.propertyHolder = propertyHolder; this.propertyHolder = propertyHolder;
this.nullability = nullability; this.nullability = nullability;
this.property = property; this.property = property;
@ -214,7 +220,9 @@ class ColumnsBuilder {
Ejb3Column[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) { Ejb3Column[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) {
Ejb3Column[] result = columns; Ejb3Column[] result = columns;
final PropertyData overridingProperty = BinderHelper.getPropertyOverriddenByMapperOrMapsId( isId, propertyHolder, property.getName(), mappings ); final PropertyData overridingProperty = BinderHelper.getPropertyOverriddenByMapperOrMapsId(
isId, propertyHolder, property.getName(), mappings
);
if ( overridingProperty != null ) { if ( overridingProperty != null ) {
result = buildExcplicitOrDefaultJoinColumn( overridingProperty ); result = buildExcplicitOrDefaultJoinColumn( overridingProperty );
} }

View File

@ -84,9 +84,11 @@ public class ComponentPropertyHolder extends AbstractPropertyHolder {
} }
public ComponentPropertyHolder( public ComponentPropertyHolder(
Component component, String path, PropertyData inferredData, PropertyHolder parent, Component component,
ExtendedMappings mappings String path,
) { PropertyData inferredData,
PropertyHolder parent,
Mappings mappings) {
super( path, parent, inferredData.getPropertyClass(), mappings ); super( path, parent, inferredData.getPropertyClass(), mappings );
final XProperty property = inferredData.getProperty(); final XProperty property = inferredData.getProperty();
setCurrentProperty( property ); setCurrentProperty( property );

View File

@ -975,7 +975,7 @@ public class Configuration implements Serializable {
* *
* @return The created mappings * @return The created mappings
*/ */
public ExtendedMappings createMappings() { public Mappings createMappings() {
return new MappingsImpl(); return new MappingsImpl();
} }
@ -4018,7 +4018,7 @@ public class Configuration implements Serializable {
log.debug( "Process annotated classes" ); log.debug( "Process annotated classes" );
//bind classes in the correct order calculating some inheritance state //bind classes in the correct order calculating some inheritance state
List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses ); List<XClass> orderedClasses = orderAndFillHierarchy( annotatedClasses );
ExtendedMappings mappings = createMappings(); Mappings mappings = createMappings();
Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates( Map<XClass, InheritanceState> inheritanceStatePerClass = AnnotationBinder.buildInheritanceStates(
orderedClasses, mappings orderedClasses, mappings
); );

View File

@ -42,28 +42,32 @@ import org.hibernate.mapping.SimpleValue;
public class CopyIdentifierComponentSecondPass implements SecondPass { public class CopyIdentifierComponentSecondPass implements SecondPass {
private final String referencedEntityName; private final String referencedEntityName;
private final Component component; private final Component component;
private final ExtendedMappings mappings; private final Mappings mappings;
private final Ejb3JoinColumn[] joinColumns; private final Ejb3JoinColumn[] joinColumns;
public CopyIdentifierComponentSecondPass( public CopyIdentifierComponentSecondPass(
Component comp, String referencedEntityName, Ejb3JoinColumn[] joinColumns, ExtendedMappings mappings) { Component comp,
String referencedEntityName,
Ejb3JoinColumn[] joinColumns,
Mappings mappings) {
this.component = comp; this.component = comp;
this.referencedEntityName = referencedEntityName; this.referencedEntityName = referencedEntityName;
this.mappings = mappings; this.mappings = mappings;
this.joinColumns = joinColumns; this.joinColumns = joinColumns;
} }
//FIXME better error names @SuppressWarnings({ "unchecked" })
public void doSecondPass(Map persistentClasses) throws MappingException { public void doSecondPass(Map persistentClasses) throws MappingException {
PersistentClass referencedPersistentClass = (PersistentClass) persistentClasses.get( referencedEntityName ); PersistentClass referencedPersistentClass = (PersistentClass) persistentClasses.get( referencedEntityName );
// TODO better error names
if ( referencedPersistentClass == null ) { if ( referencedPersistentClass == null ) {
throw new AnnotationException( throw new AnnotationException( "Unknown entity name: " + referencedEntityName );
"Unknown entity name: " + referencedEntityName }
);
};
if ( ! ( referencedPersistentClass.getIdentifier() instanceof Component ) ) { if ( ! ( referencedPersistentClass.getIdentifier() instanceof Component ) ) {
throw new AssertionFailure( "Unexpected identifier type on the referenced entity when mapping a @MapsId: " throw new AssertionFailure(
+ referencedEntityName); "Unexpected identifier type on the referenced entity when mapping a @MapsId: "
+ referencedEntityName
);
} }
Component referencedComponent = (Component) referencedPersistentClass.getIdentifier(); Component referencedComponent = (Component) referencedPersistentClass.getIdentifier();
Iterator<Property> properties = referencedComponent.getPropertyIterator(); Iterator<Property> properties = referencedComponent.getPropertyIterator();

View File

@ -52,7 +52,7 @@ public class Ejb3Column {
private String secondaryTableName; private String secondaryTableName;
protected Map<String, Join> joins; protected Map<String, Join> joins;
protected PropertyHolder propertyHolder; protected PropertyHolder propertyHolder;
private ExtendedMappings mappings; private Mappings mappings;
private boolean isImplicit; private boolean isImplicit;
public static final int DEFAULT_COLUMN_LENGTH = 255; public static final int DEFAULT_COLUMN_LENGTH = 255;
public String sqlType; public String sqlType;
@ -96,7 +96,7 @@ public class Ejb3Column {
} }
public boolean isFormula() { public boolean isFormula() {
return StringHelper.isNotEmpty(formulaString) ? true : false; return StringHelper.isNotEmpty( formulaString );
} }
public String getFormulaString() { public String getFormulaString() {
@ -123,11 +123,11 @@ public class Ejb3Column {
this.updatable = updatable; this.updatable = updatable;
} }
protected ExtendedMappings getMappings() { protected Mappings getMappings() {
return mappings; return mappings;
} }
public void setMappings(ExtendedMappings mappings) { public void setMappings(Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
} }
@ -362,23 +362,25 @@ public class Ejb3Column {
public static Ejb3Column[] buildColumnFromAnnotation( public static Ejb3Column[] buildColumnFromAnnotation(
javax.persistence.Column[] anns, javax.persistence.Column[] anns,
org.hibernate.annotations.Formula formulaAnn, Nullability nullability, PropertyHolder propertyHolder, org.hibernate.annotations.Formula formulaAnn,
Nullability nullability,
PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
ExtendedMappings mappings Mappings mappings){
){
return buildColumnFromAnnotation( return buildColumnFromAnnotation(
anns, anns, formulaAnn, nullability, propertyHolder, inferredData, null, secondaryTables, mappings
formulaAnn, nullability, propertyHolder, inferredData, null, secondaryTables, mappings); );
} }
public static Ejb3Column[] buildColumnFromAnnotation( public static Ejb3Column[] buildColumnFromAnnotation(
javax.persistence.Column[] anns, javax.persistence.Column[] anns,
org.hibernate.annotations.Formula formulaAnn, Nullability nullability, PropertyHolder propertyHolder, org.hibernate.annotations.Formula formulaAnn,
Nullability nullability,
PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
String suffixForDefaultColumnName, String suffixForDefaultColumnName,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
ExtendedMappings mappings Mappings mappings) {
) {
Ejb3Column[] columns; Ejb3Column[] columns;
if ( formulaAnn != null ) { if ( formulaAnn != null ) {
Ejb3Column formulaColumn = new Ejb3Column(); Ejb3Column formulaColumn = new Ejb3Column();
@ -463,7 +465,7 @@ public class Ejb3Column {
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
Nullability nullability, Nullability nullability,
ExtendedMappings mappings) { Mappings mappings) {
Ejb3Column column = new Ejb3Column(); Ejb3Column column = new Ejb3Column();
Ejb3Column[] columns = new Ejb3Column[1]; Ejb3Column[] columns = new Ejb3Column[1];
columns[0] = column; columns[0] = column;

View File

@ -35,13 +35,11 @@ import org.hibernate.annotations.DiscriminatorFormula;
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class Ejb3DiscriminatorColumn extends Ejb3Column { public class Ejb3DiscriminatorColumn extends Ejb3Column {
private static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "DTYPE"; private static final String DEFAULT_DISCRIMINATOR_COLUMN_NAME = "DTYPE";
private static final String DEFAULT_DISCRIMINATOR_TYPE = "string"; private static final String DEFAULT_DISCRIMINATOR_TYPE = "string";
private static final int DEFAULT_DISCRIMINATOR_LENGTH = 31;
private String discriminatorTypeName; private String discriminatorTypeName;
private static final int DEFAULT_DISCRIMINATOR_LENGTH = 31;
public Ejb3DiscriminatorColumn() { public Ejb3DiscriminatorColumn() {
//discriminator default value //discriminator default value
@ -61,9 +59,9 @@ public class Ejb3DiscriminatorColumn extends Ejb3Column {
} }
public static Ejb3DiscriminatorColumn buildDiscriminatorColumn( public static Ejb3DiscriminatorColumn buildDiscriminatorColumn(
DiscriminatorType type, DiscriminatorColumn discAnn, DiscriminatorFormula discFormulaAnn, DiscriminatorType type, DiscriminatorColumn discAnn,
ExtendedMappings mappings DiscriminatorFormula discFormulaAnn,
) { Mappings mappings) {
Ejb3DiscriminatorColumn discriminatorColumn = new Ejb3DiscriminatorColumn(); Ejb3DiscriminatorColumn discriminatorColumn = new Ejb3DiscriminatorColumn();
discriminatorColumn.setMappings( mappings ); discriminatorColumn.setMappings( mappings );
discriminatorColumn.setImplicit( true ); discriminatorColumn.setImplicit( true );

View File

@ -69,7 +69,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
this.JPA2ElementCollection = JPA2ElementCollection; this.JPA2ElementCollection = JPA2ElementCollection;
} }
//FIXME hacky solution to get the information at property ref resolution // TODO hacky solution to get the information at property ref resolution
public String getManyToManyOwnerSideEntityName() { public String getManyToManyOwnerSideEntityName() {
return manyToManyOwnerSideEntityName; return manyToManyOwnerSideEntityName;
} }
@ -113,8 +113,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
String propertyName, String propertyName,
String mappedBy, String mappedBy,
boolean isImplicit, boolean isImplicit,
ExtendedMappings mappings Mappings mappings) {
) {
super(); super();
setImplicit( isImplicit ); setImplicit( isImplicit );
setSqlType( sqlType ); setSqlType( sqlType );
@ -137,25 +136,27 @@ public class Ejb3JoinColumn extends Ejb3Column {
return referencedColumn; return referencedColumn;
} }
public static Ejb3JoinColumn[] buildJoinColumnsOrFormulas( public static Ejb3JoinColumn[] buildJoinColumnsOrFormulas(
JoinColumnsOrFormulas anns, JoinColumnsOrFormulas anns,
String mappedBy, Map<String, Join> joins, String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
String propertyName, String propertyName,
ExtendedMappings mappings Mappings mappings) {
) {
JoinColumnOrFormula [] ann = anns.value(); JoinColumnOrFormula [] ann = anns.value();
Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length]; Ejb3JoinColumn [] joinColumns = new Ejb3JoinColumn[ann.length];
for (int i = 0; i < ann.length; i++) { for (int i = 0; i < ann.length; i++) {
JoinColumnOrFormula join = (JoinColumnOrFormula) ann[i]; JoinColumnOrFormula join = (JoinColumnOrFormula) ann[i];
JoinFormula formula = join.formula(); JoinFormula formula = join.formula();
if (formula.value() != null && !formula.value().equals("")) { if (formula.value() != null && !formula.value().equals("")) {
joinColumns[i] = buildJoinFormula(formula, mappedBy, joins, propertyHolder, propertyName, mappings); joinColumns[i] = buildJoinFormula(
formula, mappedBy, joins, propertyHolder, propertyName, mappings
);
} }
else { else {
joinColumns[i] = buildJoinColumns(new JoinColumn[] { join.column() }, mappedBy, joins, propertyHolder, propertyName, mappings)[0]; joinColumns[i] = buildJoinColumns(
new JoinColumn[] { join.column() }, mappedBy, joins, propertyHolder, propertyName, mappings
)[0];
} }
} }
@ -167,12 +168,11 @@ public class Ejb3JoinColumn extends Ejb3Column {
*/ */
public static Ejb3JoinColumn buildJoinFormula( public static Ejb3JoinColumn buildJoinFormula(
JoinFormula ann, JoinFormula ann,
String mappedBy, Map<String, Join> joins, String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
String propertyName, String propertyName,
ExtendedMappings mappings Mappings mappings) {
) {
Ejb3JoinColumn formulaColumn = new Ejb3JoinColumn(); Ejb3JoinColumn formulaColumn = new Ejb3JoinColumn();
formulaColumn.setFormula( ann.value() ); formulaColumn.setFormula( ann.value() );
formulaColumn.setReferencedColumn(ann.referencedColumnName()); formulaColumn.setReferencedColumn(ann.referencedColumnName());
@ -180,30 +180,30 @@ public class Ejb3JoinColumn extends Ejb3Column {
formulaColumn.setPropertyHolder( propertyHolder ); formulaColumn.setPropertyHolder( propertyHolder );
formulaColumn.setJoins( joins ); formulaColumn.setJoins( joins );
formulaColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolder, propertyName ) ); formulaColumn.setPropertyName( BinderHelper.getRelativePath( propertyHolder, propertyName ) );
formulaColumn.bind(); formulaColumn.bind();
return formulaColumn; return formulaColumn;
} }
public static Ejb3JoinColumn[] buildJoinColumns( public static Ejb3JoinColumn[] buildJoinColumns(
JoinColumn[] anns, JoinColumn[] anns,
String mappedBy, Map<String, Join> joins, String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
String propertyName, String propertyName,
ExtendedMappings mappings Mappings mappings) {
) { return buildJoinColumnsWithDefaultColumnSuffix(
return buildJoinColumnsWithDefaultColumnSuffix(anns, mappedBy, joins, propertyHolder, propertyName, "", mappings); anns, mappedBy, joins, propertyHolder, propertyName, "", mappings
);
} }
public static Ejb3JoinColumn[] buildJoinColumnsWithDefaultColumnSuffix( public static Ejb3JoinColumn[] buildJoinColumnsWithDefaultColumnSuffix(
JoinColumn[] anns, JoinColumn[] anns,
String mappedBy, Map<String, Join> joins, String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
String propertyName, String propertyName,
String suffixForDefaultColumnName, String suffixForDefaultColumnName,
ExtendedMappings mappings Mappings mappings) {
) {
JoinColumn[] actualColumns = propertyHolder.getOverriddenJoinColumn( JoinColumn[] actualColumns = propertyHolder.getOverriddenJoinColumn(
StringHelper.qualify( propertyHolder.getPath(), propertyName ) StringHelper.qualify( propertyHolder.getPath(), propertyName )
); );
@ -247,8 +247,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
String propertyName, String propertyName,
String suffixForDefaultColumnName, String suffixForDefaultColumnName,
ExtendedMappings mappings Mappings mappings) {
) {
if ( ann != null ) { if ( ann != null ) {
if ( BinderHelper.isDefault( mappedBy ) ) { if ( BinderHelper.isDefault( mappedBy ) ) {
throw new AnnotationException( throw new AnnotationException(
@ -293,7 +292,7 @@ public class Ejb3JoinColumn extends Ejb3Column {
} }
//FIXME default name still useful in association table // TODO default name still useful in association table
public void setJoinAnnotation(JoinColumn annJoin, String defaultName) { public void setJoinAnnotation(JoinColumn annJoin, String defaultName) {
if ( annJoin == null ) { if ( annJoin == null ) {
setImplicit( true ); setImplicit( true );
@ -319,9 +318,8 @@ public class Ejb3JoinColumn extends Ejb3Column {
JoinColumn joinAnn, JoinColumn joinAnn,
Value identifier, Value identifier,
Map<String, Join> joins, Map<String, Join> joins,
PropertyHolder propertyHolder, ExtendedMappings mappings PropertyHolder propertyHolder,
) { Mappings mappings) {
Column col = (Column) identifier.getColumnIterator().next(); Column col = (Column) identifier.getColumnIterator().next();
String defaultName = mappings.getLogicalColumnName( col.getQuotedName(), identifier.getTable() ); String defaultName = mappings.getLogicalColumnName( col.getQuotedName(), identifier.getTable() );
if ( pkJoinAnn != null || joinAnn != null ) { if ( pkJoinAnn != null || joinAnn != null ) {
@ -369,10 +367,11 @@ public class Ejb3JoinColumn extends Ejb3Column {
* Override persistent class on oneToMany Cases for late settings * Override persistent class on oneToMany Cases for late settings
* Must only be used on second level pass binding * Must only be used on second level pass binding
*/ */
public void setPersistentClass(PersistentClass persistentClass, public void setPersistentClass(
PersistentClass persistentClass,
Map<String, Join> joins, Map<String, Join> joins,
Map<XClass, InheritanceState> inheritanceStatePerClass) { Map<XClass, InheritanceState> inheritanceStatePerClass) {
//FIXME shouldn't we deduce the classname from the persistentclasS? // TODO shouldn't we deduce the classname from the persistentclasS?
this.propertyHolder = PropertyHolderBuilder.buildPropertyHolder( persistentClass, joins, getMappings(), inheritanceStatePerClass ); this.propertyHolder = PropertyHolderBuilder.buildPropertyHolder( persistentClass, joins, getMappings(), inheritanceStatePerClass );
} }
@ -390,8 +389,9 @@ public class Ejb3JoinColumn extends Ejb3Column {
public void copyReferencedStructureAndCreateDefaultJoinColumns( public void copyReferencedStructureAndCreateDefaultJoinColumns(
PersistentClass referencedEntity, Iterator columnIterator, SimpleValue value PersistentClass referencedEntity,
) { Iterator columnIterator,
SimpleValue value) {
if ( !isNameDeferred() ) { if ( !isNameDeferred() ) {
throw new AssertionFailure( "Building implicit column but the column is not implicit" ); throw new AssertionFailure( "Building implicit column but the column is not implicit" );
} }
@ -404,8 +404,9 @@ public class Ejb3JoinColumn extends Ejb3Column {
} }
public void linkValueUsingDefaultColumnNaming( public void linkValueUsingDefaultColumnNaming(
Column referencedColumn, PersistentClass referencedEntity, SimpleValue value Column referencedColumn,
) { PersistentClass referencedEntity,
SimpleValue value) {
String columnName; String columnName;
String logicalReferencedColumn = getMappings().getLogicalColumnName( String logicalReferencedColumn = getMappings().getLogicalColumnName(
referencedColumn.getQuotedName(), referencedEntity.getTable() referencedColumn.getQuotedName(), referencedEntity.getTable()
@ -528,9 +529,9 @@ public class Ejb3JoinColumn extends Ejb3Column {
public static final int NON_PK_REFERENCE = 2; public static final int NON_PK_REFERENCE = 2;
public static int checkReferencedColumnsType( public static int checkReferencedColumnsType(
Ejb3JoinColumn[] columns, PersistentClass referencedEntity, Ejb3JoinColumn[] columns,
ExtendedMappings mappings PersistentClass referencedEntity,
) { Mappings mappings) {
//convenient container to find whether a column is an id one or not //convenient container to find whether a column is an id one or not
Set<Column> idColumns = new HashSet<Column>(); Set<Column> idColumns = new HashSet<Column>();
Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator(); Iterator idColumnsIt = referencedEntity.getKey().getColumnIterator();
@ -605,7 +606,6 @@ public class Ejb3JoinColumn extends Ejb3Column {
* @param column the referenced column. * @param column the referenced column.
*/ */
public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) { public void overrideFromReferencedColumnIfNecessary(org.hibernate.mapping.Column column) {
if (getMappingColumn() != null) { if (getMappingColumn() != null) {
// columnDefinition can also be specified using @JoinColumn, hence we have to check // columnDefinition can also be specified using @JoinColumn, hence we have to check
// whether it is set or not // whether it is set or not
@ -633,9 +633,12 @@ public class Ejb3JoinColumn extends Ejb3Column {
} }
public static Ejb3JoinColumn[] buildJoinTableJoinColumns( public static Ejb3JoinColumn[] buildJoinTableJoinColumns(
JoinColumn[] annJoins, Map<String, Join> secondaryTables, JoinColumn[] annJoins,
PropertyHolder propertyHolder, String propertyName, String mappedBy, ExtendedMappings mappings Map<String, Join> secondaryTables,
) { PropertyHolder propertyHolder,
String propertyName,
String mappedBy,
Mappings mappings) {
Ejb3JoinColumn[] joinColumns; Ejb3JoinColumn[] joinColumns;
if ( annJoins == null ) { if ( annJoins == null ) {
Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn(); Ejb3JoinColumn currentJoinColumn = new Ejb3JoinColumn();

View File

@ -34,12 +34,10 @@ import org.hibernate.mapping.Join;
* *
* @author inger * @author inger
*/ */
public class IndexColumn public class IndexColumn extends Ejb3Column {
extends Ejb3Column {
private int base; private int base;
//FIXME move to a getter setter strategy for readeability // TODO move to a getter setter strategy for readability
public IndexColumn( public IndexColumn(
boolean isImplicit, boolean isImplicit,
String sqlType, String sqlType,
@ -54,8 +52,7 @@ public class IndexColumn
String secondaryTableName, String secondaryTableName,
Map<String, Join> joins, Map<String, Join> joins,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
ExtendedMappings mappings Mappings mappings) {
) {
super(); super();
setImplicit( isImplicit ); setImplicit( isImplicit );
setSqlType( sqlType ); setSqlType( sqlType );
@ -72,8 +69,6 @@ public class IndexColumn
setJoins( joins ); setJoins( joins );
setMappings( mappings ); setMappings( mappings );
bind(); bind();
//super(isImplicit, sqlType, length, precision, scale, name, nullable, unique, insertable, updatable, secondaryTableName, joins, propertyHolder, mappings);
} }
public int getBase() { public int getBase() {
@ -90,8 +85,7 @@ public class IndexColumn
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
Map<String, Join> secondaryTables, Map<String, Join> secondaryTables,
ExtendedMappings mappings Mappings mappings) {
) {
IndexColumn column; IndexColumn column;
if ( ann != null ) { if ( ann != null ) {
String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition(); String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();
@ -123,8 +117,7 @@ public class IndexColumn
org.hibernate.annotations.IndexColumn ann, org.hibernate.annotations.IndexColumn ann,
PropertyHolder propertyHolder, PropertyHolder propertyHolder,
PropertyData inferredData, PropertyData inferredData,
ExtendedMappings mappings Mappings mappings) {
) {
IndexColumn column; IndexColumn column;
if ( ann != null ) { if ( ann != null ) {
String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition(); String sqlType = BinderHelper.isDefault( ann.columnDefinition() ) ? null : ann.columnDefinition();

View File

@ -37,14 +37,14 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
private Table table; private Table table;
private final String indexName; private final String indexName;
private final String[] columns; private final String[] columns;
private final ExtendedMappings mappings; private final Mappings mappings;
private final Ejb3Column column; private final Ejb3Column column;
private final boolean unique; private final boolean unique;
/** /**
* Build an index * Build an index
*/ */
public IndexOrUniqueKeySecondPass(Table table, String indexName, String[] columns, ExtendedMappings mappings) { public IndexOrUniqueKeySecondPass(Table table, String indexName, String[] columns, Mappings mappings) {
this.table = table; this.table = table;
this.indexName = indexName; this.indexName = indexName;
this.columns = columns; this.columns = columns;
@ -56,15 +56,14 @@ public class IndexOrUniqueKeySecondPass implements SecondPass {
/** /**
* Build an index * Build an index
*/ */
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, ExtendedMappings mappings) { public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, Mappings mappings) {
this( indexName, column, mappings, false ); this( indexName, column, mappings, false );
} }
/** /**
* Build an index if unique is false or a Unique Key if unique is true * Build an index if unique is false or a Unique Key if unique is true
*/ */
public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, public IndexOrUniqueKeySecondPass(String indexName, Ejb3Column column, Mappings mappings, boolean unique) {
ExtendedMappings mappings, boolean unique) {
this.indexName = indexName; this.indexName = indexName;
this.column = column; this.column = column;
this.columns = null; this.columns = null;

View File

@ -62,14 +62,12 @@ public class InheritanceState {
private boolean isEmbeddableSuperclass = false; private boolean isEmbeddableSuperclass = false;
private Map<XClass, InheritanceState> inheritanceStatePerClass; private Map<XClass, InheritanceState> inheritanceStatePerClass;
private List<XClass> classesToProcessForMappedSuperclass = new ArrayList<XClass>(); private List<XClass> classesToProcessForMappedSuperclass = new ArrayList<XClass>();
private ExtendedMappings mappings; private Mappings mappings;
private AccessType accessType; private AccessType accessType;
private ElementsToProcess elementsToProcess; private ElementsToProcess elementsToProcess;
private Boolean hasIdClassOrEmbeddedId; private Boolean hasIdClassOrEmbeddedId;
public InheritanceState(XClass clazz, public InheritanceState(XClass clazz, Map<XClass, InheritanceState> inheritanceStatePerClass, Mappings mappings) {
Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings) {
this.setClazz( clazz ); this.setClazz( clazz );
this.mappings = mappings; this.mappings = mappings;
this.inheritanceStatePerClass = inheritanceStatePerClass; this.inheritanceStatePerClass = inheritanceStatePerClass;

View File

@ -36,9 +36,13 @@ import org.hibernate.mapping.SimpleValue;
@SuppressWarnings({"serial", "unchecked"}) @SuppressWarnings({"serial", "unchecked"})
public class JoinedSubclassFkSecondPass extends FkSecondPass { public class JoinedSubclassFkSecondPass extends FkSecondPass {
private JoinedSubclass entity; private JoinedSubclass entity;
private ExtendedMappings mappings; private Mappings mappings;
public JoinedSubclassFkSecondPass(JoinedSubclass entity, Ejb3JoinColumn[] inheritanceJoinedColumns, SimpleValue key, ExtendedMappings mappings) { public JoinedSubclassFkSecondPass(
JoinedSubclass entity,
Ejb3JoinColumn[] inheritanceJoinedColumns,
SimpleValue key,
Mappings mappings) {
super( key, inheritanceJoinedColumns ); super( key, inheritanceJoinedColumns );
this.entity = entity; this.entity = entity;
this.mappings = mappings; this.mappings = mappings;

View File

@ -48,7 +48,7 @@ import org.hibernate.util.StringHelper;
*/ */
public class OneToOneSecondPass implements SecondPass { public class OneToOneSecondPass implements SecondPass {
private String mappedBy; private String mappedBy;
private ExtendedMappings mappings; private Mappings mappings;
private String ownerEntity; private String ownerEntity;
private String ownerProperty; private String ownerProperty;
private PropertyHolder propertyHolder; private PropertyHolder propertyHolder;
@ -62,11 +62,18 @@ public class OneToOneSecondPass implements SecondPass {
//that suck, we should read that from the property mainly //that suck, we should read that from the property mainly
public OneToOneSecondPass( public OneToOneSecondPass(
String mappedBy, String ownerEntity, String ownerProperty, String mappedBy,
PropertyHolder propertyHolder, PropertyData inferredData, XClass targetEntity, boolean ignoreNotFound, String ownerEntity,
boolean cascadeOnDelete, boolean optional, String cascadeStrategy, Ejb3JoinColumn[] columns, String ownerProperty,
ExtendedMappings mappings PropertyHolder propertyHolder,
) { PropertyData inferredData,
XClass targetEntity,
boolean ignoreNotFound,
boolean cascadeOnDelete,
boolean optional,
String cascadeStrategy,
Ejb3JoinColumn[] columns,
Mappings mappings) {
this.ownerEntity = ownerEntity; this.ownerEntity = ownerEntity;
this.ownerProperty = ownerProperty; this.ownerProperty = ownerProperty;
this.mappedBy = mappedBy; this.mappedBy = mappedBy;

View File

@ -46,11 +46,11 @@ public final class PropertyHolderBuilder {
XClass clazzToProcess, XClass clazzToProcess,
PersistentClass persistentClass, PersistentClass persistentClass,
EntityBinder entityBinder, EntityBinder entityBinder,
//Map<String, Join> joins, Mappings mappings,
ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass) {
Map<XClass, InheritanceState> inheritanceStatePerClass return new ClassPropertyHolder(
) { persistentClass, clazzToProcess, entityBinder, mappings, inheritanceStatePerClass
return new ClassPropertyHolder( persistentClass, clazzToProcess, entityBinder, mappings, inheritanceStatePerClass ); );
} }
/** /**
@ -62,9 +62,11 @@ public final class PropertyHolderBuilder {
* @return PropertyHolder * @return PropertyHolder
*/ */
public static PropertyHolder buildPropertyHolder( public static PropertyHolder buildPropertyHolder(
Component component, String path, PropertyData inferredData, PropertyHolder parent, Component component,
ExtendedMappings mappings String path,
) { PropertyData inferredData,
PropertyHolder parent,
Mappings mappings) {
return new ComponentPropertyHolder( component, path, inferredData, parent, mappings ); return new ComponentPropertyHolder( component, path, inferredData, parent, mappings );
} }
@ -72,20 +74,25 @@ public final class PropertyHolderBuilder {
* buid a property holder on top of a collection * buid a property holder on top of a collection
*/ */
public static PropertyHolder buildPropertyHolder( public static PropertyHolder buildPropertyHolder(
Collection collection, String path, XClass clazzToProcess, XProperty property, Collection collection,
PropertyHolder parentPropertyHolder, ExtendedMappings mappings String path,
) { XClass clazzToProcess,
return new CollectionPropertyHolder( collection, path, clazzToProcess, property, parentPropertyHolder, mappings ); XProperty property,
PropertyHolder parentPropertyHolder,
Mappings mappings) {
return new CollectionPropertyHolder(
collection, path, clazzToProcess, property, parentPropertyHolder, mappings
);
} }
/** /**
* must only be used on second level phases (<join> has to be settled already) * must only be used on second level phases (<join> has to be settled already)
*/ */
public static PropertyHolder buildPropertyHolder( public static PropertyHolder buildPropertyHolder(
PersistentClass persistentClass, Map<String, Join> joins, PersistentClass persistentClass,
ExtendedMappings mappings, Map<String, Join> joins,
Map<XClass, InheritanceState> inheritanceStatePerClass Mappings mappings,
) { Map<XClass, InheritanceState> inheritanceStatePerClass) {
return new ClassPropertyHolder( persistentClass, null, joins, mappings, inheritanceStatePerClass ); return new ClassPropertyHolder( persistentClass, null, joins, mappings, inheritanceStatePerClass );
} }
} }

View File

@ -38,7 +38,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
* @author Emmanuel Bernard * @author Emmanuel Bernard
*/ */
public class ToOneBinder { public class ToOneBinder {
public static String getReferenceEntityName(PropertyData propertyData, XClass targetEntity, ExtendedMappings mappings) { public static String getReferenceEntityName(PropertyData propertyData, XClass targetEntity, Mappings mappings) {
if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) { if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) {
return propertyData.getClassOrElementName(); return propertyData.getClassOrElementName();
} }
@ -47,7 +47,7 @@ public class ToOneBinder {
} }
} }
public static String getReferenceEntityName(PropertyData propertyData, ExtendedMappings mappings) { public static String getReferenceEntityName(PropertyData propertyData, Mappings mappings) {
XClass targetEntity = getTargetEntity( propertyData, mappings ); XClass targetEntity = getTargetEntity( propertyData, mappings );
if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) { if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) {
return propertyData.getClassOrElementName(); return propertyData.getClassOrElementName();
@ -57,7 +57,7 @@ public class ToOneBinder {
} }
} }
public static XClass getTargetEntity(PropertyData propertyData, ExtendedMappings mappings) { public static XClass getTargetEntity(PropertyData propertyData, Mappings mappings) {
XProperty property = propertyData.getProperty(); XProperty property = propertyData.getProperty();
return mappings.getReflectionManager().toXClass( getTargetEntityClass( property ) ); return mappings.getReflectionManager().toXClass( getTargetEntityClass( property ) );
} }

View File

@ -47,13 +47,17 @@ import org.hibernate.util.StringHelper;
*/ */
public class ToOneFkSecondPass extends FkSecondPass { public class ToOneFkSecondPass extends FkSecondPass {
private boolean unique; private boolean unique;
private ExtendedMappings mappings; private Mappings mappings;
private String path; private String path;
private String entityClassName; private String entityClassName;
public ToOneFkSecondPass( public ToOneFkSecondPass(
ToOne value, Ejb3JoinColumn[] columns, boolean unique, String entityClassName, String path, ExtendedMappings mappings ToOne value,
) { Ejb3JoinColumn[] columns,
boolean unique,
String entityClassName,
String path,
Mappings mappings) {
super( value, columns ); super( value, columns );
this.mappings = mappings; this.mappings = mappings;
this.unique = unique; this.unique = unique;

View File

@ -34,12 +34,14 @@ import org.hibernate.mapping.PersistentClass;
* @author Hardy Ferentschik * @author Hardy Ferentschik
*/ */
public class VerifyFetchProfileReferenceSecondPass implements SecondPass { public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
private String fetchProfileName; private String fetchProfileName;
private FetchProfile.FetchOverride fetch; private FetchProfile.FetchOverride fetch;
private ExtendedMappings mappings; private Mappings mappings;
public VerifyFetchProfileReferenceSecondPass(String fetchProfileName, FetchProfile.FetchOverride fetch, ExtendedMappings mappings) { public VerifyFetchProfileReferenceSecondPass(
String fetchProfileName,
FetchProfile.FetchOverride fetch,
Mappings mappings) {
this.fetchProfileName = fetchProfileName; this.fetchProfileName = fetchProfileName;
this.fetch = fetch; this.fetch = fetch;
this.mappings = mappings; this.mappings = mappings;

View File

@ -85,9 +85,9 @@ import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.CollectionSecondPass; import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.IndexColumn; import org.hibernate.cfg.IndexColumn;
import org.hibernate.cfg.InheritanceState; import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyData; import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder; import org.hibernate.cfg.PropertyHolderBuilder;
@ -121,7 +121,6 @@ import org.hibernate.util.StringHelper;
*/ */
@SuppressWarnings({"unchecked", "serial"}) @SuppressWarnings({"unchecked", "serial"})
public abstract class CollectionBinder { public abstract class CollectionBinder {
private Logger log = LoggerFactory.getLogger( CollectionBinder.class ); private Logger log = LoggerFactory.getLogger( CollectionBinder.class );
protected Collection collection; protected Collection collection;
@ -131,7 +130,7 @@ public abstract class CollectionBinder {
private String mappedBy; private String mappedBy;
private XClass collectionType; private XClass collectionType;
private XClass targetEntity; private XClass targetEntity;
private ExtendedMappings mappings; private Mappings mappings;
private Ejb3JoinColumn[] inverseJoinColumns; private Ejb3JoinColumn[] inverseJoinColumns;
private String cascadeStrategy; private String cascadeStrategy;
String cacheConcurrencyStrategy; String cacheConcurrencyStrategy;
@ -163,7 +162,7 @@ public abstract class CollectionBinder {
private AccessType accessType; private AccessType accessType;
private boolean hibernateExtensionMapping; private boolean hibernateExtensionMapping;
protected ExtendedMappings getMappings() { protected Mappings getMappings() {
return mappings; return mappings;
} }
@ -244,9 +243,10 @@ public abstract class CollectionBinder {
* collection binder factory * collection binder factory
*/ */
public static CollectionBinder getCollectionBinder( public static CollectionBinder getCollectionBinder(
String entityName, XProperty property, String entityName,
boolean isIndexed, boolean isHibernateExtensionMapping XProperty property,
) { boolean isIndexed,
boolean isHibernateExtensionMapping) {
CollectionBinder result; CollectionBinder result;
if ( property.isArray() ) { if ( property.isArray() ) {
if ( property.getElementClass().isPrimitive() ) { if ( property.getElementClass().isPrimitive() ) {
@ -351,7 +351,7 @@ public abstract class CollectionBinder {
this.targetEntity = targetEntity; this.targetEntity = targetEntity;
} }
public void setMappings(ExtendedMappings mappings) { public void setMappings(Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
} }
@ -610,23 +610,25 @@ public abstract class CollectionBinder {
} }
public SecondPass getSecondPass( public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, final Ejb3JoinColumn[] fkJoinColumns,
final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] inverseColumns, final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns, final Ejb3Column[] elementColumns,
final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded, final Ejb3Column[] mapKeyColumns,
final XProperty property, final XClass collType, final Ejb3JoinColumn[] mapKeyManyToManyColumns,
final boolean ignoreNotFound, final boolean unique, final boolean isEmbedded,
final TableBinder assocTableBinder, final ExtendedMappings mappings final XProperty property,
) { final XClass collType,
final boolean ignoreNotFound,
final boolean unique,
final TableBinder assocTableBinder,
final Mappings mappings) {
return new CollectionSecondPass( mappings, collection ) { return new CollectionSecondPass( mappings, collection ) {
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas) throws MappingException {
public void secondPass(java.util.Map persistentClasses, java.util.Map inheritedMetas)
throws MappingException {
bindStarToManySecondPass( bindStarToManySecondPass(
persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns, persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns,
isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mappings isEmbedded, property, unique, assocTableBinder, ignoreNotFound, mappings
); );
} }
}; };
} }
@ -635,13 +637,18 @@ public abstract class CollectionBinder {
* return true if it's a Fk, false if it's an association table * return true if it's a Fk, false if it's an association table
*/ */
protected boolean bindStarToManySecondPass( protected boolean bindStarToManySecondPass(
Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns, Map persistentClasses,
Ejb3JoinColumn[] keyColumns, Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns, XClass collType,
Ejb3JoinColumn[] fkJoinColumns,
Ejb3JoinColumn[] keyColumns,
Ejb3JoinColumn[] inverseColumns,
Ejb3Column[] elementColumns,
boolean isEmbedded, boolean isEmbedded,
XProperty property, boolean unique, XProperty property,
boolean unique,
TableBinder associationTableBinder, TableBinder associationTableBinder,
boolean ignoreNotFound, ExtendedMappings mappings boolean ignoreNotFound,
) { Mappings mappings) {
PersistentClass persistentClass = (PersistentClass) persistentClasses.get( collType.getName() ); PersistentClass persistentClass = (PersistentClass) persistentClasses.get( collType.getName() );
boolean reversePropertyInJoin = false; boolean reversePropertyInJoin = false;
if ( persistentClass != null && StringHelper.isNotEmpty( this.mappedBy ) ) { if ( persistentClass != null && StringHelper.isNotEmpty( this.mappedBy ) ) {
@ -699,14 +706,17 @@ public abstract class CollectionBinder {
} }
protected void bindOneToManySecondPass( protected void bindOneToManySecondPass(
Collection collection, Map persistentClasses, Ejb3JoinColumn[] fkJoinColumns, Collection collection,
Map persistentClasses,
Ejb3JoinColumn[] fkJoinColumns,
XClass collectionType, XClass collectionType,
boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy, ExtendedMappings extendedMappings, boolean cascadeDeleteEnabled,
Map<XClass, InheritanceState> inheritanceStatePerClass boolean ignoreNotFound,
) { String hqlOrderBy,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
log.debug("Binding a OneToMany: {}.{} through a foreign key", propertyHolder.getEntityName(), propertyName); log.debug("Binding a OneToMany: {}.{} through a foreign key", propertyHolder.getEntityName(), propertyName);
org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( extendedMappings, collection.getOwner() ); org.hibernate.mapping.OneToMany oneToMany = new org.hibernate.mapping.OneToMany( mappings, collection.getOwner() );
collection.setElement( oneToMany ); collection.setElement( oneToMany );
oneToMany.setReferencedEntityName( collectionType.getName() ); oneToMany.setReferencedEntityName( collectionType.getName() );
oneToMany.setIgnoreNotFound( ignoreNotFound ); oneToMany.setIgnoreNotFound( ignoreNotFound );
@ -1076,7 +1086,7 @@ public abstract class CollectionBinder {
private static SimpleValue buildCollectionKey( private static SimpleValue buildCollectionKey(
Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled, Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled,
XProperty property, ExtendedMappings mappings XProperty property, Mappings mappings
) { ) {
//binding key reference using column //binding key reference using column
KeyValue keyVal; KeyValue keyVal;
@ -1127,9 +1137,11 @@ public abstract class CollectionBinder {
XClass collType, XClass collType,
boolean ignoreNotFound, boolean unique, boolean ignoreNotFound, boolean unique,
boolean cascadeDeleteEnabled, boolean cascadeDeleteEnabled,
TableBinder associationTableBinder, XProperty property, PropertyHolder parentPropertyHolder, TableBinder associationTableBinder,
String hqlOrderBy, ExtendedMappings mappings XProperty property,
) throws MappingException { PropertyHolder parentPropertyHolder,
String hqlOrderBy,
Mappings mappings) throws MappingException {
PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() ); PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() );
boolean isCollectionOfEntities = collectionEntity != null; boolean isCollectionOfEntities = collectionEntity != null;
@ -1415,10 +1427,12 @@ public abstract class CollectionBinder {
} }
private static void bindCollectionSecondPass( private static void bindCollectionSecondPass(
Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns, Collection collValue,
boolean cascadeDeleteEnabled, XProperty property, PersistentClass collectionEntity,
ExtendedMappings mappings Ejb3JoinColumn[] joinColumns,
) { boolean cascadeDeleteEnabled,
XProperty property,
Mappings mappings) {
BinderHelper.createSyntheticPropertyReference( BinderHelper.createSyntheticPropertyReference(
joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings
); );
@ -1450,9 +1464,11 @@ public abstract class CollectionBinder {
* Otherwise delegates to the usual algorithm * Otherwise delegates to the usual algorithm
*/ */
public static void bindManytoManyInverseFk( public static void bindManytoManyInverseFk(
PersistentClass referencedEntity, Ejb3JoinColumn[] columns, SimpleValue value, boolean unique, PersistentClass referencedEntity,
ExtendedMappings mappings Ejb3JoinColumn[] columns,
) { SimpleValue value,
boolean unique,
Mappings mappings) {
final String mappedBy = columns[0].getMappedBy(); final String mappedBy = columns[0].getMappedBy();
if ( StringHelper.isNotEmpty( mappedBy ) ) { if ( StringHelper.isNotEmpty( mappedBy ) ) {
final Property property = referencedEntity.getRecursiveProperty( mappedBy ); final Property property = referencedEntity.getRecursiveProperty( mappedBy );

View File

@ -66,8 +66,8 @@ import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.AnnotationBinder; import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.InheritanceState; import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.ObjectNameSource; import org.hibernate.cfg.ObjectNameSource;
import org.hibernate.cfg.NamingStrategy; import org.hibernate.cfg.NamingStrategy;
@ -99,7 +99,7 @@ public class EntityBinder {
private String name; private String name;
private XClass annotatedClass; private XClass annotatedClass;
private PersistentClass persistentClass; private PersistentClass persistentClass;
private ExtendedMappings mappings; private Mappings mappings;
private Logger log = LoggerFactory.getLogger( EntityBinder.class ); private Logger log = LoggerFactory.getLogger( EntityBinder.class );
private String discriminatorValue = ""; private String discriminatorValue = "";
private boolean dynamicInsert; private boolean dynamicInsert;
@ -136,10 +136,11 @@ public class EntityBinder {
} }
public EntityBinder( public EntityBinder(
Entity ejb3Ann, org.hibernate.annotations.Entity hibAnn, Entity ejb3Ann,
XClass annotatedClass, PersistentClass persistentClass, org.hibernate.annotations.Entity hibAnn,
ExtendedMappings mappings XClass annotatedClass,
) { PersistentClass persistentClass,
Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
this.persistentClass = persistentClass; this.persistentClass = persistentClass;
this.annotatedClass = annotatedClass; this.annotatedClass = annotatedClass;
@ -479,9 +480,12 @@ public class EntityBinder {
} }
public void bindTable( public void bindTable(
String schema, String catalog, String schema,
String tableName, List<UniqueConstraintHolder> uniqueConstraints, String catalog,
String constraints, Table denormalizedSuperclassTable) { String tableName,
List<UniqueConstraintHolder> uniqueConstraints,
String constraints,
Table denormalizedSuperclassTable) {
EntityTableObjectNameSource tableNameContext = new EntityTableObjectNameSource( tableName, name ); EntityTableObjectNameSource tableNameContext = new EntityTableObjectNameSource( tableName, name );
EntityTableNamingStrategyHelper namingStrategyHelper = new EntityTableNamingStrategyHelper( name ); EntityTableNamingStrategyHelper namingStrategyHelper = new EntityTableNamingStrategyHelper( name );
final Table table = TableBinder.buildAndFillTable( final Table table = TableBinder.buildAndFillTable(
@ -589,7 +593,7 @@ public class EntityBinder {
bindJoinToPersistentClass( join, ejb3JoinColumns, mappings ); bindJoinToPersistentClass( join, ejb3JoinColumns, mappings );
} }
private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, ExtendedMappings mappings) { private void bindJoinToPersistentClass(Join join, Ejb3JoinColumn[] ejb3JoinColumns, Mappings mappings) {
SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() ); SimpleValue key = new DependantValue( mappings, join.getTable(), persistentClass.getIdentifier() );
join.setKey( key ); join.setKey( key );
setFKNameIfDefined( join ); setFKNameIfDefined( join );

View File

@ -34,7 +34,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyData; import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyInferredData; import org.hibernate.cfg.PropertyInferredData;
import org.hibernate.cfg.WrappedInferredData; import org.hibernate.cfg.WrappedInferredData;
@ -55,10 +55,18 @@ public class IdBagBinder extends BagBinder {
@Override @Override
protected boolean bindStarToManySecondPass( protected boolean bindStarToManySecondPass(
Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns, Ejb3JoinColumn[] keyColumns, Map persistentClasses,
Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns, boolean isEmbedded, XProperty property, XClass collType,
boolean unique, TableBinder associationTableBinder, boolean ignoreNotFound, ExtendedMappings mappings Ejb3JoinColumn[] fkJoinColumns,
) { Ejb3JoinColumn[] keyColumns,
Ejb3JoinColumn[] inverseColumns,
Ejb3Column[] elementColumns,
boolean isEmbedded,
XProperty property,
boolean unique,
TableBinder associationTableBinder,
boolean ignoreNotFound,
Mappings mappings) {
boolean result = super.bindStarToManySecondPass( boolean result = super.bindStarToManySecondPass(
persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns, isEmbedded, persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns, isEmbedded,
property, unique, associationTableBinder, ignoreNotFound, mappings property, unique, associationTableBinder, ignoreNotFound, mappings
@ -68,9 +76,14 @@ public class IdBagBinder extends BagBinder {
SimpleValueBinder simpleValue = new SimpleValueBinder(); SimpleValueBinder simpleValue = new SimpleValueBinder();
PropertyData propertyData = new WrappedInferredData( PropertyData propertyData = new WrappedInferredData(
new PropertyInferredData( null, property, null, //default access should not be useful new PropertyInferredData(
mappings.getReflectionManager() ), null,
"id" ); property,
null, //default access should not be useful
mappings.getReflectionManager()
),
"id"
);
Ejb3Column[] idColumns = Ejb3Column.buildColumnFromAnnotation( Ejb3Column[] idColumns = Ejb3Column.buildColumnFromAnnotation(
collectionIdAnn.columns(), collectionIdAnn.columns(),
null, null,

View File

@ -37,7 +37,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.CollectionSecondPass; import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder; import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.SecondPass; import org.hibernate.cfg.SecondPass;
@ -76,14 +76,19 @@ public class ListBinder extends CollectionBinder {
@Override @Override
public SecondPass getSecondPass( public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, final Ejb3JoinColumn[] fkJoinColumns,
final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] inverseColumns, final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns, final Ejb3Column[] elementColumns,
Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded, Ejb3Column[] mapKeyColumns,
final XProperty property, final XClass collType, final Ejb3JoinColumn[] mapKeyManyToManyColumns,
final boolean ignoreNotFound, final boolean unique, final boolean isEmbedded,
final TableBinder assocTableBinder, final ExtendedMappings mappings final XProperty property,
) { final XClass collType,
final boolean ignoreNotFound,
final boolean unique,
final TableBinder assocTableBinder,
final Mappings mappings) {
return new CollectionSecondPass( mappings, ListBinder.this.collection ) { return new CollectionSecondPass( mappings, ListBinder.this.collection ) {
public void secondPass(Map persistentClasses, Map inheritedMetas) public void secondPass(Map persistentClasses, Map inheritedMetas)
throws MappingException { throws MappingException {
@ -96,7 +101,7 @@ public class ListBinder extends CollectionBinder {
}; };
} }
private void bindIndex(final ExtendedMappings mappings) { private void bindIndex(final Mappings mappings) {
if ( !indexColumn.isImplicit() ) { if ( !indexColumn.isImplicit() ) {
PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder( PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
this.collection, this.collection,

View File

@ -46,7 +46,7 @@ import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.CollectionSecondPass; import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyData; import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder; import org.hibernate.cfg.PropertyHolderBuilder;
@ -93,14 +93,19 @@ public class MapBinder extends CollectionBinder {
@Override @Override
public SecondPass getSecondPass( public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns, final Ejb3JoinColumn[] fkJoinColumns,
final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] inverseColumns, final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns, final Ejb3Column[] elementColumns,
final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded, final Ejb3Column[] mapKeyColumns,
final XProperty property, final XClass collType, final Ejb3JoinColumn[] mapKeyManyToManyColumns,
final boolean ignoreNotFound, final boolean unique, final boolean isEmbedded,
final TableBinder assocTableBinder, final ExtendedMappings mappings final XProperty property,
) { final XClass collType,
final boolean ignoreNotFound,
final boolean unique,
final TableBinder assocTableBinder,
final Mappings mappings) {
return new CollectionSecondPass( mappings, MapBinder.this.collection ) { return new CollectionSecondPass( mappings, MapBinder.this.collection ) {
public void secondPass(Map persistentClasses, Map inheritedMetas) public void secondPass(Map persistentClasses, Map inheritedMetas)
throws MappingException { throws MappingException {
@ -118,10 +123,15 @@ public class MapBinder extends CollectionBinder {
} }
private void bindKeyFromAssociationTable( private void bindKeyFromAssociationTable(
XClass collType, Map persistentClasses, String mapKeyPropertyName, XProperty property, XClass collType,
boolean isEmbedded, ExtendedMappings mappings, Ejb3Column[] mapKeyColumns, Map persistentClasses,
Ejb3JoinColumn[] mapKeyManyToManyColumns, String targetPropertyName String mapKeyPropertyName,
) { XProperty property,
boolean isEmbedded,
Mappings mappings,
Ejb3Column[] mapKeyColumns,
Ejb3JoinColumn[] mapKeyManyToManyColumns,
String targetPropertyName) {
if ( mapKeyPropertyName != null ) { if ( mapKeyPropertyName != null ) {
//this is an EJB3 @MapKey //this is an EJB3 @MapKey
PersistentClass associatedClass = (PersistentClass) persistentClasses.get( collType.getName() ); PersistentClass associatedClass = (PersistentClass) persistentClasses.get( collType.getName() );
@ -133,7 +143,9 @@ public class MapBinder extends CollectionBinder {
); );
} }
org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection; org.hibernate.mapping.Map map = (org.hibernate.mapping.Map) this.collection;
Value indexValue = createFormulatedValue( mapProperty.getValue(), map, targetPropertyName, associatedClass, mappings ); Value indexValue = createFormulatedValue(
mapProperty.getValue(), map, targetPropertyName, associatedClass, mappings
);
map.setIndex( indexValue ); map.setIndex( indexValue );
} }
else { else {
@ -305,7 +317,7 @@ public class MapBinder extends CollectionBinder {
Collection collection, Collection collection,
String targetPropertyName, String targetPropertyName,
PersistentClass associatedClass, PersistentClass associatedClass,
ExtendedMappings mappings) { Mappings mappings) {
Value element = collection.getElement(); Value element = collection.getElement();
String fromAndWhere = null; String fromAndWhere = null;
if ( !( element instanceof OneToMany ) ) { if ( !( element instanceof OneToMany ) ) {

View File

@ -43,8 +43,8 @@ import org.hibernate.cfg.AccessType;
import org.hibernate.cfg.AnnotationBinder; import org.hibernate.cfg.AnnotationBinder;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.InheritanceState; import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder; import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyPreloadedData; import org.hibernate.cfg.PropertyPreloadedData;
import org.hibernate.mapping.Component; import org.hibernate.mapping.Component;
@ -67,7 +67,7 @@ public class PropertyBinder {
private AccessType accessType; private AccessType accessType;
private Ejb3Column[] columns; private Ejb3Column[] columns;
private PropertyHolder holder; private PropertyHolder holder;
private ExtendedMappings mappings; private Mappings mappings;
private Value value; private Value value;
private boolean insertable = true; private boolean insertable = true;
private boolean updatable = true; private boolean updatable = true;
@ -145,7 +145,7 @@ public class PropertyBinder {
this.cascade = cascadeStrategy; this.cascade = cascadeStrategy;
} }
public void setMappings(ExtendedMappings mappings) { public void setMappings(Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
} }

View File

@ -40,7 +40,7 @@ import org.hibernate.LockMode;
import org.hibernate.annotations.CacheModeType; import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType; import org.hibernate.annotations.FlushModeType;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException; import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.NamedQueryDefinition; import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition; import org.hibernate.engine.NamedSQLQueryDefinition;
@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
public abstract class QueryBinder { public abstract class QueryBinder {
private static final Logger log = LoggerFactory.getLogger( QueryBinder.class ); private static final Logger log = LoggerFactory.getLogger( QueryBinder.class );
public static void bindQuery(NamedQuery queryAnn, ExtendedMappings mappings, boolean isDefault) { public static void bindQuery(NamedQuery queryAnn, Mappings mappings, boolean isDefault) {
if ( queryAnn == null ) return; if ( queryAnn == null ) return;
if ( BinderHelper.isDefault( queryAnn.name() ) ) { if ( BinderHelper.isDefault( queryAnn.name() ) ) {
throw new AnnotationException( "A named query must have a name when used in class or package level" ); throw new AnnotationException( "A named query must have a name when used in class or package level" );
@ -87,7 +87,7 @@ public abstract class QueryBinder {
} }
public static void bindNativeQuery(NamedNativeQuery queryAnn, ExtendedMappings mappings, boolean isDefault) { public static void bindNativeQuery(NamedNativeQuery queryAnn, Mappings mappings, boolean isDefault) {
if ( queryAnn == null ) return; if ( queryAnn == null ) return;
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() ); //ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
if ( BinderHelper.isDefault( queryAnn.name() ) ) { if ( BinderHelper.isDefault( queryAnn.name() ) ) {
@ -148,7 +148,7 @@ public abstract class QueryBinder {
log.info( "Binding named native query: {} => {}", queryAnn.name(), queryAnn.query() ); log.info( "Binding named native query: {} => {}", queryAnn.name(), queryAnn.query() );
} }
public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn, ExtendedMappings mappings) { public static void bindNativeQuery(org.hibernate.annotations.NamedNativeQuery queryAnn, Mappings mappings) {
if ( queryAnn == null ) return; if ( queryAnn == null ) return;
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() ); //ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
if ( BinderHelper.isDefault( queryAnn.name() ) ) { if ( BinderHelper.isDefault( queryAnn.name() ) ) {
@ -202,14 +202,14 @@ public abstract class QueryBinder {
log.info( "Binding named native query: {} => {}", queryAnn.name(), queryAnn.query() ); log.info( "Binding named native query: {} => {}", queryAnn.name(), queryAnn.query() );
} }
public static void bindQueries(NamedQueries queriesAnn, ExtendedMappings mappings, boolean isDefault) { public static void bindQueries(NamedQueries queriesAnn, Mappings mappings, boolean isDefault) {
if ( queriesAnn == null ) return; if ( queriesAnn == null ) return;
for (NamedQuery q : queriesAnn.value()) { for (NamedQuery q : queriesAnn.value()) {
bindQuery( q, mappings, isDefault ); bindQuery( q, mappings, isDefault );
} }
} }
public static void bindNativeQueries(NamedNativeQueries queriesAnn, ExtendedMappings mappings, boolean isDefault) { public static void bindNativeQueries(NamedNativeQueries queriesAnn, Mappings mappings, boolean isDefault) {
if ( queriesAnn == null ) return; if ( queriesAnn == null ) return;
for (NamedNativeQuery q : queriesAnn.value()) { for (NamedNativeQuery q : queriesAnn.value()) {
bindNativeQuery( q, mappings, isDefault ); bindNativeQuery( q, mappings, isDefault );
@ -217,7 +217,7 @@ public abstract class QueryBinder {
} }
public static void bindNativeQueries( public static void bindNativeQueries(
org.hibernate.annotations.NamedNativeQueries queriesAnn, ExtendedMappings mappings org.hibernate.annotations.NamedNativeQueries queriesAnn, Mappings mappings
) { ) {
if ( queriesAnn == null ) return; if ( queriesAnn == null ) return;
for (org.hibernate.annotations.NamedNativeQuery q : queriesAnn.value()) { for (org.hibernate.annotations.NamedNativeQuery q : queriesAnn.value()) {
@ -225,7 +225,7 @@ public abstract class QueryBinder {
} }
} }
public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, ExtendedMappings mappings) { public static void bindQuery(org.hibernate.annotations.NamedQuery queryAnn, Mappings mappings) {
if ( queryAnn == null ) return; if ( queryAnn == null ) return;
if ( BinderHelper.isDefault( queryAnn.name() ) ) { if ( BinderHelper.isDefault( queryAnn.name() ) ) {
throw new AnnotationException( "A named query must have a name when used in class or package level" ); throw new AnnotationException( "A named query must have a name when used in class or package level" );
@ -296,14 +296,14 @@ public abstract class QueryBinder {
} }
public static void bindQueries(org.hibernate.annotations.NamedQueries queriesAnn, ExtendedMappings mappings) { public static void bindQueries(org.hibernate.annotations.NamedQueries queriesAnn, Mappings mappings) {
if ( queriesAnn == null ) return; if ( queriesAnn == null ) return;
for (org.hibernate.annotations.NamedQuery q : queriesAnn.value()) { for (org.hibernate.annotations.NamedQuery q : queriesAnn.value()) {
bindQuery( q, mappings ); bindQuery( q, mappings );
} }
} }
public static void bindSqlResultsetMappings(SqlResultSetMappings ann, ExtendedMappings mappings, boolean isDefault) { public static void bindSqlResultsetMappings(SqlResultSetMappings ann, Mappings mappings, boolean isDefault) {
if ( ann == null ) return; if ( ann == null ) return;
for (SqlResultSetMapping rs : ann.value()) { for (SqlResultSetMapping rs : ann.value()) {
//no need to handle inSecondPass //no need to handle inSecondPass
@ -311,7 +311,7 @@ public abstract class QueryBinder {
} }
} }
public static void bindSqlResultsetMapping(SqlResultSetMapping ann, ExtendedMappings mappings, boolean isDefault) { public static void bindSqlResultsetMapping(SqlResultSetMapping ann, Mappings mappings, boolean isDefault) {
//no need to handle inSecondPass //no need to handle inSecondPass
mappings.addSecondPass( new ResultsetMappingSecondPass( ann, mappings, isDefault ) ); mappings.addSecondPass( new ResultsetMappingSecondPass( ann, mappings, isDefault ) );
} }

View File

@ -38,7 +38,7 @@ import javax.persistence.SqlResultSetMapping;
import org.hibernate.LockMode; import org.hibernate.LockMode;
import org.hibernate.MappingException; import org.hibernate.MappingException;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.QuerySecondPass; import org.hibernate.cfg.QuerySecondPass;
import org.hibernate.engine.ResultSetMappingDefinition; import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn; import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
@ -58,10 +58,10 @@ import org.slf4j.LoggerFactory;
public class ResultsetMappingSecondPass implements QuerySecondPass { public class ResultsetMappingSecondPass implements QuerySecondPass {
private Logger log = LoggerFactory.getLogger( ResultsetMappingSecondPass.class ); private Logger log = LoggerFactory.getLogger( ResultsetMappingSecondPass.class );
private SqlResultSetMapping ann; private SqlResultSetMapping ann;
private ExtendedMappings mappings; private Mappings mappings;
private boolean isDefault; private boolean isDefault;
public ResultsetMappingSecondPass(SqlResultSetMapping ann, ExtendedMappings mappings, boolean isDefault) { public ResultsetMappingSecondPass(SqlResultSetMapping ann, Mappings mappings, boolean isDefault) {
this.ann = ann; this.ann = ann;
this.mappings = mappings; this.mappings = mappings;
this.isDefault = isDefault; this.isDefault = isDefault;

View File

@ -48,7 +48,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3Column; import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings; import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException; import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass; import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
import org.hibernate.cfg.SetSimpleValueTypeSecondPass; import org.hibernate.cfg.SetSimpleValueTypeSecondPass;
@ -72,7 +72,7 @@ public class SimpleValueBinder {
private String persistentClassName; private String persistentClassName;
private String explicitType = ""; private String explicitType = "";
private Properties typeParameters = new Properties(); private Properties typeParameters = new Properties();
private ExtendedMappings mappings; private Mappings mappings;
private Table table; private Table table;
private SimpleValue simpleValue; private SimpleValue simpleValue;
private boolean isVersion; private boolean isVersion;
@ -278,7 +278,7 @@ public class SimpleValueBinder {
} }
} }
public void setMappings(ExtendedMappings mappings) { public void setMappings(Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
} }

View File

@ -31,11 +31,11 @@ import javax.persistence.UniqueConstraint;
import org.hibernate.AnnotationException; import org.hibernate.AnnotationException;
import org.hibernate.AssertionFailure; import org.hibernate.AssertionFailure;
import org.hibernate.annotations.Index; import org.hibernate.annotations.Index;
import org.hibernate.cfg.Mappings;
import org.hibernate.util.StringHelper; import org.hibernate.util.StringHelper;
import org.hibernate.util.CollectionHelper; import org.hibernate.util.CollectionHelper;
import org.hibernate.cfg.BinderHelper; import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn; import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.IndexOrUniqueKeySecondPass; import org.hibernate.cfg.IndexOrUniqueKeySecondPass;
import org.hibernate.cfg.ObjectNameNormalizer; import org.hibernate.cfg.ObjectNameNormalizer;
import org.hibernate.cfg.ObjectNameSource; import org.hibernate.cfg.ObjectNameSource;
@ -71,7 +71,7 @@ public class TableBinder {
// private List<String[]> uniqueConstraints; // private List<String[]> uniqueConstraints;
String constraints; String constraints;
Table denormalizedSuperTable; Table denormalizedSuperTable;
ExtendedMappings mappings; Mappings mappings;
private String ownerEntityTable; private String ownerEntityTable;
private String associatedEntityTable; private String associatedEntityTable;
private String propertyName; private String propertyName;
@ -111,7 +111,7 @@ public class TableBinder {
this.denormalizedSuperTable = denormalizedSuperTable; this.denormalizedSuperTable = denormalizedSuperTable;
} }
public void setMappings(ExtendedMappings mappings) { public void setMappings(Mappings mappings) {
this.mappings = mappings; this.mappings = mappings;
} }
@ -211,7 +211,7 @@ public class TableBinder {
List<UniqueConstraintHolder> uniqueConstraints, List<UniqueConstraintHolder> uniqueConstraints,
String constraints, String constraints,
Table denormalizedSuperTable, Table denormalizedSuperTable,
ExtendedMappings mappings, Mappings mappings,
String subselect) { String subselect) {
schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema; schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema;
catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog; catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
@ -273,9 +273,15 @@ public class TableBinder {
*/ */
@SuppressWarnings({ "JavaDoc" }) @SuppressWarnings({ "JavaDoc" })
public static Table fillTable( public static Table fillTable(
String schema, String catalog, String realTableName, String logicalName, boolean isAbstract, String schema,
List uniqueConstraints, String constraints, Table denormalizedSuperTable, ExtendedMappings mappings String catalog,
) { String realTableName,
String logicalName,
boolean isAbstract,
List uniqueConstraints,
String constraints,
Table denormalizedSuperTable,
Mappings mappings) {
schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema; schema = BinderHelper.isDefault( schema ) ? mappings.getSchemaName() : schema;
catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog; catalog = BinderHelper.isDefault( catalog ) ? mappings.getCatalogName() : catalog;
Table table; Table table;
@ -310,10 +316,12 @@ public class TableBinder {
} }
public static void bindFk( public static void bindFk(
PersistentClass referencedEntity, PersistentClass destinationEntity, Ejb3JoinColumn[] columns, PersistentClass referencedEntity,
PersistentClass destinationEntity,
Ejb3JoinColumn[] columns,
SimpleValue value, SimpleValue value,
boolean unique, ExtendedMappings mappings boolean unique,
) { Mappings mappings) {
PersistentClass associatedClass; PersistentClass associatedClass;
if ( destinationEntity != null ) { if ( destinationEntity != null ) {
//overridden destination //overridden destination
@ -478,8 +486,10 @@ public class TableBinder {
} }
public static void linkJoinColumnWithValueOverridingNameIfImplicit( public static void linkJoinColumnWithValueOverridingNameIfImplicit(
PersistentClass referencedEntity, Iterator columnIterator, Ejb3JoinColumn[] columns, SimpleValue value PersistentClass referencedEntity,
) { Iterator columnIterator,
Ejb3JoinColumn[] columns,
SimpleValue value) {
for (Ejb3JoinColumn joinCol : columns) { for (Ejb3JoinColumn joinCol : columns) {
Column synthCol = (Column) columnIterator.next(); Column synthCol = (Column) columnIterator.next();
if ( joinCol.isNameDeferred() ) { if ( joinCol.isNameDeferred() ) {
@ -502,7 +512,7 @@ public class TableBinder {
value.getTable().createUniqueKey( cols ); value.getTable().createUniqueKey( cols );
} }
public static void addIndexes(Table hibTable, Index[] indexes, ExtendedMappings mappings) { public static void addIndexes(Table hibTable, Index[] indexes, Mappings mappings) {
for (Index index : indexes) { for (Index index : indexes) {
//no need to handle inSecondPass here since it is only called from EntityBinder //no need to handle inSecondPass here since it is only called from EntityBinder
mappings.addSecondPass( mappings.addSecondPass(