本文介绍了UserType / Hibernate / JodaMoney错误:PersistentMoneyAmount需要将currencyCode定义为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当SessionFactory初始化时,我遇到了一个错误:
我使用UserType 3.0.0.RC1将JodaMoney映射到Hibernate。
$ b
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.
这篇关于UserType / Hibernate / JodaMoney错误:PersistentMoneyAmount需要将currencyCode定义为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!