mirror of
https://github.com/hibernate/hibernate-orm
synced 2025-02-28 06:49:09 +00:00
extremely minor cleanups to type descriptors
This commit is contained in:
parent
e83008e75d
commit
dfc282adb1
@ -22,7 +22,6 @@
|
||||
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;
|
||||
|
||||
import jakarta.persistence.TemporalType;
|
||||
@ -118,7 +117,7 @@ else if ( queryParameter.getHibernateType() != null ) {
|
||||
catch (CoercionException ce) {
|
||||
throw new IllegalArgumentException(
|
||||
String.format(
|
||||
"Parameter value [%s] did not match expected type [%s ]",
|
||||
"Parameter value [%s] did not match expected type [%s]",
|
||||
value,
|
||||
bindType
|
||||
),
|
||||
|
@ -13,7 +13,6 @@
|
||||
import org.hibernate.query.sqm.tree.AbstractSqmNode;
|
||||
import org.hibernate.query.sqm.tree.SqmCopyContext;
|
||||
import org.hibernate.query.sqm.tree.SqmTypedNode;
|
||||
import org.hibernate.query.sqm.tree.SqmVisitableNode;
|
||||
|
||||
|
||||
/**
|
||||
@ -81,12 +80,12 @@ public ReturnableType<T> getType() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> T accept(SemanticQueryWalker<T> walker) {
|
||||
public <X> X accept(SemanticQueryWalker<X> walker) {
|
||||
return walker.visitCastTarget(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SqmExpressible getNodeType() {
|
||||
public SqmExpressible<T> getNodeType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
|
@ -44,10 +44,12 @@ public BooleanJavaType(char characterValueTrue, char characterValueFalse) {
|
||||
stringValueTrue = String.valueOf( characterValueTrue );
|
||||
stringValueFalse = String.valueOf( characterValueFalse );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Boolean value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean fromString(CharSequence string) {
|
||||
return Boolean.valueOf( string.toString() );
|
||||
@ -95,6 +97,7 @@ public <X> X unwrap(Boolean value, Class<X> type, WrapperOptions options) {
|
||||
}
|
||||
throw unknownUnwrap( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> Boolean wrap(X value, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
@ -117,10 +120,7 @@ public <X> Boolean wrap(X value, WrapperOptions options) {
|
||||
}
|
||||
|
||||
private boolean isTrue(String strValue) {
|
||||
if (strValue != null && !strValue.isEmpty()) {
|
||||
return isTrue(strValue.charAt(0));
|
||||
}
|
||||
return false;
|
||||
return strValue != null && !strValue.isEmpty() && isTrue( strValue.charAt(0) );
|
||||
}
|
||||
|
||||
private boolean isTrue(char charValue) {
|
||||
|
@ -35,6 +35,7 @@ public ByteJavaType() {
|
||||
public String toString(Byte value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte fromString(CharSequence string) {
|
||||
return Byte.valueOf( string.toString() );
|
||||
@ -175,6 +176,7 @@ public <X> Byte coerce(X value, CoercionContext coercionContext) {
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Byte next(
|
||||
Byte current,
|
||||
@ -188,7 +190,9 @@ public Byte next(
|
||||
@Override
|
||||
public Byte seed(
|
||||
Long length,
|
||||
Integer precision, Integer scale, SharedSessionContractImplementor session) {
|
||||
Integer precision,
|
||||
Integer scale,
|
||||
SharedSessionContractImplementor session) {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
|
@ -42,21 +42,18 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.DATE );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarTimeJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -51,21 +51,18 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.TIMESTAMP );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarDateJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarTimeJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -42,21 +42,18 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.TIME );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) CalendarDateJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -24,6 +24,7 @@ public class CharacterJavaType extends AbstractClassJavaType<Character> implemen
|
||||
public CharacterJavaType() {
|
||||
super( Character.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Character value) {
|
||||
return value.toString();
|
||||
@ -50,10 +51,11 @@ public <X> X unwrap(Character value, Class<X> type, WrapperOptions options) {
|
||||
return (X) value.toString();
|
||||
}
|
||||
if ( Number.class.isAssignableFrom( type ) ) {
|
||||
return (X) Short.valueOf( (short)value.charValue() );
|
||||
return (X) Short.valueOf( (short) value.charValue() );
|
||||
}
|
||||
throw unknownUnwrap( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> Character wrap(X value, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
@ -77,7 +79,7 @@ public <X> Character wrap(X value, WrapperOptions options) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
public Class<?> getPrimitiveClass() {
|
||||
return char.class;
|
||||
}
|
||||
|
||||
|
@ -60,21 +60,18 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.TIMESTAMP );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) JdbcDateJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) JdbcTimestampJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) JdbcTimeJavaType.INSTANCE;
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,7 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
|
||||
public String toString(Double value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Double fromString(CharSequence string) {
|
||||
return Double.valueOf( string.toString() );
|
||||
@ -79,6 +80,7 @@ public <X> X unwrap(Double value, Class<X> type, WrapperOptions options) {
|
||||
}
|
||||
throw unknownUnwrap( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> Double wrap(X value, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
@ -117,9 +119,8 @@ public boolean isWider(JavaType<?> javaType) {
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("rawtypes")
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
public Class<?> getPrimitiveClass() {
|
||||
return double.class;
|
||||
}
|
||||
|
||||
|
@ -38,6 +38,7 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators indicators) {
|
||||
public String toString(Float value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Float fromString(CharSequence string) {
|
||||
return Float.valueOf( string.toString() );
|
||||
@ -78,6 +79,7 @@ public <X> X unwrap(Float value, Class<X> type, WrapperOptions options) {
|
||||
}
|
||||
throw unknownUnwrap( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> Float wrap(X value, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
@ -115,7 +117,7 @@ public boolean isWider(JavaType<?> javaType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
public Class<?> getPrimitiveClass() {
|
||||
return float.class;
|
||||
}
|
||||
|
||||
|
@ -47,21 +47,18 @@ public TemporalType getPrecision() {
|
||||
return TemporalType.TIMESTAMP;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimePrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,12 @@ public class IntegerJavaType extends AbstractClassJavaType<Integer>
|
||||
public IntegerJavaType() {
|
||||
super( Integer.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Integer value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer fromString(CharSequence string) {
|
||||
return string == null ? null : Integer.valueOf( string.toString() );
|
||||
@ -87,7 +89,7 @@ public <X> Integer wrap(X value, WrapperOptions options) {
|
||||
return ( (Number) value ).intValue();
|
||||
}
|
||||
if (value instanceof String) {
|
||||
return Integer.valueOf( ( (String) value ) );
|
||||
return Integer.valueOf( (String) value );
|
||||
}
|
||||
throw unknownWrap( value.getClass() );
|
||||
}
|
||||
@ -106,7 +108,7 @@ public boolean isWider(JavaType<?> javaType) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
public Class<?> getPrimitiveClass() {
|
||||
return int.class;
|
||||
}
|
||||
|
||||
@ -195,8 +197,7 @@ public Integer coerce(Object value, CoercionContext coercionContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer seed(
|
||||
Long length, Integer precision, Integer scale, SharedSessionContractImplementor session) {
|
||||
public Integer seed(Long length, Integer precision, Integer scale, SharedSessionContractImplementor session) {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
@ -205,7 +206,8 @@ public Integer next(
|
||||
Integer current,
|
||||
Long length,
|
||||
Integer precision,
|
||||
Integer scale, SharedSessionContractImplementor session) {
|
||||
Integer scale,
|
||||
SharedSessionContractImplementor session) {
|
||||
return current + 1;
|
||||
}
|
||||
|
||||
|
@ -258,13 +258,12 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.TIMESTAMP );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forDatePrecision(TypeConfiguration typeConfiguration) {
|
||||
return (TemporalJavaType<X>) JdbcDateJavaType.INSTANCE;
|
||||
}
|
||||
|
@ -51,9 +51,8 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators context) {
|
||||
return context.getJdbcType( Types.TIMESTAMP );
|
||||
}
|
||||
|
||||
@Override
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
//noinspection unchecked
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,12 @@ public class LongJavaType extends AbstractClassJavaType<Long>
|
||||
public LongJavaType() {
|
||||
super( Long.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Long value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long fromString(CharSequence string) {
|
||||
return Long.valueOf( string.toString() );
|
||||
@ -162,7 +164,7 @@ public <X> Long coerce(X value, CoercionContext coercionContext) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class getPrimitiveClass() {
|
||||
public Class<?> getPrimitiveClass() {
|
||||
return long.class;
|
||||
}
|
||||
|
||||
@ -209,7 +211,9 @@ public Long next(
|
||||
@Override
|
||||
public Long seed(
|
||||
Long length,
|
||||
Integer precision, Integer scale, SharedSessionContractImplementor session) {
|
||||
Integer precision,
|
||||
Integer scale,
|
||||
SharedSessionContractImplementor session) {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
|
@ -73,8 +73,7 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators stdIndicators) {
|
||||
.getDescriptor( stdIndicators.getDefaultZonedTimestampSqlType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
@ -29,10 +29,12 @@ public class ShortJavaType extends AbstractClassJavaType<Short>
|
||||
public ShortJavaType() {
|
||||
super( Short.class );
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString(Short value) {
|
||||
return value == null ? null : value.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Short fromString(CharSequence string) {
|
||||
return Short.valueOf( string.toString() );
|
||||
@ -78,6 +80,7 @@ public <X> X unwrap(Short value, Class<X> type, WrapperOptions options) {
|
||||
}
|
||||
throw unknownUnwrap( type );
|
||||
}
|
||||
|
||||
@Override
|
||||
public <X> Short wrap(X value, WrapperOptions options) {
|
||||
if ( value == null ) {
|
||||
@ -186,7 +189,9 @@ public Short coerce(Object value, CoercionContext coercionContext) {
|
||||
@Override
|
||||
public Short seed(
|
||||
Long length,
|
||||
Integer precision, Integer scale, SharedSessionContractImplementor session) {
|
||||
Integer precision,
|
||||
Integer scale,
|
||||
SharedSessionContractImplementor session) {
|
||||
return ZERO;
|
||||
}
|
||||
|
||||
|
@ -54,8 +54,7 @@ public JdbcType getRecommendedJdbcType(JdbcTypeIndicators stdIndicators) {
|
||||
.getDescriptor( stdIndicators.getDefaultZonedTimestampSqlType() );
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("unchecked")
|
||||
@Override @SuppressWarnings("unchecked")
|
||||
protected <X> TemporalJavaType<X> forTimestampPrecision(TypeConfiguration typeConfiguration) {
|
||||
return (TemporalJavaType<X>) this;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user