在迁移到Hibernate 4.3时,我遇到了一个关于在bean注入中使用Configuration类的问题。
我注入的配置类会覆盖org.hibernate.cfg.Configuration类中的某些方法,如validateSchema()
在Hibernate 3中,我在配置文件中有这个,它可以工作,因为configurationClass的get / set方法存在:
<bean id="SessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource">
<ref bean="$[DATA_SOURCE]" />
</property>
<property name="entityInterceptor">
<ref bean="entityInterceptor"/>
</property>
<property name="configurationClass">
<value>com.hibernate.cfg.CustomSchemaValidationConfiguration</value>
</property>
同时,在Hibernate 4.3中,我收到此错误,因为setConfigurationClass()方法不再存在。
Invalid property 'configurationClass' of bean class [org.springframework.orm.hibernate4.LocalSessionFactoryBean]: Bean property 'configurationClass' is not writable or has an invalid setter method. Does the parameter type of the setter match the return type of the getter?
事情就是我仍然需要/需要使用que配置类。 我在代码中看到过很多例子,但我想继续使用弹簧注入方式。它可以吗?有什么建议吗?