I'm using UserType 3.0.0.RC1 to map JodaMoney to Hibernate.
I'm stuck with an error when the SessionFactory initialises:
PersistentMoneyAmount requires currencyCode to be defined as a parameter, or the defaultCurrencyCode Hibernate property to be defined
I'm sure I must have some configuration issue — here's the relevant snippets.
Persistence.xml:
<persistence-unit name="spring-jpa">
<properties>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="jadira.usertype.autoRegisterUserTypes" value="true"/>
</properties>
</persistence-unit>
The relevant spring config:
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="packagesToScan">
<list>
<value>com.mangofactory.concorde</value>
<value>com.mangofactory.moolah</value>
</list>
</property>
<property name="persistenceUnitName" value="spring-jpa" />
<property name="jpaVendorAdapter">
<bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="showSql" value="true" />
<property name="databasePlatform" value="org.hibernate.dialect.MySQLDialect" />
</bean>
</property>
</bean>
Any tips on what I'm missing?
I ended up solving this using the following configuration in my persistence.xml
:
<persistence-unit name="spring-jpa">
<properties>
<property name="hibernate.format_sql" value="true"/>
<property name="hibernate.hbm2ddl.auto" value="update"/>
<property name="jadira.usertype.autoRegisterUserTypes" value="true"/>
<property name="jadira.usertype.currencyCode" value="AUD"/>
<property name="jadira.usertype.seed" value="org.jadira.usertype.spi.shared.JvmTimestampSeed"/>
</properties>
</persistence-unit>
The tricky part is that I needed to provide a jadira.usertype.seed
in order for the jadira.usertype.currencyCode
to be detected.