Hibernate中annotation使用注解在setter和filed上的区别

2025-04-03 20:05:50
推荐回答(1个)
回答1:

If these annotations are on a field, then only fields
are considered for persistence and the state is accessed via the field. If there
annotations are on a getter, then only the getters are considered for persistence and
the state is accessed via the getter/setter. That works well in practice and is the
recommended approach.

3.6的英文文档这么说的,他这里没有用filed和property做对比,而是说,注释了字段,则直接访问字段,如果注释在getter上,则走getter和setter。并没有出现property这个概念