【问题标题】:jpa 2 and hibernate together + hibernate custom types + springjpa 2 和 hibernate 一起 + hibernate 自定义类型 + spring
【发布时间】:2010-12-08 19:11:13
【问题描述】:

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

错误:无法确定类型: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 文件中的自定义类型映射

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

【问题讨论】:

    标签: java hibernate spring jpa jakarta-ee


    【解决方案1】:

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

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

    这应该使它可用

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-05-17
      • 1970-01-01
      • 2019-07-20
      • 1970-01-01
      • 1970-01-01
      • 2017-05-10
      • 2023-04-08
      相关资源
      最近更新 更多