• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating POJO with Hibernate

 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am using hibernate 3 for persistence layer.
Let's say i have an Account POJO which has all the information (userID, pwd, address,...) about the user account. If i want to update a single attribute
I am currently doing:

Does hibernate issue an update statement just for password? or does it update (with old values) all the fields in the database?

Thanks,
Srikanth.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Does hibernate issue an update statement just for password? or does it update (with old values) all the fields in the database?

It will update all the values with whatever state they have.
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
it will update all the fields but, you could set to only update the changed fields with the attributes dynamic-insert or dynamic-update. Here it's the reference http://www.hibernate.org/hib_docs/reference/en/html_single/#mapping-declaration-class

regards
 
Saathvik Reddy
Ranch Hand
Posts: 228
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Angel Taveras wrote:it will update all the fields but, you could set to only update the changed fields with the attributes dynamic-insert or dynamic-update. Here it's the reference http://www.hibernate.org/hib_docs/reference/en/html_single/#mapping-declaration-class

regards


I am using JPA so i don't have access to the hibernate mapping files. How can we set the attributes to dynamic-update programatically?

Thanks in advance
 
Angel Taveras
Ranch Hand
Posts: 84
Eclipse IDE Hibernate Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
with @org.hibernate.annotations.Entity and it's attributes dynamicInsert, dynamicUpdate. Remeber that this it's not a replacement for @javax.persistence.Entity, because is still mandatory.

regards
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic