Hibernate Annotations - Which is better, field or property access?

后端 未结 25 1524
说谎
说谎 2020-11-22 15:02

This question is somewhat related to Hibernate Annotation Placement Question.

But I want to know which is better? Access via properties or access vi

25条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 15:22

    Normally beans are POJO, so they have accessors anyway.

    So the question is not "which one is better?", but simply "when to use field access?". And the answer is "when you don't need a setter/getter for the field!".

提交回复
热议问题