This week's book giveaway is in the Cloud forum.
We're giving away four copies of The Business Blockchain and have William Mougayar on-line!
See this thread for details.
Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Entity and set/get methods

 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a Entity which has a non-transitive property, for this property I have no set/get. If I persist this in the database I get the value for the field with no geter. That means, the entity manager does not care of setter or getter, it just "grab" the value .
the next code snippet show the entity :


After this entity is persisted in the db I have for the stuff variable the value 10. Strange because I don't have a get for.

My question is : why is doing the the jpa container this ? Is this specified in the specifications ?


Regards,
Mihai
 
Remko Strating
Ranch Hand
Posts: 893
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Because you did put the id annotation on the getter the persistence provider assumes you want to use property based persistence.
 
Mihai Radulescu
Ranch Hand
Posts: 918
IntelliJ IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your answer

I already spot this i the specification (2.2 Persistent Fields and Properties)


The persistent state of an entity is accessed by the persistence provider runtime[1] either via JavaBeans style property accessors (“property access”) or via instance variables (“field access”). Whether persistent properties or persistent fields or a combination of the two is used for the provider’s access to a given class or entity hierarchy is determined as described in Section 2.3, “Access Type”.


Regards
Mihai
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic