UserType / Hibernate / JodaMoney错误:PersistentMoneyAmount需要将currencyCode定义为参数 [英] UserType / Hibernate / JodaMoney error : PersistentMoneyAmount requires currencyCode to be defined as a parameter

查看:465
本文介绍了UserType / Hibernate / JodaMoney错误:PersistentMoneyAmount需要将currencyCode定义为参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



当SessionFactory初始化时,我遇到了一个错误:

我使用UserType 3.0.0.RC1将JodaMoney映射到Hibernate。
$ b


PersistentMoneyAmount要求currencyCode被定义为
参数,或者定义defaultCurrencyCode Hibernate属性
blockquote>

我确定我必须有一些配置问题 - 这里是相关的片段。



Persistence.xml:

 < persistence-unit name =spring-jpa> 
<属性>
< property name =hibernate.format_sqlvalue =true/>
< property name =hibernate.hbm2ddl.autovalue =update/>
< property name =jadira.usertype.autoRegisterUserTypesvalue =true/>
< / properties>
< / persistence-unit>

相关的弹簧配置:

 < bean id =entityManagerFactory
class =org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean>
< property name =dataSourceref =dataSource/>
< property name =packagesToScan>
< list>
<值> com.mangofactory.concorde< /值>
<值> com.mangofactory.moolah< /值>
< / list>
< / property>
< property name =persistenceUnitNamevalue =spring-jpa/>
< property name =jpaVendorAdapter>
< bean class =org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter>
< property name =showSqlvalue =true/>
< property name =databasePlatformvalue =org.hibernate.dialect.MySQLDialect/>
< / bean>
< / property>
< / bean>

提示我缺少什么?

解决方案

最后,我在 persistence.xml 中使用以下配置来解决此问题:

 < persistence-unit name =spring-jpa> 
<属性>
< property name =hibernate.format_sqlvalue =true/>
< property name =hibernate.hbm2ddl.autovalue =update/>
< property name =jadira.usertype.autoRegisterUserTypesvalue =true/>
< property name =jadira.usertype.currencyCodevalue =AUD/>
< property name =jadira.usertype.seedvalue =org.jadira.usertype.spi.shared.JvmTimestampSeed/>
< / properties>
< / persistence-unit>

棘手的部分是我需要提供 jadira.usertype.seed 为了检测 jadira.usertype.currencyCode


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.

这篇关于UserType / Hibernate / JodaMoney错误:PersistentMoneyAmount需要将currencyCode定义为参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆