6

I'm using the org.jadira.usertype.dateandtime.joda.PersistentDateTime class from UserType 3.0.0.RC1 to map a JodaTime DateTime to Hibernate. The Javadocs for the class mention that there are 'databaseZone' and 'jvmZone' properties which I would like to set, but I cannot find anything in the UserType documentation that indicates how to do this. I found this thread which seems to imply that these are set by XML similar to the following:

<prop key="jadira.usertype.autoRegisterUserTypes">true</prop> <prop key="jadira.usertype.databaseZone">jvm</prop> 

I tried adding these to my hibernate configuration, but that just gave an error. Does anyone know where this configuration needs to go? Thanks.

2 Answers 2

4

Those settings can indeed be placed in the hibernate configuration, as like the following:

<session-factory> <!-- Database connection settings --> <property name="connection.driver_class">com.mysql.jdbc.Driver</property> <property name="connection.url">jdbc:mysql://localhost:3306/SOME_DATABASE</property> <property name="connection.username">root</property> <property name="connection.password">password</property> ... <property name="jadira.usertype.databaseZone">UTC</property> <property name="jadira.usertype.javaZone">UTC</property> </session-factory> 

Turns out I was actually referencing an old version of the UserType library by mistake, which didn't support those properties. D'oh!

Sign up to request clarification or add additional context in comments.

Comments

0

Those settings need to go into your persistence.xml.

An example is shown here

1 Comment

Thanks, but unfortunately I don't have a persistence.xml file; in the project I am working on we have got all of these properties configured in the 'session-factory' bean managed by Spring. Nice to know the alternative is there though.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.