Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

java beans: difference between persistent field and persistent property?

I got the impression that if we use persistent fields, there is no need for getter methods since the entity manager references the instance variables directly. However, when I removed the getter and setter methods from an entity to have persistent fields, the values for the corresponding instance variable was not retrieved from the database!

Does that mean we must have getter and setter methods even though we have persistent fields?

like image 986
abracadabra Avatar asked Feb 28 '26 19:02

abracadabra


1 Answers

If the entity class uses persistence, fields Persistence accesses the entity class instance variables directly at runtime.

While on persistence property, there is a getter and a setter method for each property.

What you said should have worked on hibernate.

A link about it

like image 133
Diego Dias Avatar answered Mar 03 '26 10:03

Diego Dias



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!