use of org.hibernate.annotations.TimeZoneStorageType in project hibernate-orm by hibernate.
the class MetadataBuilderImpl method resolveTimeZoneStorageStrategy.
private static TimeZoneStorageStrategy resolveTimeZoneStorageStrategy(StandardServiceRegistry serviceRegistry, ConfigurationService configService) {
final TimeZoneStorageType configuredTimeZoneStorageType = configService.getSetting(AvailableSettings.TIMEZONE_DEFAULT_STORAGE, TimeZoneStorageType.class, null);
final TimeZoneStorageStrategy resolvedTimezoneStorage;
// For now, we default to NORMALIZE as that is the Hibernate 5.x behavior
if (configuredTimeZoneStorageType == null) {
resolvedTimezoneStorage = TimeZoneStorageStrategy.NORMALIZE;
} else {
final TimeZoneSupport timeZoneSupport = serviceRegistry.getService(JdbcServices.class).getDialect().getTimeZoneSupport();
switch(configuredTimeZoneStorageType) {
case NATIVE:
if (timeZoneSupport != TimeZoneSupport.NATIVE) {
throw new HibernateException("The configured time zone storage type NATIVE is not supported with the configured dialect");
}
resolvedTimezoneStorage = TimeZoneStorageStrategy.NATIVE;
break;
case NORMALIZE:
resolvedTimezoneStorage = TimeZoneStorageStrategy.NORMALIZE;
break;
default:
throw new HibernateException("Unsupported time zone storage type: " + configuredTimeZoneStorageType);
}
}
return resolvedTimezoneStorage;
}
Aggregations