[Logo]
Forums Register Login
annotations on getter methods in entity class - why?
Copying this entity (not entity bean) from: http://java.sun.com/developer/technicalArticles/J2EE/intro_ee5/



I am just wondering that they are putting annotations (id, many to one etc) on getter methods. Why???

Isn't it better and cleaner to put these kind of annotations on variable (instead of methods)?

What's say?

Thanks.
You can put annotations on either field level OR method level. Most developers prefer annotating getter methods because otherwise method level annotations are overridden.
Sie also this blog.

Lars
Enjoy the full beauty of the english language. Embedded in this tiny ad:
ScroogeXHTML 7.1 - RTF to HTML5 / XHTML converter
https://coderanch.com/t/690611/ScroogeXHTML-RTF-HTML-XHTML-converter


This thread has been viewed 607 times.

All times above are in ranch (not your local) time.
The current ranch time is
Feb 18, 2018 00:22:31.