jpa 2和hibernate一起+ hibernate自定义类型+ spring [英] jpa 2 and hibernate together + hibernate custom types + spring

查看:231
本文介绍了jpa 2和hibernate一起+ hibernate自定义类型+ spring的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功地使用了hibernate和spring的hibernate自定义类型。现在我们将JPA用于新实体,并希望hibernate仍然可以支持定义了自定义类型的旧hbm文件。但是我得到了同样的例外。我们所有旧的hibernate映射都是外部化的,但是新的JPA实体正在使用注释。任何帮助表示赞赏。 thx

I have been successfully using the hibernate custom type with hibernate and spring. Now we are using JPA for new entities and hoping that hibernate can still support old hbm files that have custom type defined. However I get the same exception. All of our old hibernate mappings are externalized but new JPA entities are using annotations. Any help is appreciated. thx

错误:无法确定类型:com.equifax.aspire.persistence.framework.hibernate.EmptySupportedString

Error: Could not determine type for: com.equifax.aspire.persistence.framework.hibernate.EmptySupportedString

<bean class="org.springframework.orm.jpa.support.PersistenceAnnotationBeanPostProcessor"/>

  <bean id="entityManagerFactory" class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
    <property name="persistenceXmlLocation"  value="classpath:/persistence.xml"/>
    <property name="dataSource" ref="root.platform.persistence.dataSource"/>
    <property name="jpaVendorAdapter">
      <bean class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
        <property name="showSql" value="true"/>     
        <property name="database" value="ORACLE"/>
        <property name="databasePlatform" value="org.hibernate.dialect.OracleDialect" />        
      </bean>
    </property>
   <!--<property name="loadTimeWeaver">
      <bean class="org.springframework.instrument.classloading.SimpleLoadTimeWeaver"/>
    </property> -->
  </bean> 

我在hbm文件中的自定义类型映射

My custom type mapping in hbm file

<property name="securityCode" column="SecurityCode" type="com.persistence.framework.hibernate.EmptySupportedString"/>


推荐答案

您可以将.hbm.xml文件添加到persistence.xml文件。像这样:

You can add the .hbm.xml file to the persistence.xml file. Like so:

<persistence xmlns="http://java.sun.com/xml/ns/persistence" version="1.0">
    <persistence-unit name="name">
        <provider>org.hibernate.ejb.HibernatePersistence</provider>
        <mapping-file>com/equifax/aspire/persistence/framework/hibernate/EmptySupportedString.hbm.xml</mapping-file>

应该可以使用

这篇关于jpa 2和hibernate一起+ hibernate自定义类型+ spring的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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