Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ static AnnotatedJoinColumn buildJoinColumn(
throw new AnnotationException( "Property '" + path
+ "' overrides mapping specified using '@JoinColumnOrFormula'" );
}
return buildJoinColumn( joinColumn, /*null,*/ mappedBy, parent, propertyHolder, inferredData, "" );
return buildJoinColumn( joinColumn, mappedBy, parent, propertyHolder, inferredData, "" );
}

public static AnnotatedJoinColumn buildJoinFormula(
Expand All @@ -102,7 +102,6 @@ public static AnnotatedJoinColumn buildJoinFormula(

static AnnotatedJoinColumn buildJoinColumn(
JoinColumn joinColumn,
// Comment comment,
String mappedBy,
AnnotatedJoinColumns parent,
PropertyHolder propertyHolder,
Expand All @@ -114,7 +113,7 @@ static AnnotatedJoinColumn buildJoinColumn(
+ getRelativePath( propertyHolder, inferredData.getPropertyName() )
+ "' is 'mappedBy' a different entity and may not explicitly specify the '@JoinColumn'" );
}
return explicitJoinColumn( joinColumn, /*comment,*/ parent, inferredData, defaultColumnSuffix );
return explicitJoinColumn( joinColumn, parent, inferredData, defaultColumnSuffix );
}
else {
return implicitJoinColumn( parent, inferredData, defaultColumnSuffix );
Expand All @@ -123,12 +122,10 @@ static AnnotatedJoinColumn buildJoinColumn(

private static AnnotatedJoinColumn explicitJoinColumn(
JoinColumn joinColumn,
// Comment comment,
AnnotatedJoinColumns parent,
PropertyData inferredData,
String defaultColumnSuffix) {
final AnnotatedJoinColumn column = new AnnotatedJoinColumn();
// column.setComment( comment != null ? comment.value() : null );
// column.setContext( context );
// column.setJoins( joins );
// column.setPropertyHolder( propertyHolder );
Expand Down Expand Up @@ -290,15 +287,6 @@ private static AnnotatedJoinColumn buildImplicitInheritanceJoinColumn(
return column;
}

public static void checkIfJoinColumn(Object columns, PropertyHolder holder, PropertyData property) {
if ( !( columns instanceof AnnotatedJoinColumn[] ) ) {
throw new AnnotationException(
"Property '" + getRelativePath( holder, property.getPropertyName() )
+ "' is an association and may not use '@Column' to specify column mappings (use '@JoinColumn' instead)"
);
}
}

public void copyReferencedStructureAndCreateDefaultJoinColumns(
PersistentClass referencedEntity,
SimpleValue referencedValue,
Expand Down Expand Up @@ -386,14 +374,8 @@ private String defaultColumnName(int columnIndex, PersistentClass referencedEnti
// }
}

public void addDefaultJoinColumnName(PersistentClass referencedEntity, String logicalReferencedColumn) {
final String columnName = getParent().buildDefaultColumnName( referencedEntity, logicalReferencedColumn );
getMappingColumn().setName( columnName );
setLogicalColumnName( columnName );
}

/**
* used for mappedBy cases
* Used for {@code mappedBy} cases.
*/
public void linkValueUsingAColumnCopy(Column column, SimpleValue value) {
initMappingColumn(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,13 @@ static AnnotatedJoinColumns buildJoinColumnsWithFormula(

public static AnnotatedJoinColumns buildJoinColumns(
JoinColumn[] joinColumns,
// Comment comment,
String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder,
PropertyData inferredData,
MetadataBuildingContext buildingContext) {
return buildJoinColumnsWithDefaultColumnSuffix(
joinColumns,
// comment,
mappedBy,
joins,
propertyHolder,
Expand All @@ -158,7 +156,6 @@ public static AnnotatedJoinColumns buildJoinColumns(

public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
JoinColumn[] joinColumns,
// Comment comment,
String mappedBy,
Map<String, Join> joins,
PropertyHolder propertyHolder,
Expand All @@ -180,7 +177,6 @@ public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
if ( isEmpty( actualColumns ) ) {
AnnotatedJoinColumn.buildJoinColumn(
null,
// comment,
mappedBy,
parent,
propertyHolder,
Expand All @@ -193,7 +189,6 @@ public static AnnotatedJoinColumns buildJoinColumnsWithDefaultColumnSuffix(
for ( JoinColumn actualColumn : actualColumns ) {
AnnotatedJoinColumn.buildJoinColumn(
actualColumn,
// comment,
mappedBy,
parent,
propertyHolder,
Expand Down Expand Up @@ -431,7 +426,7 @@ private Identifier columnIdentifier(
ImplicitNamingStrategy implicitNamingStrategy,
InFlightMetadataCollector collector,
Database database) {
boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );
final boolean isRefColumnQuoted = isQuoted( logicalReferencedColumn );

if ( isMappedBySide() ) {
// NOTE: An @ElementCollection can't be mappedBy, but the client code
Expand All @@ -444,17 +439,10 @@ private Identifier columnIdentifier(
}
else if ( isOwnerSide() ) {
final String logicalTableName = collector.getLogicalTableName( referencedEntity.getTable() );
Identifier columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
new OwnedImplicitJoinColumnNameSource(referencedEntity, logicalTableName, logicalReferencedColumn)
final Identifier columnIdentifier = implicitNamingStrategy.determineJoinColumnName(
new OwnedImplicitJoinColumnNameSource( referencedEntity, logicalTableName, logicalReferencedColumn )
);
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
columnIdentifier = Identifier.toIdentifier(
columnIdentifier.getText().replace( "_{element}_", "_" ),
columnIdentifier.isQuoted()
);
}
return quoteIfNecessary( isRefColumnQuoted, logicalTableName, columnIdentifier );
return quoteIfNecessary( isRefColumnQuoted, logicalTableName, handleElement( columnIdentifier ) );
}
else {
final Identifier logicalTableName = database.toIdentifier(
Expand Down Expand Up @@ -483,9 +471,23 @@ public Identifier getReferencedPrimaryKeyColumnName() {
}
}

private Identifier handleElement(Identifier columnIdentifier) {
// HHH-11826 magic. See AnnotatedColumn and the HHH-6005 comments
if ( columnIdentifier.getText().contains( "_{element}_" ) ) {
return Identifier.toIdentifier(
columnIdentifier.getText().replace( "_{element}_", "_" ),
columnIdentifier.isQuoted()
);
}
else {
return columnIdentifier;
}
}

private static Identifier quoteIfNecessary(
boolean isRefColumnQuoted, Identifier logicalTableName, Identifier columnIdentifier) {
return !columnIdentifier.isQuoted() && ( isRefColumnQuoted || logicalTableName.isQuoted() )
return !columnIdentifier.isQuoted()
&& ( isRefColumnQuoted || logicalTableName.isQuoted() )
? Identifier.quote( columnIdentifier )
: columnIdentifier;
}
Expand Down Expand Up @@ -596,8 +598,9 @@ public Identifier getReferencedColumnName() {
return null;
}

final Property mappedByProperty = collector.getEntityBinding( getMappedByEntityName() )
.getProperty( getMappedByPropertyName() );
final Property mappedByProperty =
collector.getEntityBinding( getMappedByEntityName() )
.getProperty( getMappedByPropertyName() );
final SimpleValue value = (SimpleValue) mappedByProperty.getValue();
if ( value.getSelectables().isEmpty() ) {
throw new AnnotationException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,6 @@ public static void bindCollection(
collectionBinder.setInheritanceStatePerClass( inheritanceStatePerClass );
collectionBinder.setDeclaringClass( inferredData.getDeclaringClass() );

// final Comment comment = property.getAnnotation( Comment.class );
final Cascade hibernateCascade = property.getAnnotationUsage( Cascade.class, modelsContext );

collectionBinder.setElementColumns( elementColumns(
Expand All @@ -261,7 +260,6 @@ public static void bindCollection(
entityBinder,
context,
property
// comment
) );

collectionBinder.setMapKeyManyToManyColumns( mapKeyJoinColumns(
Expand All @@ -270,7 +268,6 @@ public static void bindCollection(
entityBinder,
context,
property
// comment
) );

bindJoinedTableAssociation(
Expand Down Expand Up @@ -351,10 +348,8 @@ private static AnnotatedJoinColumns mapKeyJoinColumns(
EntityBinder entityBinder,
MetadataBuildingContext context,
MemberDetails property) {
// Comment comment) {
return buildJoinColumnsWithDefaultColumnSuffix(
mapKeyJoinColumnAnnotations( property, context ),
// comment,
null,
entityBinder.getSecondaryTables(),
propertyHolder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,6 @@ else if ( joinColumns == null
OneToMany oneToMany = property.getDirectAnnotationUsage( OneToMany.class );
joinColumns = AnnotatedJoinColumns.buildJoinColumns(
null,
// comment,
oneToMany == null ? null : nullIfEmpty( oneToMany.mappedBy() ),
entityBinder.getSecondaryTables(),
propertyHolder,
Expand Down Expand Up @@ -172,11 +171,9 @@ private AnnotatedJoinColumns buildDefaultJoinColumnsForToOne(
MemberDetails property,
PropertyData inferredData) {
final JoinTable joinTableAnn = propertyHolder.getJoinTable( property );
// final Comment comment = property.getAnnotation(Comment.class);
if ( joinTableAnn != null ) {
return AnnotatedJoinColumns.buildJoinColumns(
joinTableAnn.inverseJoinColumns(),
// comment,
null,
entityBinder.getSecondaryTables(),
propertyHolder,
Expand All @@ -188,7 +185,6 @@ private AnnotatedJoinColumns buildDefaultJoinColumnsForToOne(
final OneToOne oneToOneAnn = property.getDirectAnnotationUsage( OneToOne.class );
return AnnotatedJoinColumns.buildJoinColumns(
null,
// comment,
oneToOneAnn == null ? null : nullIfEmpty( oneToOneAnn.mappedBy() ),
entityBinder.getSecondaryTables(),
propertyHolder,
Expand Down