我已经成功地将 hibernate 自定义类型与 hibernate 和 spring 一起使用。现在我们正在为新实体使用 JPA,并希望 hibernate 仍然可以支持已定义自定义类型的旧 hbm 文件。但是我得到了同样的异常(exception)。我们所有旧的 hibernate 映射都是外部化的,但新的 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"/>
最佳答案
您可以将 .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>
这应该使它可用
关于java - jpa 2和hibernate一起+hibernate自定义类型+spring,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4391287/