remove @TimeZoneColumn for now because it's unimplemented
and there's no plan to implement it for 6.0 (we can put it back later if someone gets around to implementing it)
This commit is contained in:
parent
5f1358633d
commit
475d028981
|
@ -274,7 +274,6 @@ Specifies whether to automatically quote any names that are deemed keywords.
|
||||||
Global setting for configuring the default storage for the time zone information for time zone based types.
|
Global setting for configuring the default storage for the time zone information for time zone based types.
|
||||||
+
|
+
|
||||||
`NORMALIZE`::: Does not store the time zone, and instead normalizes timestamps to UTC
|
`NORMALIZE`::: Does not store the time zone, and instead normalizes timestamps to UTC
|
||||||
`COLUMN`::: Stores the time zone in a separate column; works in conjunction with `@TimeZoneColumn`
|
|
||||||
`NATIVE`::: Stores the time zone by using the `with time zone` type. Error if `Dialect#getTimeZoneSupport()` is not `NATIVE`
|
`NATIVE`::: Stores the time zone by using the `with time zone` type. Error if `Dialect#getTimeZoneSupport()` is not `NATIVE`
|
||||||
`AUTO`::: Stores the time zone either with `NATIVE` if `Dialect#getTimeZoneSupport()` is `NATIVE`, otherwise uses the `COLUMN` strategy.
|
`AUTO`::: Stores the time zone either with `NATIVE` if `Dialect#getTimeZoneSupport()` is `NATIVE`, otherwise uses the `COLUMN` strategy.
|
||||||
+
|
+
|
||||||
|
|
|
@ -1515,7 +1515,7 @@ The `JavaType` resolved earlier is then inspected for a number of special cases.
|
||||||
still uses any explicit `JdbcType` indicators
|
still uses any explicit `JdbcType` indicators
|
||||||
. For temporal values, we check for `@Temporal` and create an enumeration mapping. Note that this resolution
|
. For temporal values, we check for `@Temporal` and create an enumeration mapping. Note that this resolution
|
||||||
still uses any explicit `JdbcType` indicators; this includes `@JdbcType` and `@JdbcTypeCode`, as well as
|
still uses any explicit `JdbcType` indicators; this includes `@JdbcType` and `@JdbcTypeCode`, as well as
|
||||||
`@TimeZoneStorage` and `@TimeZoneColumn` if appropriate.
|
`@TimeZoneStorage` if appropriate.
|
||||||
|
|
||||||
The fallback at this point is to use the `JavaType` and `JdbcType` determined in earlier steps to create a
|
The fallback at this point is to use the `JavaType` and `JdbcType` determined in earlier steps to create a
|
||||||
JDBC-mapping (which encapsulates the `JavaType` and `JdbcType`) and combines it with the resolved `MutabilityPlan`
|
JDBC-mapping (which encapsulates the `JavaType` and `JdbcType`) and combines it with the resolved `MutabilityPlan`
|
||||||
|
|
|
@ -19,10 +19,6 @@ public enum TimeZoneStorageStrategy {
|
||||||
* Stores the time zone through the "with time zone" types which retain the information.
|
* Stores the time zone through the "with time zone" types which retain the information.
|
||||||
*/
|
*/
|
||||||
NATIVE,
|
NATIVE,
|
||||||
/**
|
|
||||||
* Stores the time zone in a separate column.
|
|
||||||
*/
|
|
||||||
COLUMN,
|
|
||||||
/**
|
/**
|
||||||
* Doesn't store the time zone, but instead normalizes to UTC.
|
* Doesn't store the time zone, but instead normalizes to UTC.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
/*
|
|
||||||
* Hibernate, Relational Persistence for Idiomatic Java
|
|
||||||
*
|
|
||||||
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
|
|
||||||
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
|
|
||||||
*/
|
|
||||||
package org.hibernate.annotations;
|
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
|
||||||
import java.lang.annotation.RetentionPolicy;
|
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
import org.hibernate.Incubating;
|
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
|
|
||||||
import static java.lang.annotation.ElementType.FIELD;
|
|
||||||
import static java.lang.annotation.ElementType.METHOD;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Specifies the column name and type to use for storing the time zone information.
|
|
||||||
* The annotation can be used in conjunction with the <code>TimeZoneStorageType.AUTO</code> and
|
|
||||||
* <code>TimeZoneStorageType.COLUMN</code>. The column is simply ignored if <code>TimeZoneStorageType.AUTO</code>
|
|
||||||
* is used and the database supports native time zone storage.
|
|
||||||
*
|
|
||||||
* @author Christian Beikov
|
|
||||||
* @author Steve Ebersole
|
|
||||||
* @author Andrea Boriero
|
|
||||||
* @see TimeZoneStorage
|
|
||||||
* @see TimeZoneStorageType#COLUMN
|
|
||||||
* @see TimeZoneStorageType#AUTO
|
|
||||||
*/
|
|
||||||
@Incubating
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
|
||||||
@Target({ FIELD, METHOD })
|
|
||||||
public @interface TimeZoneColumn {
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The column for the time zone information.
|
|
||||||
*/
|
|
||||||
Column column();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The storage type for the time zone information.
|
|
||||||
*/
|
|
||||||
TimeZoneType type() default TimeZoneType.OFFSET;
|
|
||||||
|
|
||||||
}
|
|
|
@ -38,7 +38,6 @@ import static java.lang.annotation.ElementType.METHOD;
|
||||||
* @author Christian Beikov
|
* @author Christian Beikov
|
||||||
* @author Steve Ebersole
|
* @author Steve Ebersole
|
||||||
* @author Andrea Boriero
|
* @author Andrea Boriero
|
||||||
* @see TimeZoneColumn
|
|
||||||
*/
|
*/
|
||||||
@Incubating
|
@Incubating
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@ -47,5 +46,5 @@ public @interface TimeZoneStorage {
|
||||||
/**
|
/**
|
||||||
* The storage strategy for the time zone information.
|
* The storage strategy for the time zone information.
|
||||||
*/
|
*/
|
||||||
TimeZoneStorageType value() default TimeZoneStorageType.AUTO;
|
TimeZoneStorageType value();
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,18 +30,5 @@ public enum TimeZoneStorageType {
|
||||||
* Does not store the time zone, and instead normalizes
|
* Does not store the time zone, and instead normalizes
|
||||||
* timestamps to UTC.
|
* timestamps to UTC.
|
||||||
*/
|
*/
|
||||||
NORMALIZE,
|
NORMALIZE
|
||||||
/**
|
|
||||||
* Stores the time zone in a separate column; works in
|
|
||||||
* conjunction with {@link TimeZoneColumn}.
|
|
||||||
*/
|
|
||||||
COLUMN,
|
|
||||||
/**
|
|
||||||
* Stores the time zone either with {@link #NATIVE} if
|
|
||||||
* {@link Dialect#getTimeZoneSupport()} is
|
|
||||||
* {@link org.hibernate.dialect.TimeZoneSupport#NATIVE},
|
|
||||||
* otherwise uses the {@link #COLUMN} strategy.
|
|
||||||
*/
|
|
||||||
AUTO
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -918,25 +918,9 @@ public class MetadataBuilderImpl implements MetadataBuilderImplementor, TypeCont
|
||||||
}
|
}
|
||||||
resolvedTimezoneStorage = TimeZoneStorageStrategy.NATIVE;
|
resolvedTimezoneStorage = TimeZoneStorageStrategy.NATIVE;
|
||||||
break;
|
break;
|
||||||
case COLUMN:
|
|
||||||
resolvedTimezoneStorage = TimeZoneStorageStrategy.COLUMN;
|
|
||||||
break;
|
|
||||||
case NORMALIZE:
|
case NORMALIZE:
|
||||||
resolvedTimezoneStorage = TimeZoneStorageStrategy.NORMALIZE;
|
resolvedTimezoneStorage = TimeZoneStorageStrategy.NORMALIZE;
|
||||||
break;
|
break;
|
||||||
case AUTO:
|
|
||||||
switch ( timeZoneSupport ) {
|
|
||||||
case NATIVE:
|
|
||||||
resolvedTimezoneStorage = TimeZoneStorageStrategy.NATIVE;
|
|
||||||
break;
|
|
||||||
case NORMALIZE:
|
|
||||||
case NONE:
|
|
||||||
resolvedTimezoneStorage = TimeZoneStorageStrategy.COLUMN;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
throw new HibernateException( "Unsupported time zone support: " + timeZoneSupport );
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
throw new HibernateException( "Unsupported time zone storage type: " + configuredTimeZoneStorageType );
|
throw new HibernateException( "Unsupported time zone storage type: " + configuredTimeZoneStorageType );
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,8 +65,6 @@ public class VersionResolution<E> implements BasicValue.Resolution<E> {
|
||||||
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
||||||
if ( timeZoneStorageType != null ) {
|
if ( timeZoneStorageType != null ) {
|
||||||
switch ( timeZoneStorageType ) {
|
switch ( timeZoneStorageType ) {
|
||||||
case COLUMN:
|
|
||||||
return TimeZoneStorageStrategy.COLUMN;
|
|
||||||
case NATIVE:
|
case NATIVE:
|
||||||
return TimeZoneStorageStrategy.NATIVE;
|
return TimeZoneStorageStrategy.NATIVE;
|
||||||
case NORMALIZE:
|
case NORMALIZE:
|
||||||
|
|
|
@ -7,7 +7,6 @@
|
||||||
package org.hibernate.cfg.annotations;
|
package org.hibernate.cfg.annotations;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.lang.annotation.Annotation;
|
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -18,7 +17,6 @@ import java.util.function.Function;
|
||||||
import org.hibernate.AnnotationException;
|
import org.hibernate.AnnotationException;
|
||||||
import org.hibernate.AssertionFailure;
|
import org.hibernate.AssertionFailure;
|
||||||
import org.hibernate.MappingException;
|
import org.hibernate.MappingException;
|
||||||
import org.hibernate.NotYetImplementedFor6Exception;
|
|
||||||
import org.hibernate.TimeZoneStorageStrategy;
|
import org.hibernate.TimeZoneStorageStrategy;
|
||||||
import org.hibernate.annotations.AnyDiscriminator;
|
import org.hibernate.annotations.AnyDiscriminator;
|
||||||
import org.hibernate.annotations.AnyKeyJavaClass;
|
import org.hibernate.annotations.AnyKeyJavaClass;
|
||||||
|
@ -46,10 +44,8 @@ import org.hibernate.annotations.Mutability;
|
||||||
import org.hibernate.annotations.Nationalized;
|
import org.hibernate.annotations.Nationalized;
|
||||||
import org.hibernate.annotations.Parameter;
|
import org.hibernate.annotations.Parameter;
|
||||||
import org.hibernate.annotations.Target;
|
import org.hibernate.annotations.Target;
|
||||||
import org.hibernate.annotations.TimeZoneColumn;
|
|
||||||
import org.hibernate.annotations.TimeZoneStorage;
|
import org.hibernate.annotations.TimeZoneStorage;
|
||||||
import org.hibernate.annotations.TimeZoneStorageType;
|
import org.hibernate.annotations.TimeZoneStorageType;
|
||||||
import org.hibernate.annotations.TimeZoneType;
|
|
||||||
import org.hibernate.annotations.common.reflection.XClass;
|
import org.hibernate.annotations.common.reflection.XClass;
|
||||||
import org.hibernate.annotations.common.reflection.XProperty;
|
import org.hibernate.annotations.common.reflection.XProperty;
|
||||||
import org.hibernate.boot.model.TypeDefinition;
|
import org.hibernate.boot.model.TypeDefinition;
|
||||||
|
@ -62,7 +58,6 @@ import org.hibernate.cfg.PkDrivenByDefaultMapsIdSecondPass;
|
||||||
import org.hibernate.cfg.SetBasicValueTypeSecondPass;
|
import org.hibernate.cfg.SetBasicValueTypeSecondPass;
|
||||||
import org.hibernate.dialect.Dialect;
|
import org.hibernate.dialect.Dialect;
|
||||||
import org.hibernate.dialect.NationalizationSupport;
|
import org.hibernate.dialect.NationalizationSupport;
|
||||||
import org.hibernate.dialect.TimeZoneSupport;
|
|
||||||
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
import org.hibernate.engine.jdbc.spi.JdbcServices;
|
||||||
import org.hibernate.internal.CoreMessageLogger;
|
import org.hibernate.internal.CoreMessageLogger;
|
||||||
import org.hibernate.internal.util.ReflectHelper;
|
import org.hibernate.internal.util.ReflectHelper;
|
||||||
|
@ -84,7 +79,6 @@ import org.hibernate.usertype.UserType;
|
||||||
|
|
||||||
import org.jboss.logging.Logger;
|
import org.jboss.logging.Logger;
|
||||||
|
|
||||||
import jakarta.persistence.Column;
|
|
||||||
import jakarta.persistence.ElementCollection;
|
import jakarta.persistence.ElementCollection;
|
||||||
import jakarta.persistence.EnumType;
|
import jakarta.persistence.EnumType;
|
||||||
import jakarta.persistence.Enumerated;
|
import jakarta.persistence.Enumerated;
|
||||||
|
@ -184,8 +178,6 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
||||||
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
||||||
if ( timeZoneStorageType != null ) {
|
if ( timeZoneStorageType != null ) {
|
||||||
switch ( timeZoneStorageType ) {
|
switch ( timeZoneStorageType ) {
|
||||||
case COLUMN:
|
|
||||||
return TimeZoneStorageStrategy.COLUMN;
|
|
||||||
case NATIVE:
|
case NATIVE:
|
||||||
return TimeZoneStorageStrategy.NATIVE;
|
return TimeZoneStorageStrategy.NATIVE;
|
||||||
case NORMALIZE:
|
case NORMALIZE:
|
||||||
|
@ -663,105 +655,7 @@ public class BasicValueBinder<T> implements JdbcTypeIndicators {
|
||||||
}
|
}
|
||||||
|
|
||||||
final TimeZoneStorage timeZoneStorageAnn = attributeXProperty.getAnnotation( TimeZoneStorage.class );
|
final TimeZoneStorage timeZoneStorageAnn = attributeXProperty.getAnnotation( TimeZoneStorage.class );
|
||||||
if ( timeZoneStorageAnn != null ) {
|
timeZoneStorageType = timeZoneStorageAnn != null ? timeZoneStorageAnn.value() : null;
|
||||||
timeZoneStorageType = timeZoneStorageAnn.value();
|
|
||||||
final TimeZoneColumn timeZoneColumnAnn = attributeXProperty.getAnnotation( TimeZoneColumn.class );
|
|
||||||
final Column column;
|
|
||||||
final TimeZoneType type;
|
|
||||||
if ( timeZoneColumnAnn != null ) {
|
|
||||||
column = timeZoneColumnAnn.column();
|
|
||||||
type = timeZoneColumnAnn.type();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
switch ( timeZoneStorageType ) {
|
|
||||||
case AUTO:
|
|
||||||
if ( getDialect().getTimeZoneSupport() == TimeZoneSupport.NATIVE ) {
|
|
||||||
column = null;
|
|
||||||
type = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case COLUMN:
|
|
||||||
final String timeZoneColumnName = columns[0].getName() + "_tz";
|
|
||||||
column = new Column() {
|
|
||||||
@Override
|
|
||||||
public String name() {
|
|
||||||
return timeZoneColumnName;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean unique() {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean nullable() {
|
|
||||||
return columns[0].isNullable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean insertable() {
|
|
||||||
return columns[0].isInsertable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean updatable() {
|
|
||||||
return columns[0].isUpdatable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String columnDefinition() {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String table() {
|
|
||||||
return columns[0].getExplicitTableName();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int length() {
|
|
||||||
return 255;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int precision() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int scale() {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class<? extends Annotation> annotationType() {
|
|
||||||
return Column.class;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
type = TimeZoneType.OFFSET;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
column = null;
|
|
||||||
type = null;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ( column != null ) {
|
|
||||||
// todo (6.0): do something with the column
|
|
||||||
// maybe move this to AnnotationBinder#2266 and make it treat the property as composite for the COLUMN strategy
|
|
||||||
throw new NotYetImplementedFor6Exception("TimeZoneColumn support is not yet implemented!");
|
|
||||||
}
|
|
||||||
else if ( timeZoneColumnAnn != null ) {
|
|
||||||
throw new IllegalStateException(
|
|
||||||
"@TimeZoneColumn can not be used in conjunction with @TimeZoneStorage( " + timeZoneStorageType +
|
|
||||||
" ) with attribute " + attributeXProperty.getDeclaringClass().getName() +
|
|
||||||
'.' + attributeXProperty.getName()
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
timeZoneStorageType = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
normalSupplementalDetails( attributeXProperty);
|
normalSupplementalDetails( attributeXProperty);
|
||||||
|
|
||||||
|
|
|
@ -650,8 +650,6 @@ public class BasicValue extends SimpleValue implements JdbcTypeIndicators, Resol
|
||||||
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
public TimeZoneStorageStrategy getDefaultTimeZoneStorageStrategy() {
|
||||||
if ( timeZoneStorageType != null ) {
|
if ( timeZoneStorageType != null ) {
|
||||||
switch ( timeZoneStorageType ) {
|
switch ( timeZoneStorageType ) {
|
||||||
case COLUMN:
|
|
||||||
return TimeZoneStorageStrategy.COLUMN;
|
|
||||||
case NATIVE:
|
case NATIVE:
|
||||||
return TimeZoneStorageStrategy.NATIVE;
|
return TimeZoneStorageStrategy.NATIVE;
|
||||||
case NORMALIZE:
|
case NORMALIZE:
|
||||||
|
|
Loading…
Reference in New Issue