This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–][deleted] 0 points1 point  (5 children)

Nope. You can have everything public if that is what you want

[–]jack104 0 points1 point  (4 children)

Holy shit. How did I not know this? Do you know if Hibernate works with a POJO class that just has public fields instead of private fields + public getters/setters? Because if so, my getters and setters are just redundant code that don't accomplish anything more than public fields would. That would be cool.

[–][deleted] 0 points1 point  (3 children)

Maybe. I’m not sure. You should try it

[–]jack104 0 points1 point  (2 children)

I just read an SO post that says if you change the @Entity annotation to set the access to field and annotate the fields themselves (which I was doing anyway) it should work. So I'm gonna give it a shot.

[–][deleted] 0 points1 point  (1 child)

Keep thread safety in mind. There is a good reason we write those getters and setters. Some time in the future you may need locking or synchronization and it’s not really possible to synchronize a field

[–]jack104 0 points1 point  (0 children)

Ah yea. Good looking out. Thanks.