JadiraOrg / jadira

Jadira Framework
Apache License 2.0
74 stars 44 forks source link

org.jadira.usertype.dateandtime.threetenbp.PersistentZonedDateTime databaseZone and javaZone #42

Closed mrubezhanskyy closed 9 years ago

mrubezhanskyy commented 9 years ago

I cannot use any timezone like Europe/Berlin here because used org.jadira.usertype.dateandtime.threeten.columnmapper.TimestampColumnZonedDateTimeMapper#parseZone() calls ZoneOffset.of(zoneString) instead of DateTimeZone.forID(zoneString) or something else and it causes exception listed below.

Offset has another meaning and cannot replace timezone. For instance for Zone Europe/Berlin there are two possible offsets +0200 in summer and +0100 in winter.

Usage:

@Type(type = "org.jadira.usertype.dateandtime.threeten.PersistentZonedDateTime",
        parameters = { @org.hibernate.annotations.Parameter(name = "databaseZone", value = "Europe/Berlin"),
                @org.hibernate.annotations.Parameter(name = "javaZone", value = "Europe/Berlin")})
public ZonedDateTime get......() {
    return ...;
}

StackTrace:

Caused by: java.time.DateTimeException: Invalid ID for ZoneOffset, invalid format: Europe/Berlin at java.time.ZoneOffset.of(ZoneOffset.java:241) at org.jadira.usertype.dateandtime.threeten.columnmapper.TimestampColumnZonedDateTimeMapper.parseZone(TimestampColumnZonedDateTimeMapper.java:90) at org.jadira.usertype.dateandtime.threeten.columnmapper.TimestampColumnZonedDateTimeMapper.parseZone(TimestampColumnZonedDateTimeMapper.java:34) at org.jadira.usertype.spi.shared.AbstractParameterizedUserType.performDatabaseZoneConfiguration(AbstractParameterizedUserType.java:97) at org.jadira.usertype.spi.shared.AbstractParameterizedUserType.doApplyConfiguration(AbstractParameterizedUserType.java:71) at org.jadira.usertype.spi.shared.AbstractParameterizedUserType.applyConfiguration(AbstractParameterizedUserType.java:42) at org.jadira.usertype.spi.shared.AbstractVersionableUserType.applyConfiguration(AbstractVersionableUserType.java:36) at org.jadira.usertype.spi.shared.AbstractUserType.beforeNullSafeOperation(AbstractUserType.java:87) at org.jadira.usertype.spi.shared.AbstractSingleColumnUserType.nullSafeGet(AbstractSingleColumnUserType.java:67) at org.hibernate.type.CustomType.nullSafeGet(CustomType.java:127) at org.hibernate.type.AbstractType.hydrate(AbstractType.java:106) at org.hibernate.persister.entity.AbstractEntityPersister.hydrate(AbstractEntityPersister.java:2924) at org.hibernate.loader.Loader.loadFromResultSet(Loader.java:1695) at org.hibernate.loader.Loader.instanceNotYetLoaded(Loader.java:1627) at org.hibernate.loader.Loader.getRow(Loader.java:1509) at org.hibernate.loader.Loader.getRowFromResultSet(Loader.java:719) at org.hibernate.loader.Loader.processResultSet(Loader.java:949) at org.hibernate.loader.Loader.doQuery(Loader.java:917) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:348) at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:318) at org.hibernate.loader.Loader.loadEntity(Loader.java:2145) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:82) at org.hibernate.loader.entity.AbstractEntityLoader.load(AbstractEntityLoader.java:72) at org.hibernate.persister.entity.AbstractEntityPersister.load(AbstractEntityPersister.java:3939) at org.hibernate.event.internal.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:462) at org.hibernate.event.internal.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:431) at org.hibernate.event.internal.DefaultLoadEventListener.load(DefaultLoadEventListener.java:208) at org.hibernate.event.internal.DefaultLoadEventListener.proxyOrLoad(DefaultLoadEventListener.java:264) at org.hibernate.event.internal.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:152) at org.hibernate.internal.SessionImpl.fireLoad(SessionImpl.java:1017) at org.hibernate.internal.SessionImpl.access$2000(SessionImpl.java:173) at org.hibernate.internal.SessionImpl$IdentifierLoadAccessImpl.load(SessionImpl.java:2413) at org.hibernate.internal.SessionImpl.get(SessionImpl.java:913) at ...................common.tools.dao.hibernate.Hibernate4FindDAOImpl.findById(Hibernate4FindDAOImpl.java:89)

chrisphe commented 9 years ago

Please review