HHH-15802 - Fix some expression comparison type checks

This commit is contained in:
Christian Beikov 2023-03-03 12:08:56 +01:00
parent eed870c0e8
commit b82fa307ea
22 changed files with 102 additions and 115 deletions

View File

@ -2443,7 +2443,7 @@ public class HQLTest extends BaseEntityManagerFunctionalTestCase {
List<Person> persons = entityManager.createQuery(
"select p " +
"from Person p " +
"where p.createdOn > '1950-01-01' ",
"where p.createdOn > date 1950-01-01 ",
Person.class)
.getResultList();
//end::hql-relational-comparisons-example[]

View File

@ -51,7 +51,7 @@ public class InstantLiteralTest extends BaseEntityManagerFunctionalTestCase {
.createQuery(
"select de " +
"from DateEvent de " +
"where de.createdOn = '2016-10-13T06:40:18.745Z' ", DateEvent.class)
"where de.createdOn = zoned datetime 2016-10-13 06:40:18.745Z ", DateEvent.class)
.getSingleResult();
assertNotNull(dateEvent);

View File

@ -29,6 +29,7 @@ import org.hibernate.type.descriptor.java.BasicPluralJavaType;
import org.hibernate.type.descriptor.java.EnumJavaType;
import org.hibernate.type.descriptor.java.ImmutableMutabilityPlan;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.MutabilityPlan;
import org.hibernate.type.descriptor.java.SerializableJavaType;
import org.hibernate.type.descriptor.java.TemporalJavaType;
@ -81,7 +82,7 @@ public class InferredBasicValueResolver {
typeConfiguration
);
}
else if ( explicitJavaType.isTemporalType() ) {
else if ( JavaTypeHelper.isTemporal( explicitJavaType ) ) {
return fromTemporal(
(TemporalJavaType<T>) explicitJavaType,
null,
@ -133,7 +134,7 @@ public class InferredBasicValueResolver {
typeConfiguration
);
}
else if ( reflectedJtd.isTemporalType() ) {
else if ( JavaTypeHelper.isTemporal( reflectedJtd ) ) {
return fromTemporal(
(TemporalJavaType<T>) reflectedJtd,
null,
@ -170,7 +171,7 @@ public class InferredBasicValueResolver {
);
registeredElementType = resolution.getLegacyResolvedBasicType();
}
else if ( elementJtd.isTemporalType() ) {
else if ( JavaTypeHelper.isTemporal( elementJtd ) ) {
final InferredBasicValueResolution resolution = InferredBasicValueResolver.fromTemporal(
(TemporalJavaType<T>) elementJtd,
null,
@ -492,7 +493,7 @@ public class InferredBasicValueResolver {
// Case #1 - explicit JavaType
if ( explicitJavaType != null ) {
if ( !explicitJavaType.isTemporalType() ) {
if ( !JavaTypeHelper.isTemporal( explicitJavaType ) ) {
throw new MappingException(
"Explicit JavaType [" + explicitJavaType +
"] defined for temporal value must implement TemporalJavaType"

View File

@ -47,9 +47,4 @@ public interface PluralPersistentAttribute<D, C, E>
"Plural attribute [" + getPathName() + "] is not indexed (list / map)"
);
}
@Override
default boolean checkTypeComparability() {
return false;
}
}

View File

@ -27,9 +27,4 @@ public interface TupleType<J> extends SqmExpressible<J> {
SqmExpressible<?> get(int index);
SqmExpressible<?> get(String componentName);
@Override
default boolean checkTypeComparability() {
return false;
}
}

View File

@ -60,9 +60,4 @@ public class DiscriminatorSqmPathSource<D> extends AbstractSqmPathSource<D>
public Class<D> getJavaType() {
return getExpressibleJavaType().getJavaTypeClass();
}
@Override
public boolean checkTypeComparability() {
return false;
}
}

View File

@ -2464,7 +2464,7 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
break;
}
}
((SqmCriteriaNodeBuilder) creationContext.getNodeBuilder()).assertComparable( left, right );
( (SqmCriteriaNodeBuilder) creationContext.getNodeBuilder() ).assertComparable( left, right );
return new SqmComparisonPredicate(
left,
comparisonOperator,
@ -3485,9 +3485,10 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
private static LocalTime localTime(HqlParser.TimeContext ctx) {
final int hour = Integer.parseInt( ctx.hour().getText() );
final int minute = Integer.parseInt( ctx.minute().getText() );
if ( ctx.second() != null ) {
final String secondText = ctx.second().getText();
final int index = secondText.indexOf( '.');
final HqlParser.SecondContext secondContext = ctx.second();
if ( secondContext != null ) {
final String secondText = secondContext.getText();
final int index = secondText.indexOf( '.' );
if ( index < 0 ) {
return LocalTime.of(
hour,
@ -3496,11 +3497,12 @@ public class SemanticQueryBuilder<R> extends HqlParserBaseVisitor<Object> implem
);
}
else {
final String secondFractions = secondText.substring( index + 1 );
return LocalTime.of(
hour,
minute,
Integer.parseInt( secondText.substring( 0, index ) ),
Integer.parseInt( secondText.substring( index + 1 ) )
Integer.parseInt( secondFractions ) * (int) Math.pow( 10, 9 - secondFractions.length() )
);
}
}

View File

@ -18,6 +18,7 @@ import org.hibernate.metamodel.mapping.JdbcMapping;
import org.hibernate.query.BindableType;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.TemporalJavaType;
import org.hibernate.type.spi.TypeConfiguration;
@ -41,7 +42,7 @@ public class BindingTypeHelper {
SessionFactoryImplementor sessionFactory) {
if ( precision != null ) {
final SqmExpressible<T> sqmExpressible = declaredParameterType.resolveExpressible( sessionFactory );
if ( !( sqmExpressible.getExpressibleJavaType().isTemporalType() ) ) {
if ( !( JavaTypeHelper.isTemporal( sqmExpressible.getExpressibleJavaType() ) ) ) {
throw new UnsupportedOperationException(
"Cannot treat non-temporal parameter type with temporal precision"
);
@ -64,7 +65,7 @@ public class BindingTypeHelper {
Object value,
JdbcMapping baseType,
TypeConfiguration typeConfiguration) {
if ( value == null || !baseType.getJdbcJavaType().isTemporalType() ) {
if ( value == null || !JavaTypeHelper.isTemporal( baseType.getJdbcJavaType() ) ) {
return baseType;
}

View File

@ -21,6 +21,7 @@ import org.hibernate.query.spi.QueryParameterBindingValidator;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.type.descriptor.java.CoercionException;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.TemporalJavaType;
import org.hibernate.type.spi.TypeConfiguration;
@ -290,7 +291,7 @@ public class QueryParameterBindingImpl<T> implements QueryParameterBinding<T>, J
}
private void setExplicitTemporalPrecision(TemporalType temporalTypePrecision) {
if ( bindType == null || determineJavaType( bindType ).isTemporalType() ) {
if ( bindType == null || JavaTypeHelper.isTemporal( determineJavaType( bindType ) ) ) {
this.bindType = BindingTypeHelper.INSTANCE.resolveTemporalPrecision(
temporalTypePrecision,
bindType,

View File

@ -34,8 +34,4 @@ public interface SqmExpressible<J> extends BindableType<J> {
default SqmExpressible<J> resolveExpressible(SessionFactoryImplementor sessionFactory) {
return this;
}
default boolean checkTypeComparability(){
return true;
}
}

View File

@ -45,6 +45,7 @@ import org.hibernate.metamodel.model.domain.JpaMetamodel;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.metamodel.model.domain.TupleType;
import org.hibernate.metamodel.model.domain.internal.DiscriminatorSqmPathSource;
import org.hibernate.metamodel.model.domain.internal.EmbeddedSqmPathSource;
import org.hibernate.metamodel.model.domain.spi.JpaMetamodelImplementor;
import org.hibernate.metamodel.spi.MappingMetamodelImplementor;
import org.hibernate.query.BindableType;
@ -150,6 +151,7 @@ import org.hibernate.service.ServiceRegistry;
import org.hibernate.type.BasicType;
import org.hibernate.type.StandardBasicTypes;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.spi.TypeConfiguration;
import jakarta.persistence.Tuple;
@ -166,6 +168,7 @@ import jakarta.persistence.criteria.Selection;
import jakarta.persistence.criteria.SetJoin;
import jakarta.persistence.criteria.Subquery;
import jakarta.persistence.metamodel.Bindable;
import jakarta.persistence.metamodel.EntityType;
import static java.util.Arrays.asList;
import static org.hibernate.query.internal.QueryHelper.highestPrecedenceType;
@ -234,40 +237,63 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
return sessionFactory.get();
}
public boolean areTypesComparable(SqmExpressible<?> lhsType, SqmExpressible<?> rhsType) {
if ( lhsType == null || rhsType == null || lhsType == rhsType ) {
return true;
}
if ( !lhsType.checkTypeComparability() || !rhsType.checkTypeComparability() ) {
public static boolean areTypesComparable(SqmExpressible<?> lhsType, SqmExpressible<?> rhsType) {
if ( lhsType == null || rhsType == null || lhsType == rhsType
|| isDiscriminatorComparison( lhsType, rhsType )
// Allow comparing an embeddable against a tuple literal
|| lhsType instanceof EmbeddedSqmPathSource<?> && rhsType instanceof TupleType
|| rhsType instanceof EmbeddedSqmPathSource<?> && lhsType instanceof TupleType
// Since we don't know any better, we just allow any comparison with multi-valued parameters
|| lhsType instanceof MultiValueParameterType<?>
|| rhsType instanceof MultiValueParameterType<?>) {
return true;
}
final JavaType<?> lhsJavaType = lhsType.getExpressibleJavaType();
final JavaType<?> rhsJavaType = rhsType.getExpressibleJavaType();
if ( lhsJavaType.isTemporalType() || rhsJavaType.isTemporalType() ) {
return true;
}
if ( lhsJavaType.isUnknownType() || rhsJavaType.isUnknownType() ) {
return true;
}
if ( lhsJavaType == rhsJavaType
return lhsJavaType == rhsJavaType
// If we don't know the java types, let's just be lenient
|| JavaTypeHelper.isUnknown( lhsJavaType )
|| JavaTypeHelper.isUnknown( rhsJavaType )
// Allow comparing two temporal expressions regardless of their concrete java types
|| JavaTypeHelper.isTemporal( lhsJavaType ) && JavaTypeHelper.isTemporal( rhsJavaType )
// Assume we can coerce one to another
|| lhsJavaType.isWider( rhsJavaType )
|| rhsJavaType.isWider( lhsJavaType ) ) {
// Assume we can coerce one to another
return true;
|| rhsJavaType.isWider( lhsJavaType )
// Polymorphic entity comparison
|| lhsJavaType.getJavaTypeClass().isAssignableFrom( rhsJavaType.getJavaTypeClass() )
|| rhsJavaType.getJavaTypeClass().isAssignableFrom( lhsJavaType.getJavaTypeClass() );
}
private static boolean isDiscriminatorComparison(SqmExpressible<?> lhsType, SqmExpressible<?> rhsType) {
final SqmExpressible<?> nonDiscriminator;
if ( lhsType instanceof DiscriminatorSqmPathSource<?> ) {
nonDiscriminator = rhsType;
}
else if ( rhsType instanceof DiscriminatorSqmPathSource<?> ) {
nonDiscriminator = lhsType;
}
else {
return false;
}
if ( lhsJavaType.getJavaTypeClass().isAssignableFrom( rhsJavaType.getJavaTypeClass() )
|| rhsJavaType.getJavaTypeClass().isAssignableFrom( lhsJavaType.getJavaTypeClass() ) ) {
// Polymorphic entity comparison
// Comparing the discriminator against an entity type is fine
if ( nonDiscriminator instanceof EntityType<?> ) {
return true;
}
return false;
final JavaType<?> nonDiscriminatorJavaType = nonDiscriminator.getExpressibleJavaType();
// Comparing the discriminator against the discriminator value is fine
switch ( nonDiscriminatorJavaType.getJavaTypeClass().getTypeName() ) {
case "java.lang.String":
case "char":
case "java.lang.Character":
case "int":
case "java.lang.Integer":
return true;
default:
return false;
}
}
@Override
@ -1292,11 +1318,6 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
public Class<T> getBindableJavaType() {
return javaType.getJavaTypeClass();
}
@Override
public boolean checkTypeComparability() {
return false;
}
}
@Override
@ -2070,8 +2091,8 @@ public class SqmCriteriaNodeBuilder implements NodeBuilder, SqmCreationContext,
}
public void assertComparable(Expression<?> x, Expression<?> y) {
final SqmExpressible<?> lhsType = ((SqmExpression<?>) x).getNodeType();
final SqmExpressible<?> rhsType = ((SqmExpression<?>) y).getNodeType();
final SqmExpressible<?> lhsType = ( (SqmExpression<?>) x ).getNodeType();
final SqmExpressible<?> rhsType = ( (SqmExpression<?>) y ).getNodeType();
if ( !areTypesComparable( lhsType, rhsType ) ) {
throw new IllegalArgumentException(
String.format(

View File

@ -393,6 +393,7 @@ import org.hibernate.type.descriptor.converter.internal.OrdinalEnumValueConverte
import org.hibernate.type.descriptor.converter.spi.BasicValueConverter;
import org.hibernate.type.descriptor.java.EnumJavaType;
import org.hibernate.type.descriptor.java.JavaType;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.TemporalJavaType;
import org.hibernate.type.descriptor.jdbc.JdbcType;
import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
@ -6061,7 +6062,7 @@ public abstract class BaseSqmToSqlAstConverter<T extends Statement> extends Base
private static Expression getActualExpression(Expression expression) {
if ( expression.getExpressionType() instanceof EmbeddableValuedModelPart ) {
final EmbeddableValuedModelPart embeddableValuedModelPart = (EmbeddableValuedModelPart) expression.getExpressionType();
if ( embeddableValuedModelPart.getJavaType().isTemporalType() ) {
if ( JavaTypeHelper.isTemporal( embeddableValuedModelPart.getJavaType() ) ) {
return ( (SqlTupleContainer) expression ).getSqlTuple().getExpressions().get( 0 );
}
}

View File

@ -9,6 +9,7 @@ package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.EntityDomainType;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.PathException;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.spi.NavigablePath;
/**
@ -16,15 +17,16 @@ import org.hibernate.spi.NavigablePath;
*/
public abstract class AbstractSqmSpecificPluralPartPath<T> extends AbstractSqmPath<T> implements SqmPath<T> {
private final SqmPath<?> pluralDomainPath;
private final PluralPersistentAttribute<?, ?, T> pluralAttribute;
private final PluralPersistentAttribute<?, ?, ?> pluralAttribute;
public AbstractSqmSpecificPluralPartPath(
NavigablePath navigablePath,
SqmPath<?> pluralDomainPath,
PluralPersistentAttribute<?, ?, T> referencedAttribute) {
PluralPersistentAttribute<?, ?, ?> referencedAttribute,
SqmPathSource<T> pathSource) {
super(
navigablePath,
referencedAttribute,
pathSource,
pluralDomainPath,
pluralDomainPath.nodeBuilder()
);
@ -36,7 +38,7 @@ public abstract class AbstractSqmSpecificPluralPartPath<T> extends AbstractSqmPa
return pluralDomainPath;
}
public PluralPersistentAttribute<?, ?, T> getPluralAttribute() {
public PluralPersistentAttribute<?, ?, ?> getPluralAttribute() {
return pluralAttribute;
}

View File

@ -23,7 +23,8 @@ public class SqmElementAggregateFunction<T> extends AbstractSqmSpecificPluralPar
super(
pluralDomainPath.getNavigablePath().getParent().append( pluralDomainPath.getNavigablePath().getLocalName(), "{" + functionName + "-element}" ),
pluralDomainPath,
(PluralPersistentAttribute<?, ?, T>) pluralDomainPath.getReferencedPathSource()
(PluralPersistentAttribute<?, ?, ?>) pluralDomainPath.getReferencedPathSource(),
( (PluralPersistentAttribute<?, ?, T>) pluralDomainPath.getReferencedPathSource() ).getElementPathSource()
);
this.functionName = functionName;
}
@ -60,11 +61,6 @@ public class SqmElementAggregateFunction<T> extends AbstractSqmSpecificPluralPar
return sqmPath;
}
@Override
public SqmPathSource<T> getReferencedPathSource() {
return getPluralAttribute().getElementPathSource();
}
@Override
public <X> X accept(SemanticQueryWalker<X> walker) {
return walker.visitElementAggregateFunction( this );

View File

@ -6,19 +6,16 @@
*/
package org.hibernate.query.sqm.tree.domain;
import org.hibernate.metamodel.model.domain.ListPersistentAttribute;
import org.hibernate.metamodel.model.domain.MapPersistentAttribute;
import org.hibernate.metamodel.model.domain.PluralPersistentAttribute;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.hql.spi.SqmCreationState;
import org.hibernate.query.sqm.SemanticQueryWalker;
import org.hibernate.query.sqm.SqmPathSource;
import org.hibernate.query.sqm.tree.SqmCopyContext;
/**
* @author Steve Ebersole
*/
public class SqmIndexAggregateFunction<T> extends AbstractSqmSpecificPluralPartPath<T> {
private final SqmPathSource<T> indexPathSource;
private final String functionName;
public SqmIndexAggregateFunction(SqmPath<?> pluralDomainPath, String functionName) {
@ -26,21 +23,10 @@ public class SqmIndexAggregateFunction<T> extends AbstractSqmSpecificPluralPartP
super(
pluralDomainPath.getNavigablePath().getParent().append( pluralDomainPath.getNavigablePath().getLocalName(), "{" + functionName + "-index}" ),
pluralDomainPath,
(PluralPersistentAttribute<?, ?, T>) pluralDomainPath.getReferencedPathSource()
(PluralPersistentAttribute<?, ?, ?>) pluralDomainPath.getReferencedPathSource(),
(SqmPathSource<T>) ( (PluralPersistentAttribute<?, ?, ?>) pluralDomainPath.getReferencedPathSource() ).getIndexPathSource()
);
this.functionName = functionName;
if ( getPluralAttribute() instanceof ListPersistentAttribute ) {
//noinspection unchecked
this.indexPathSource = (SqmPathSource<T>) getPluralAttribute().getIndexPathSource();
}
else if ( getPluralAttribute() instanceof MapPersistentAttribute ) {
//noinspection unchecked
this.indexPathSource = ( (MapPersistentAttribute<?, T, ?>) getPluralAttribute() ).getKeyPathSource();
}
else {
throw new UnsupportedOperationException( "Plural attribute [" + getPluralAttribute() + "] is not indexed" );
}
}
@Override
@ -75,11 +61,6 @@ public class SqmIndexAggregateFunction<T> extends AbstractSqmSpecificPluralPartP
return sqmPath;
}
@Override
public SqmPathSource<T> getReferencedPathSource() {
return indexPathSource;
}
@Override
public <X> X accept(SemanticQueryWalker<X> walker) {
return walker.visitIndexAggregateFunction( this );

View File

@ -24,6 +24,7 @@ import org.hibernate.query.sqm.NodeBuilder;
import org.hibernate.query.sqm.SqmExpressible;
import org.hibernate.query.sqm.TemporalUnit;
import org.hibernate.query.sqm.tree.domain.SqmPath;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.JdbcDateJavaType;
import org.hibernate.type.descriptor.java.JdbcTimeJavaType;
import org.hibernate.type.descriptor.java.JdbcTimestampJavaType;
@ -111,7 +112,7 @@ public class SqmExpressionHelper {
public static boolean isCompositeTemporal(SqmExpression<?> expression) {
// When TimeZoneStorageStrategy.COLUMN is used, that implies using a composite user type
return expression instanceof SqmPath<?> && expression.getNodeType() instanceof EmbeddedSqmPathSource<?>
&& expression.getJavaTypeDescriptor().isTemporalType();
&& JavaTypeHelper.isTemporal( expression.getJavaTypeDescriptor() );
}
public static SqmExpression<?> getActualExpression(SqmExpression<?> expression) {

View File

@ -63,6 +63,7 @@ public class CurrencyJavaType extends AbstractClassJavaType<Currency> {
@Override
public boolean isWider(JavaType<?> javaType) {
// This is necessary to allow comparing/assigning a currency attribute against a literal of the JdbcType
switch ( javaType.getJavaType().getTypeName() ) {
case "java.lang.String":
return true;

View File

@ -230,6 +230,7 @@ public class EnumJavaType<T extends Enum<T>> extends AbstractClassJavaType<T> {
@Override
public boolean isWider(JavaType<?> javaType) {
// This is necessary to allow comparing/assigning an enum attribute against a literal of the JdbcType
switch ( javaType.getJavaType().getTypeName() ) {
case "byte":
case "java.lang.Byte":

View File

@ -333,13 +333,4 @@ public interface JavaType<T> extends Serializable {
return false;
}
/**
* Return true if the implementation is an instance of {@link org.hibernate.type.descriptor.java.spi.UnknownBasicJavaType}
*
* @return true if it is an instance of {@link UnknownBasicJavaType}; false otherwise
*/
default boolean isUnknownType(){
return false;
}
}

View File

@ -7,6 +7,7 @@
package org.hibernate.type.descriptor.java;
import org.hibernate.HibernateException;
import org.hibernate.type.descriptor.java.spi.UnknownBasicJavaType;
/**
* @author Steve Ebersole
@ -23,4 +24,12 @@ public class JavaTypeHelper {
"Unknown wrap conversion requested: " + valueType.getName() + " to " + sourceType.getName() + " : `" + jtd.getClass().getName() + "` (" + jtd.getJavaTypeClass().getName() + ")"
);
}
public static boolean isTemporal(JavaType<?> javaType) {
return javaType != null && javaType.isTemporalType();
}
public static boolean isUnknown(JavaType<?> javaType) {
return javaType.getClass() == UnknownBasicJavaType.class;
}
}

View File

@ -18,7 +18,7 @@ import org.hibernate.type.descriptor.jdbc.JdbcTypeIndicators;
* {@link AbstractJavaType} adapter for cases where we do not know a proper
* {@link org.hibernate.type.descriptor.java.JavaType} for a given Java type.
*/
public class UnknownBasicJavaType<T> extends AbstractJavaType<T> {
public final class UnknownBasicJavaType<T> extends AbstractJavaType<T> {
public UnknownBasicJavaType(Class<T> type) {
super( type );
}
@ -76,9 +76,4 @@ public class UnknownBasicJavaType<T> extends AbstractJavaType<T> {
public String toString() {
return "BasicJavaType(" + getJavaType().getTypeName() + ")";
}
@Override
public boolean isUnknownType() {
return true;
}
}

View File

@ -23,6 +23,8 @@ import javax.xml.namespace.QName;
import org.hibernate.internal.util.ReflectHelper;
import org.hibernate.internal.util.collections.CollectionHelper;
import org.hibernate.sql.ast.spi.StringBuilderSqlAppender;
import org.hibernate.type.descriptor.java.JavaTypeHelper;
import org.hibernate.type.descriptor.java.spi.UnknownBasicJavaType;
import org.hibernate.type.format.FormatMapper;
import org.hibernate.type.descriptor.WrapperOptions;
import org.hibernate.type.descriptor.java.BasicPluralJavaType;
@ -449,7 +451,7 @@ public final class JaxbXmlFormatMapper implements FormatMapper {
.getTypeConfiguration()
.getJavaTypeRegistry()
.findDescriptor( elementClass );
if ( exampleElement == null && ( elementJavaType == null || elementJavaType.isUnknownType() ) ) {
if ( exampleElement == null && ( elementJavaType == null || JavaTypeHelper.isUnknown( elementJavaType ) ) ) {
try {
final Constructor<?> declaredConstructor = elementClass.getDeclaredConstructor();
exampleElement = declaredConstructor.newInstance();
@ -479,7 +481,7 @@ public final class JaxbXmlFormatMapper implements FormatMapper {
Object exampleElement,
JAXBIntrospector introspector,
WrapperOptions wrapperOptions) {
if ( exampleElement == null && elementJavaType.isUnknownType() ) {
if ( exampleElement == null && JavaTypeHelper.isUnknown( elementJavaType ) ) {
try {
final Constructor<?> declaredConstructor = elementJavaType.getJavaTypeClass().getDeclaredConstructor();
exampleElement = declaredConstructor.newInstance();