Skip to content

HHH-16125 PostgreSQL enum types + reimplementation of enum support #6448

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 11 commits into from
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JsonJdbcType;
import org.hibernate.type.descriptor.jdbc.NullJdbcType;
import org.hibernate.type.descriptor.jdbc.spi.JdbcTypeRegistry;
import org.hibernate.type.descriptor.sql.internal.CapacityDependentDdlType;
Expand Down Expand Up @@ -796,7 +795,7 @@ public boolean supportsColumnCheck() {
}

@Override
public String getEnumTypeDeclaration(String[] values) {
public String getEnumTypeDeclaration(String name, String[] values) {
StringBuilder type = new StringBuilder();
type.append( "enum (" );
String separator = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1020,8 +1020,8 @@ public org.hibernate.type.Type getReferencedPropertyType(String entityName, Stri
}


private Map<Identifier,Identifier> logicalToPhysicalTableNameMap = new HashMap<>();
private Map<Identifier,Identifier> physicalToLogicalTableNameMap = new HashMap<>();
private final Map<Identifier,Identifier> logicalToPhysicalTableNameMap = new HashMap<>();
private final Map<Identifier,Identifier> physicalToLogicalTableNameMap = new HashMap<>();

@Override
public void addTableNameBinding(Identifier logicalName, Table table) {
Expand Down Expand Up @@ -1204,7 +1204,7 @@ public String getLogicalColumnName(Table table, Identifier physicalName) throws
}
}

if ( DenormalizedTable.class.isInstance( currentTable ) ) {
if ( currentTable instanceof DenormalizedTable ) {
currentTable = ( (DenormalizedTable) currentTable ).getIncludedTable();
}
else {
Expand Down Expand Up @@ -1265,15 +1265,15 @@ else if ( clazz.isAnnotationPresent( Imported.class ) ) {


@Override
public void addMappedSuperclass(Class type, MappedSuperclass mappedSuperclass) {
public void addMappedSuperclass(Class<?> type, MappedSuperclass mappedSuperclass) {
if ( mappedSuperClasses == null ) {
mappedSuperClasses = new HashMap<>();
}
mappedSuperClasses.put( type, mappedSuperclass );
}

@Override
public MappedSuperclass getMappedSuperclass(Class type) {
public MappedSuperclass getMappedSuperclass(Class<?> type) {
if ( mappedSuperClasses == null ) {
return null;
}
Expand Down Expand Up @@ -1421,13 +1421,12 @@ public void addUniquePropertyReference(String referencedClass, String propertyNa
);
}

@Override
@SuppressWarnings("unchecked")
public void addUniqueConstraints(Table table, List uniqueConstraints) {
@Override @Deprecated(forRemoval = true)
public void addUniqueConstraints(Table table, List<String[]> uniqueConstraints) {
List<UniqueConstraintHolder> constraintHolders = new ArrayList<>( uniqueConstraints.size() );

int keyNameBase = determineCurrentNumberOfUniqueConstraintHolders( table );
for ( String[] columns : ( List<String[]> ) uniqueConstraints ) {
for ( String[] columns : uniqueConstraints ) {
final String keyName = "key" + keyNameBase++;
constraintHolders.add(
new UniqueConstraintHolder().setName( keyName ).setColumns( columns )
Expand All @@ -1438,9 +1437,7 @@ public void addUniqueConstraints(Table table, List uniqueConstraints) {

private int determineCurrentNumberOfUniqueConstraintHolders(Table table) {
List currentHolders = uniqueConstraintHoldersByTable == null ? null : uniqueConstraintHoldersByTable.get( table );
return currentHolders == null
? 0
: currentHolders.size();
return currentHolders == null ? 0 : currentHolders.size();
}

@Override
Expand Down Expand Up @@ -1514,7 +1511,7 @@ public Map<String, Join> getJoins(String entityName) {
private static final class EntityTableXrefImpl implements EntityTableXref {
private final Identifier primaryTableLogicalName;
private final Table primaryTable;
private EntityTableXrefImpl superEntityTableXref;
private final EntityTableXrefImpl superEntityTableXref;

//annotations needs a Map<String,Join>
//private Map<Identifier,Join> secondaryTableJoinMap;
Expand Down Expand Up @@ -1972,6 +1969,7 @@ protected void secondPassCompileForeignKeys(Table table, Set<ForeignKey> done, M
throws MappingException {
table.createForeignKeys();

final Dialect dialect = getDatabase().getJdbcEnvironment().getDialect();
for ( ForeignKey foreignKey : table.getForeignKeys().values() ) {
if ( !done.contains( foreignKey ) ) {
done.add( foreignKey );
Expand All @@ -1998,7 +1996,7 @@ protected void secondPassCompileForeignKeys(Table table, Set<ForeignKey> done, M

final Identifier nameIdentifier = getMetadataBuildingOptions().getImplicitNamingStrategy()
.determineForeignKeyName( new ForeignKeyNameSource( foreignKey, table, buildingContext ) );
foreignKey.setName( nameIdentifier.render( getDatabase().getJdbcEnvironment().getDialect() ) );
foreignKey.setName( nameIdentifier.render( dialect ) );

foreignKey.alignColumns();
}
Expand All @@ -2017,14 +2015,13 @@ private List<Identifier> toIdentifiers(String[] names) {
return columnNames;
}

@SuppressWarnings("unchecked")
private List<Identifier> extractColumnNames(List columns) {
private List<Identifier> extractColumnNames(List<Column> columns) {
if ( columns == null || columns.isEmpty() ) {
return emptyList();
}

final List<Identifier> columnNames = arrayList( columns.size() );
for ( Column column : (List<Column>) columns ) {
for ( Column column : columns ) {
columnNames.add( getDatabase().toIdentifier( column.getQuotedName() ) );
}
return columnNames;
Expand Down Expand Up @@ -2397,13 +2394,6 @@ private void handleIdentifierValueBinding(
}
}

private String extractName(Identifier identifier, Dialect dialect) {
if ( identifier == null ) {
return null;
}
return identifier.render( dialect );
}

private class IndexOrUniqueKeyNameSource implements ImplicitIndexNameSource, ImplicitUniqueKeyNameSource {
private final MetadataBuildingContext buildingContext;
private final Table table;
Expand Down

This file was deleted.

Loading