HHH-16912 return null from deprecated method instead of producing a CCE

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.

(cherry picked from commit 7c378847cb)
This commit is contained in:
Gavin King 2023-07-19 00:44:04 +02:00 committed by Steve Ebersole
parent ff0479c1d2
commit 5247156259
1 changed files with 10 additions and 2 deletions

View File

@ -36,6 +36,9 @@ public interface KeyValue extends Value {
/**
* @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(
@ -44,18 +47,23 @@ public interface KeyValue extends Value {
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;
}
/**