UserType / Hibernate / JodaTime - where to set global properties of UserType?

I am using the org.jadira.usertype.dateandtime.joda.PersistentDateTime class from UserType 3.0.0.RC1 to map the JodaTime DateTime to Hibernate. In the Javadocs for the class, the 'databaseZone' and 'jvmZone' properties are mentioned, which I would like to set, but I cannot find anything in the UserType Documentation that tells how to do this. I found this thread , which apparently implies that they are defined by XML as follows:

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

I tried adding them to my hibernation configuration, but this just gave an error. Does anyone know where this configuration should go? Thanks.

+6
source share
2 answers

These settings can indeed be placed in a sleep configuration, as shown below:

 <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> 

It turns out that I mistakenly referred to an old version of the UserType library that did not support these properties. D'o!

+4
source

These settings should go into your persistence.xml .

An example is shown here.

0
source

Source: https://habr.com/ru/post/915441/


All Articles