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 @@ -57,7 +57,7 @@ static boolean hasMatchingLength(Column column, ColumnInformation columnInformat
return true;
}
else {
int sqlType = columnInformation.getTypeCode();
final int sqlType = columnInformation.getTypeCode();
if ( isStringType( sqlType ) ) {
final int actualLength = columnInformation.getColumnSize();
final Size size = column.getColumnSize( dialect, metadata );
Expand Down Expand Up @@ -91,14 +91,14 @@ static String getFullColumnDeclaration(
Metadata metadata,
Dialect dialect,
SqlStringGenerationContext context) {
StringBuilder definition = new StringBuilder();
final StringBuilder definition = new StringBuilder();
appendColumn( definition, column, table, metadata, dialect, context );
return definition.toString();
}


static String getColumnDefinition(Column column, Metadata metadata, Dialect dialect) {
StringBuilder definition = new StringBuilder();
final StringBuilder definition = new StringBuilder();
appendColumnDefinition( definition, column, metadata, dialect );
appendComment( definition, column, dialect );
return definition.toString();
Expand Down Expand Up @@ -235,28 +235,19 @@ private static String normalize(String typeName) {
}
else {
final String lowercaseTypeName = typeName.toLowerCase(Locale.ROOT);
switch (lowercaseTypeName) {
case "int":
return "integer";
case "character":
return "char";
case "character varying":
return "varchar";
case "binary varying":
return "varbinary";
case "character large object":
return "clob";
case "binary large object":
return "blob";
case "interval second":
return "interval";
case "double precision":
return "double";
return switch ( lowercaseTypeName ) {
case "int" -> "integer";
case "character" -> "char";
case "character varying" -> "varchar";
case "binary varying" -> "varbinary";
case "character large object" -> "clob";
case "binary large object" -> "blob";
case "interval second" -> "interval";
case "double precision" -> "double";
// todo: normalize DECIMAL to NUMERIC?
// normalize REAL to FLOAT?
default:
return lowercaseTypeName;
}
default -> lowercaseTypeName;
};
}
}

Expand All @@ -265,7 +256,7 @@ private static String stripArgs(String typeExpression) {
return null;
}
else {
int i = typeExpression.indexOf('(');
final int i = typeExpression.indexOf('(');
return i>0 ? typeExpression.substring(0,i).trim() : typeExpression;
}
}
Expand Down
10 changes: 10 additions & 0 deletions migration-guide.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -410,6 +410,16 @@ Previously, `char` and `Character` fields were, by default, mapped to `char(1)`
However, MySQL treats a `char(1)` containing a single space as an empty string, resulting in broken behavior for some HQL and SQL functions.
Now, `varchar(1)` is used by default.

[[unowned-order-column]]
== `@OrderColumn` in unowned `@OneToMany` associations

In an unowned (`mappedBy`) one-to-many association, an `@OrderColumn` should, in principle, also be mapped by a field of the associated entity, and the value of the order column should be determined by the value of this field, not by the position in the list.

Previously, since version 4.1, https://hibernate.atlassian.net/issues/HHH-18830[Hibernate would issue superfluous SQL `UPDATE` statements] to set the value of the order column based on the state of the unowned collection.
This was incorrect according to the JPA specification, and inconsistent with the natural semantics of Hibernate.

In Hibernate 7, these SQL `UPDATE` statements only occur if the `@OrderColumn` is _not_ also mapped by a field of the entity.

[[cleanup]]
== Cleanup

Expand Down
Loading