Skip to content

Commit

Permalink
HHH-16912 return null from deprecated method instead of producing a CCE
Browse files Browse the repository at this point in the history
This is a band-aid over an error occurring in Liquibase. But it seems to
me that Liquibase itself should be updated to use the new APIs.
  • Loading branch information
gavinking committed Jul 18, 2023
1 parent e537138 commit 3391766
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions hibernate-core/src/main/java/org/hibernate/mapping/KeyValue.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ Generator createGenerator(

/**
* @deprecated Use {@link #createGenerator(IdentifierGeneratorFactory, Dialect, RootClass)} instead.
*
* @return {@code null} if the {@code Generator} returned by {@link #createGenerator} is not an instance
* of {@link IdentifierGenerator}.
*/
@Deprecated(since="6.2")
default IdentifierGenerator createIdentifierGenerator(
Expand All @@ -44,18 +47,23 @@ default IdentifierGenerator createIdentifierGenerator(
String defaultCatalog,
String defaultSchema,
RootClass rootClass) {
return (IdentifierGenerator) createGenerator( identifierGeneratorFactory, dialect, rootClass );
final Generator generator = createGenerator( identifierGeneratorFactory, dialect, rootClass );
return generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null;
}

/**
* @deprecated Use {@link #createGenerator(IdentifierGeneratorFactory, Dialect, RootClass)} instead.
*
* @return {@code null} if the {@code Generator} returned by {@link #createGenerator} is not an instance
* of {@link IdentifierGenerator}.
*/
@Deprecated(since="6.2")
default IdentifierGenerator createIdentifierGenerator(
IdentifierGeneratorFactory identifierGeneratorFactory,
Dialect dialect,
RootClass rootClass) {
return (IdentifierGenerator) createGenerator( identifierGeneratorFactory, dialect, rootClass );
final Generator generator = createGenerator( identifierGeneratorFactory, dialect, rootClass );
return generator instanceof IdentifierGenerator ? (IdentifierGenerator) generator : null;
}

/**
Expand Down

0 comments on commit 3391766

Please sign in to comment.