我正在将Spring 4.3.2项目升级到Spring 5.1.5。我的一个测试用例开始因错误而失败。
ClassNotFoundException:org.hibernate.property.DirectPropertyAccessor
这是有道理的,因为它在Spring 5.x的最低兼容Hibernate版本的Hibernate 5.x中已弃用。我在hbm.xml中使用它,如下所示:
<class name="Notification"
table="T_NOTIFICATION"
lazy="false">
<id name="id"
type="integer"
column="ID"
unsaved-value="null"
access="property">
<generator class="identity"/>
</id>
<!-- A versioned entity. -->
<version name="version"
column="VERSION"
access="org.hibernate.property.DirectPropertyAccessor"/>
我应该用什么替换访问字段以保持相同的行为?
使用access=<class-name>
你应该只使用,如果你有自己的自定义类,你要使用。如果要使用直接字段访问而不是属性,请使用access="field"
而不是现在的属性。另请参见《Hibernate参考指南》。
在内部,您的当前版本将DirectPropertyAccessor
在升级Hibernate时使用,它将自动适应新引入的其他类的使用。现在,负担由休眠承担了,而您不必了解休眠的内部API。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句