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> currentPropertyJoinTableOverride;
private String path;
private ExtendedMappings mappings;
private Mappings mappings;
private Boolean isInIdClass;
public AbstractPropertyHolder(
String path, PropertyHolder parent, XClass clazzToProcess, ExtendedMappings mappings
) {
String path,
PropertyHolder parent,
XClass clazzToProcess,
Mappings mappings) {
this.path = path;
this.parent = (AbstractPropertyHolder) parent;
this.mappings = mappings;
@ -80,7 +82,7 @@ public abstract class AbstractPropertyHolder implements PropertyHolder {
return path;
}
protected ExtendedMappings getMappings() {
protected Mappings getMappings() {
return mappings;
}

View File

@ -21,9 +21,6 @@
* 51 Franklin Street, Fifth Floor
* Boston, MA 02110-1301 USA
*/
// $Id$
package org.hibernate.cfg;
import java.lang.annotation.Annotation;
@ -203,7 +200,7 @@ public final class AnnotationBinder {
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();
{
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;
try {
pckg = mappings.getReflectionManager().packageForName( packageName );
@ -282,7 +279,7 @@ public final class AnnotationBinder {
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 );
GenericGenerators defsAnn = annotatedElement.getAnnotation( GenericGenerators.class );
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 );
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 );
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();
if ( mappings.getSchemaName() != null ) {
idGen.addParam( PersistentIdentifierGenerator.SCHEMA, mappings.getSchemaName() );
@ -470,7 +467,7 @@ public final class AnnotationBinder {
if ( seqGen.initialValue() != 1 ) {
log.warn(
"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 ) );
@ -503,8 +500,9 @@ public final class AnnotationBinder {
* @throws MappingException in case there is an configuration error
*/
public static void bindClass(
XClass clazzToProcess, Map<XClass, InheritanceState> inheritanceStatePerClass, ExtendedMappings mappings
) throws MappingException {
XClass clazzToProcess,
Map<XClass, InheritanceState> inheritanceStatePerClass,
Mappings mappings) throws MappingException {
//@Entity and @MappedSuperclass on the same class leads to a NPE down the road
if ( clazzToProcess.isAnnotationPresent( Entity.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 );
for ( PropertyData propertyAnnotatedElement : elementsToProcess.getElements() ) {
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
* 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,
AccessType propertyAccessor,
Map<XClass, InheritanceState> inheritanceStatePerClass,
ExtendedMappings mappings) {
Mappings mappings) {
if ( elementsToProcess.getIdPropertyCount() == 1 ) {
final PropertyData idPropertyOnBaseClass = getUniqueIdPropertyFromBaseClass(
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 );
if ( cacheAnn != null ) {
return cacheAnn;
@ -979,7 +994,7 @@ public final class AnnotationBinder {
return cacheAnn;
}
private static SharedCacheMode determineSharedCacheMode(ExtendedMappings mappings) {
private static SharedCacheMode determineSharedCacheMode(Mappings mappings) {
SharedCacheMode mode;
final Object value = mappings.getConfigurationProperties().get( "javax.persistence.sharedCache.mode" );
if ( value == null ) {
@ -1006,7 +1021,7 @@ public final class AnnotationBinder {
return mode;
}
private static Cache buildCacheMock(String region, ExtendedMappings mappings) {
private static Cache buildCacheMock(String region, Mappings mappings) {
return new LocalCacheAnnotationImpl( region, determineCacheConcurrencyStrategy( mappings ) );
}
@ -1018,12 +1033,12 @@ public final class AnnotationBinder {
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" );
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 + "]" );
CacheConcurrencyStrategy strategy = CacheConcurrencyStrategy.parse( strategyName );
if ( strategy == null ) {
@ -1035,7 +1050,7 @@ public final class AnnotationBinder {
DEFAULT_CACHE_CONCURRENCY_STRATEGY = strategy;
}
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(ExtendedMappings mappings) {
private static CacheConcurrencyStrategy determineCacheConcurrencyStrategy(Mappings mappings) {
if ( DEFAULT_CACHE_CONCURRENCY_STRATEGY == null ) {
final RegionFactory cacheRegionFactory = SettingsFactory.createRegionFactory(
mappings.getConfigurationProperties(), true
@ -1094,7 +1109,11 @@ public final class AnnotationBinder {
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;
final boolean hasJoinedColumns = inheritanceState.hasParents()
&& InheritanceType.JOINED.equals( inheritanceState.getType() );
@ -1133,7 +1152,7 @@ public final class AnnotationBinder {
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(
clazzToProcess, inheritanceStatePerClass
);
@ -1185,7 +1204,7 @@ public final class AnnotationBinder {
*/
private static void bindFilters(XClass annotatedClass, EntityBinder entityBinder,
ExtendedMappings mappings) {
Mappings mappings) {
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 );
FilterDefs defsAnn = annotatedElement.getAnnotation( FilterDefs.class );
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>();
for ( ParamDef param : defAnn.parameters() ) {
params.put( param.name(), mappings.getTypeResolver().heuristicType( param.type() ) );
@ -1238,7 +1257,7 @@ public final class AnnotationBinder {
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 );
TypeDefs defsAnn = annotatedElement.getAnnotation( TypeDefs.class );
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 );
FetchProfiles fetchProfileAnnotations = annotatedElement.getAnnotation( FetchProfiles.class );
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() ) {
org.hibernate.annotations.FetchMode mode = fetch.mode();
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();
for ( Parameter param : defAnn.parameters() ) {
params.setProperty( param.name(), param.value() );
@ -1306,7 +1325,7 @@ public final class AnnotationBinder {
Ejb3DiscriminatorColumn discriminatorColumn,
Map<String, Join> secondaryTables,
PropertyHolder propertyHolder,
ExtendedMappings mappings) {
Mappings mappings) {
if ( rootClass.getDiscriminator() == null ) {
if ( discriminatorColumn == null ) {
throw new AssertionFailure( "discriminator column should have been built" );
@ -1333,8 +1352,10 @@ public final class AnnotationBinder {
* the determined access strategy, {@code false} otherwise.
*/
static int addElementsOfClass(
List<PropertyData> elements, AccessType defaultAccessType, PropertyContainer propertyContainer, ExtendedMappings mappings
) {
List<PropertyData> elements,
AccessType defaultAccessType,
PropertyContainer propertyContainer,
Mappings mappings) {
int idPropertyCounter = 0;
AccessType accessType = defaultAccessType;
@ -1353,9 +1374,11 @@ public final class AnnotationBinder {
}
private static int addProperty(
PropertyContainer propertyContainer, XProperty property, List<PropertyData> annElts,
String propertyAccessor, ExtendedMappings mappings
) {
PropertyContainer propertyContainer,
XProperty property,
List<PropertyData> annElts,
String propertyAccessor,
Mappings mappings) {
final XClass declaringClass = propertyContainer.getDeclaringClass();
final XClass entity = propertyContainer.getEntityAtStake();
int idPropertyCounter = 0;
@ -1391,12 +1414,16 @@ public final class AnnotationBinder {
*/
private static void processElementAnnotations(
PropertyHolder propertyHolder, Nullability nullability,
PropertyData inferredData, HashMap<String, IdGenerator> classGenerators,
EntityBinder entityBinder, boolean isIdentifierMapper,
boolean isComponentEmbedded, boolean inSecondPass, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) throws MappingException {
PropertyHolder propertyHolder,
Nullability nullability,
PropertyData inferredData,
HashMap<String, IdGenerator> classGenerators,
EntityBinder entityBinder,
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
* Because it's a value type, there is no bidirectional association, hence second pass
@ -2065,7 +2092,7 @@ public final class AnnotationBinder {
SimpleValue idValue,
HashMap<String, IdGenerator> classGenerators,
boolean isIdentifierMapper,
ExtendedMappings mappings) {
Mappings mappings) {
if ( isIdentifierMapper ) {
throw new AnnotationException(
"@IdClass class should not have @Id nor @EmbeddedId properties: "
@ -2103,10 +2130,13 @@ public final class AnnotationBinder {
//TODO move that to collection binder?
private static void bindJoinedTableAssociation(
XProperty property, ExtendedMappings mappings, EntityBinder entityBinder,
CollectionBinder collectionBinder, PropertyHolder propertyHolder, PropertyData inferredData,
String mappedBy
) {
XProperty property,
Mappings mappings,
EntityBinder entityBinder,
CollectionBinder collectionBinder,
PropertyHolder propertyHolder,
PropertyData inferredData,
String mappedBy) {
TableBinder associationTableBinder = new TableBinder();
JoinColumn[] annJoins;
JoinColumn[] annInverseJoins;
@ -2181,7 +2211,7 @@ public final class AnnotationBinder {
AccessType propertyAccessor,
EntityBinder entityBinder,
boolean isIdentifierMapper,
ExtendedMappings mappings,
Mappings mappings,
boolean isComponentEmbedded,
boolean isId, //is a identifier
Map<XClass, InheritanceState> inheritanceStatePerClass,
@ -2240,13 +2270,16 @@ public final class AnnotationBinder {
}
public static Component fillComponent(
PropertyHolder propertyHolder, PropertyData inferredData,
AccessType propertyAccessor, boolean isNullable,
PropertyHolder propertyHolder,
PropertyData inferredData,
AccessType propertyAccessor,
boolean isNullable,
EntityBinder entityBinder,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass,
ExtendedMappings mappings, Map<XClass, InheritanceState> inheritanceStatePerClass
) {
boolean isComponentEmbedded,
boolean isIdentifierMapper,
boolean inSecondPass,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
return fillComponent(
propertyHolder, inferredData, null, propertyAccessor,
isNullable, entityBinder, isComponentEmbedded, isIdentifierMapper, inSecondPass, mappings,
@ -2255,13 +2288,17 @@ public final class AnnotationBinder {
}
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)
AccessType propertyAccessor, boolean isNullable, EntityBinder entityBinder,
boolean isComponentEmbedded, boolean isIdentifierMapper, boolean inSecondPass, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
AccessType propertyAccessor,
boolean isNullable,
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
* Because it's a value type, there is no bidirectional association, hence second pass
@ -2380,7 +2417,7 @@ public final class AnnotationBinder {
PropertyData inferredData,
boolean isComponentEmbedded,
boolean isIdentifierMapper,
ExtendedMappings mappings) {
Mappings mappings) {
Component comp = new Component( mappings, propertyHolder.getPersistentClass() );
comp.setEmbedded( isComponentEmbedded );
//yuk
@ -2397,13 +2434,19 @@ public final class AnnotationBinder {
}
private static void bindIdClass(
String generatorType, String generatorName, PropertyData inferredData,
PropertyData baseInferredData, Ejb3Column[] columns, PropertyHolder propertyHolder,
String generatorType,
String generatorName,
PropertyData inferredData,
PropertyData baseInferredData,
Ejb3Column[] columns,
PropertyHolder propertyHolder,
boolean isComposite,
AccessType propertyAccessor, EntityBinder entityBinder, boolean isEmbedded,
boolean isIdentifierMapper, ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
AccessType propertyAccessor,
EntityBinder entityBinder,
boolean isEmbedded,
boolean isIdentifierMapper,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
/*
* Fill simple value and property since and Id is a property
@ -2485,7 +2528,7 @@ public final class AnnotationBinder {
PropertyData inferredData,
PropertyData baseInferredData,
AccessType propertyAccessor,
ExtendedMappings mappings) {
Mappings mappings) {
List<PropertyData> baseClassElements = new ArrayList<PropertyData>();
XClass baseReturnedClassOrElement = baseInferredData.getClassOrElement();
PropertyContainer propContainer = new PropertyContainer(
@ -2514,14 +2557,19 @@ public final class AnnotationBinder {
}
private static void bindManyToOne(
String cascadeStrategy, Ejb3JoinColumn[] columns, boolean optional,
boolean ignoreNotFound, boolean cascadeOnDelete,
XClass targetEntity, PropertyHolder propertyHolder,
PropertyData inferredData, boolean unique,
boolean isIdentifierMapper, boolean inSecondPass,
String cascadeStrategy,
Ejb3JoinColumn[] columns,
boolean optional,
boolean ignoreNotFound,
boolean cascadeOnDelete,
XClass targetEntity,
PropertyHolder propertyHolder,
PropertyData inferredData,
boolean unique,
boolean isIdentifierMapper,
boolean inSecondPass,
PropertyBinder propertyBinder,
ExtendedMappings mappings
) {
Mappings mappings) {
//All FK columns should be in the same table
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
@ -2655,8 +2703,7 @@ public final class AnnotationBinder {
boolean isIdentifierMapper,
boolean inSecondPass,
PropertyBinder propertyBinder,
ExtendedMappings mappings
) {
Mappings mappings) {
//column.getTable() => persistentClass.getTable()
final String propertyName = inferredData.getPropertyName();
log.trace( "Fetching {} with {}", propertyName, fetchMode );
@ -2721,10 +2768,15 @@ public final class AnnotationBinder {
}
private static void bindAny(
String cascadeStrategy, Ejb3JoinColumn[] columns, boolean cascadeOnDelete, Nullability nullability,
PropertyHolder propertyHolder, PropertyData inferredData, EntityBinder entityBinder,
boolean isIdentifierMapper, ExtendedMappings mappings
) {
String cascadeStrategy,
Ejb3JoinColumn[] columns,
boolean cascadeOnDelete,
Nullability nullability,
PropertyHolder propertyHolder,
PropertyData inferredData,
EntityBinder entityBinder,
boolean isIdentifierMapper,
Mappings mappings) {
org.hibernate.annotations.Any anyAnn = inferredData.getProperty()
.getAnnotation( org.hibernate.annotations.Any.class );
if ( anyAnn == null ) {
@ -2759,7 +2811,7 @@ public final class AnnotationBinder {
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();
switch ( generatorEnum ) {
case IDENTITY:
@ -2811,8 +2863,10 @@ public final class AnnotationBinder {
}
private static String getCascadeStrategy(
javax.persistence.CascadeType[] ejbCascades, Cascade hibernateCascadeAnnotation,
boolean orphanRemoval, boolean forcePersist) {
javax.persistence.CascadeType[] ejbCascades,
Cascade hibernateCascadeAnnotation,
boolean orphanRemoval,
boolean forcePersist) {
EnumSet<CascadeType> hibernateCascadeSet = convertToHibernateCascadeType( ejbCascades );
CascadeType[] hibernateCascades = hibernateCascadeAnnotation == 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>();
TableGenerator tabGen = annElt.getAnnotation( TableGenerator.class );
SequenceGenerator seqGen = annElt.getAnnotation( SequenceGenerator.class );
@ -2903,7 +2957,7 @@ public final class AnnotationBinder {
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 );
}
@ -2917,7 +2971,7 @@ public final class AnnotationBinder {
*/
public static Map<XClass, InheritanceState> buildInheritanceStates(
List<XClass> orderedClasses,
ExtendedMappings mappings) {
Mappings mappings) {
ReflectionManager reflectionManager = mappings.getReflectionManager();
Map<XClass, InheritanceState> inheritanceStatePerClass = new HashMap<XClass, InheritanceState>(
orderedClasses.size()

View File

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

View File

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

View File

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

View File

@ -46,7 +46,7 @@ import org.hibernate.util.StringHelper;
/**
* 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
*/
@ -56,11 +56,17 @@ class ColumnsBuilder {
private XProperty property;
private PropertyData inferredData;
private EntityBinder entityBinder;
private ExtendedMappings mappings;
private Mappings mappings;
private Ejb3Column[] columns;
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.nullability = nullability;
this.property = property;
@ -214,7 +220,9 @@ class ColumnsBuilder {
Ejb3Column[] overrideColumnFromMapperOrMapsIdProperty(boolean isId) {
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 ) {
result = buildExcplicitOrDefaultJoinColumn( overridingProperty );
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -36,9 +36,13 @@ import org.hibernate.mapping.SimpleValue;
@SuppressWarnings({"serial", "unchecked"})
public class JoinedSubclassFkSecondPass extends FkSecondPass {
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 );
this.entity = entity;
this.mappings = mappings;

View File

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

View File

@ -46,11 +46,11 @@ public final class PropertyHolderBuilder {
XClass clazzToProcess,
PersistentClass persistentClass,
EntityBinder entityBinder,
//Map<String, Join> joins,
ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
return new ClassPropertyHolder( persistentClass, clazzToProcess, entityBinder, mappings, inheritanceStatePerClass );
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
return new ClassPropertyHolder(
persistentClass, clazzToProcess, entityBinder, mappings, inheritanceStatePerClass
);
}
/**
@ -62,9 +62,11 @@ public final class PropertyHolderBuilder {
* @return PropertyHolder
*/
public static PropertyHolder buildPropertyHolder(
Component component, String path, PropertyData inferredData, PropertyHolder parent,
ExtendedMappings mappings
) {
Component component,
String path,
PropertyData inferredData,
PropertyHolder parent,
Mappings 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
*/
public static PropertyHolder buildPropertyHolder(
Collection collection, String path, XClass clazzToProcess, XProperty property,
PropertyHolder parentPropertyHolder, ExtendedMappings mappings
) {
return new CollectionPropertyHolder( collection, path, clazzToProcess, property, parentPropertyHolder, mappings );
Collection collection,
String path,
XClass clazzToProcess,
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)
*/
public static PropertyHolder buildPropertyHolder(
PersistentClass persistentClass, Map<String, Join> joins,
ExtendedMappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
PersistentClass persistentClass,
Map<String, Join> joins,
Mappings mappings,
Map<XClass, InheritanceState> 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
*/
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 ) ) {
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 );
if ( AnnotationBinder.isDefault( targetEntity, mappings ) ) {
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();
return mappings.getReflectionManager().toXClass( getTargetEntityClass( property ) );
}

View File

@ -47,13 +47,17 @@ import org.hibernate.util.StringHelper;
*/
public class ToOneFkSecondPass extends FkSecondPass {
private boolean unique;
private ExtendedMappings mappings;
private Mappings mappings;
private String path;
private String entityClassName;
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 );
this.mappings = mappings;
this.unique = unique;

View File

@ -34,12 +34,14 @@ import org.hibernate.mapping.PersistentClass;
* @author Hardy Ferentschik
*/
public class VerifyFetchProfileReferenceSecondPass implements SecondPass {
private String fetchProfileName;
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.fetch = fetch;
this.mappings = mappings;

View File

@ -85,9 +85,9 @@ import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.IndexColumn;
import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyData;
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder;
@ -121,7 +121,6 @@ import org.hibernate.util.StringHelper;
*/
@SuppressWarnings({"unchecked", "serial"})
public abstract class CollectionBinder {
private Logger log = LoggerFactory.getLogger( CollectionBinder.class );
protected Collection collection;
@ -131,7 +130,7 @@ public abstract class CollectionBinder {
private String mappedBy;
private XClass collectionType;
private XClass targetEntity;
private ExtendedMappings mappings;
private Mappings mappings;
private Ejb3JoinColumn[] inverseJoinColumns;
private String cascadeStrategy;
String cacheConcurrencyStrategy;
@ -163,7 +162,7 @@ public abstract class CollectionBinder {
private AccessType accessType;
private boolean hibernateExtensionMapping;
protected ExtendedMappings getMappings() {
protected Mappings getMappings() {
return mappings;
}
@ -244,9 +243,10 @@ public abstract class CollectionBinder {
* collection binder factory
*/
public static CollectionBinder getCollectionBinder(
String entityName, XProperty property,
boolean isIndexed, boolean isHibernateExtensionMapping
) {
String entityName,
XProperty property,
boolean isIndexed,
boolean isHibernateExtensionMapping) {
CollectionBinder result;
if ( property.isArray() ) {
if ( property.getElementClass().isPrimitive() ) {
@ -351,7 +351,7 @@ public abstract class CollectionBinder {
this.targetEntity = targetEntity;
}
public void setMappings(ExtendedMappings mappings) {
public void setMappings(Mappings mappings) {
this.mappings = mappings;
}
@ -610,23 +610,25 @@ public abstract class CollectionBinder {
}
public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] fkJoinColumns,
final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns,
final Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded,
final XProperty property, final XClass collType,
final boolean ignoreNotFound, final boolean unique,
final TableBinder assocTableBinder, final ExtendedMappings mappings
) {
final Ejb3Column[] mapKeyColumns,
final Ejb3JoinColumn[] mapKeyManyToManyColumns,
final boolean isEmbedded,
final XProperty property,
final XClass collType,
final boolean ignoreNotFound,
final boolean unique,
final TableBinder assocTableBinder,
final Mappings mappings) {
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(
persistentClasses, collType, fkJoinColumns, keyColumns, inverseColumns, elementColumns,
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
*/
protected boolean bindStarToManySecondPass(
Map persistentClasses, XClass collType, Ejb3JoinColumn[] fkJoinColumns,
Ejb3JoinColumn[] keyColumns, Ejb3JoinColumn[] inverseColumns, Ejb3Column[] elementColumns,
Map persistentClasses,
XClass collType,
Ejb3JoinColumn[] fkJoinColumns,
Ejb3JoinColumn[] keyColumns,
Ejb3JoinColumn[] inverseColumns,
Ejb3Column[] elementColumns,
boolean isEmbedded,
XProperty property, boolean unique,
XProperty property,
boolean unique,
TableBinder associationTableBinder,
boolean ignoreNotFound, ExtendedMappings mappings
) {
boolean ignoreNotFound,
Mappings mappings) {
PersistentClass persistentClass = (PersistentClass) persistentClasses.get( collType.getName() );
boolean reversePropertyInJoin = false;
if ( persistentClass != null && StringHelper.isNotEmpty( this.mappedBy ) ) {
@ -699,14 +706,17 @@ public abstract class CollectionBinder {
}
protected void bindOneToManySecondPass(
Collection collection, Map persistentClasses, Ejb3JoinColumn[] fkJoinColumns,
Collection collection,
Map persistentClasses,
Ejb3JoinColumn[] fkJoinColumns,
XClass collectionType,
boolean cascadeDeleteEnabled, boolean ignoreNotFound, String hqlOrderBy, ExtendedMappings extendedMappings,
Map<XClass, InheritanceState> inheritanceStatePerClass
) {
boolean cascadeDeleteEnabled,
boolean ignoreNotFound,
String hqlOrderBy,
Mappings mappings,
Map<XClass, InheritanceState> inheritanceStatePerClass) {
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 );
oneToMany.setReferencedEntityName( collectionType.getName() );
oneToMany.setIgnoreNotFound( ignoreNotFound );
@ -1076,7 +1086,7 @@ public abstract class CollectionBinder {
private static SimpleValue buildCollectionKey(
Collection collValue, Ejb3JoinColumn[] joinColumns, boolean cascadeDeleteEnabled,
XProperty property, ExtendedMappings mappings
XProperty property, Mappings mappings
) {
//binding key reference using column
KeyValue keyVal;
@ -1127,9 +1137,11 @@ public abstract class CollectionBinder {
XClass collType,
boolean ignoreNotFound, boolean unique,
boolean cascadeDeleteEnabled,
TableBinder associationTableBinder, XProperty property, PropertyHolder parentPropertyHolder,
String hqlOrderBy, ExtendedMappings mappings
) throws MappingException {
TableBinder associationTableBinder,
XProperty property,
PropertyHolder parentPropertyHolder,
String hqlOrderBy,
Mappings mappings) throws MappingException {
PersistentClass collectionEntity = (PersistentClass) persistentClasses.get( collType.getName() );
boolean isCollectionOfEntities = collectionEntity != null;
@ -1415,10 +1427,12 @@ public abstract class CollectionBinder {
}
private static void bindCollectionSecondPass(
Collection collValue, PersistentClass collectionEntity, Ejb3JoinColumn[] joinColumns,
boolean cascadeDeleteEnabled, XProperty property,
ExtendedMappings mappings
) {
Collection collValue,
PersistentClass collectionEntity,
Ejb3JoinColumn[] joinColumns,
boolean cascadeDeleteEnabled,
XProperty property,
Mappings mappings) {
BinderHelper.createSyntheticPropertyReference(
joinColumns, collValue.getOwner(), collectionEntity, collValue, false, mappings
);
@ -1450,9 +1464,11 @@ public abstract class CollectionBinder {
* Otherwise delegates to the usual algorithm
*/
public static void bindManytoManyInverseFk(
PersistentClass referencedEntity, Ejb3JoinColumn[] columns, SimpleValue value, boolean unique,
ExtendedMappings mappings
) {
PersistentClass referencedEntity,
Ejb3JoinColumn[] columns,
SimpleValue value,
boolean unique,
Mappings mappings) {
final String mappedBy = columns[0].getMappedBy();
if ( StringHelper.isNotEmpty( 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.BinderHelper;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.InheritanceState;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.ObjectNameSource;
import org.hibernate.cfg.NamingStrategy;
@ -99,7 +99,7 @@ public class EntityBinder {
private String name;
private XClass annotatedClass;
private PersistentClass persistentClass;
private ExtendedMappings mappings;
private Mappings mappings;
private Logger log = LoggerFactory.getLogger( EntityBinder.class );
private String discriminatorValue = "";
private boolean dynamicInsert;
@ -136,10 +136,11 @@ public class EntityBinder {
}
public EntityBinder(
Entity ejb3Ann, org.hibernate.annotations.Entity hibAnn,
XClass annotatedClass, PersistentClass persistentClass,
ExtendedMappings mappings
) {
Entity ejb3Ann,
org.hibernate.annotations.Entity hibAnn,
XClass annotatedClass,
PersistentClass persistentClass,
Mappings mappings) {
this.mappings = mappings;
this.persistentClass = persistentClass;
this.annotatedClass = annotatedClass;
@ -479,9 +480,12 @@ public class EntityBinder {
}
public void bindTable(
String schema, String catalog,
String tableName, List<UniqueConstraintHolder> uniqueConstraints,
String constraints, Table denormalizedSuperclassTable) {
String schema,
String catalog,
String tableName,
List<UniqueConstraintHolder> uniqueConstraints,
String constraints,
Table denormalizedSuperclassTable) {
EntityTableObjectNameSource tableNameContext = new EntityTableObjectNameSource( tableName, name );
EntityTableNamingStrategyHelper namingStrategyHelper = new EntityTableNamingStrategyHelper( name );
final Table table = TableBinder.buildAndFillTable(
@ -589,7 +593,7 @@ public class EntityBinder {
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() );
join.setKey( key );
setFKNameIfDefined( join );

View File

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

View File

@ -37,7 +37,7 @@ import org.hibernate.annotations.common.reflection.XProperty;
import org.hibernate.cfg.CollectionSecondPass;
import org.hibernate.cfg.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.PropertyHolder;
import org.hibernate.cfg.PropertyHolderBuilder;
import org.hibernate.cfg.SecondPass;
@ -76,14 +76,19 @@ public class ListBinder extends CollectionBinder {
@Override
public SecondPass getSecondPass(
final Ejb3JoinColumn[] fkJoinColumns, final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] fkJoinColumns,
final Ejb3JoinColumn[] keyColumns,
final Ejb3JoinColumn[] inverseColumns,
final Ejb3Column[] elementColumns,
Ejb3Column[] mapKeyColumns, final Ejb3JoinColumn[] mapKeyManyToManyColumns, final boolean isEmbedded,
final XProperty property, final XClass collType,
final boolean ignoreNotFound, final boolean unique,
final TableBinder assocTableBinder, final ExtendedMappings mappings
) {
Ejb3Column[] mapKeyColumns,
final Ejb3JoinColumn[] mapKeyManyToManyColumns,
final boolean isEmbedded,
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 ) {
public void secondPass(Map persistentClasses, Map inheritedMetas)
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() ) {
PropertyHolder valueHolder = PropertyHolderBuilder.buildPropertyHolder(
this.collection,

View File

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

View File

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

View File

@ -40,7 +40,7 @@ import org.hibernate.LockMode;
import org.hibernate.annotations.CacheModeType;
import org.hibernate.annotations.FlushModeType;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.engine.NamedQueryDefinition;
import org.hibernate.engine.NamedSQLQueryDefinition;
@ -57,7 +57,7 @@ import org.slf4j.LoggerFactory;
public abstract class QueryBinder {
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 ( BinderHelper.isDefault( queryAnn.name() ) ) {
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;
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
@ -148,7 +148,7 @@ public abstract class QueryBinder {
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;
//ResultSetMappingDefinition mappingDefinition = mappings.getResultSetMapping( queryAnn.resultSetMapping() );
if ( BinderHelper.isDefault( queryAnn.name() ) ) {
@ -202,14 +202,14 @@ public abstract class QueryBinder {
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;
for (NamedQuery q : queriesAnn.value()) {
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;
for (NamedNativeQuery q : queriesAnn.value()) {
bindNativeQuery( q, mappings, isDefault );
@ -217,7 +217,7 @@ public abstract class QueryBinder {
}
public static void bindNativeQueries(
org.hibernate.annotations.NamedNativeQueries queriesAnn, ExtendedMappings mappings
org.hibernate.annotations.NamedNativeQueries queriesAnn, Mappings mappings
) {
if ( queriesAnn == null ) return;
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 ( BinderHelper.isDefault( queryAnn.name() ) ) {
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;
for (org.hibernate.annotations.NamedQuery q : queriesAnn.value()) {
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;
for (SqlResultSetMapping rs : ann.value()) {
//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
mappings.addSecondPass( new ResultsetMappingSecondPass( ann, mappings, isDefault ) );
}

View File

@ -38,7 +38,7 @@ import javax.persistence.SqlResultSetMapping;
import org.hibernate.LockMode;
import org.hibernate.MappingException;
import org.hibernate.cfg.BinderHelper;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.QuerySecondPass;
import org.hibernate.engine.ResultSetMappingDefinition;
import org.hibernate.engine.query.sql.NativeSQLQueryRootReturn;
@ -58,10 +58,10 @@ import org.slf4j.LoggerFactory;
public class ResultsetMappingSecondPass implements QuerySecondPass {
private Logger log = LoggerFactory.getLogger( ResultsetMappingSecondPass.class );
private SqlResultSetMapping ann;
private ExtendedMappings mappings;
private Mappings mappings;
private boolean isDefault;
public ResultsetMappingSecondPass(SqlResultSetMapping ann, ExtendedMappings mappings, boolean isDefault) {
public ResultsetMappingSecondPass(SqlResultSetMapping ann, Mappings mappings, boolean isDefault) {
this.ann = ann;
this.mappings = mappings;
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.Ejb3Column;
import org.hibernate.cfg.Ejb3JoinColumn;
import org.hibernate.cfg.ExtendedMappings;
import org.hibernate.cfg.Mappings;
import org.hibernate.cfg.NotYetImplementedException;
import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
import org.hibernate.cfg.SetSimpleValueTypeSecondPass;
@ -72,7 +72,7 @@ public class SimpleValueBinder {
private String persistentClassName;
private String explicitType = "";
private Properties typeParameters = new Properties();
private ExtendedMappings mappings;
private Mappings mappings;
private Table table;
private SimpleValue simpleValue;
private boolean isVersion;
@ -278,7 +278,7 @@ public class SimpleValueBinder {
}
}
public void setMappings(ExtendedMappings mappings) {
public void setMappings(Mappings mappings) {
this.mappings = mappings;
}

View File

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