• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Problems when modify JPA Object

 
Johny Trinh
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Currently, we have been developing a project with JPA.

I encountered a problems as below:

When I try to load an object from database using NamedQueries. I was success.

However I use Struts for displaying data. There are cases where I want to modify some data of the "loaded object" above.

But when I use setMethod of the Model, this change go immediately to database that i can not control.



I cannot find any way to fix this problem, could any one show me why?



With many thanks,
 
prveen dhannapuneni
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make sure changing object detached from persistence context before it modified Other wise Persistence context will merge change back to database. If you are using JPA2.0, there is method called detached() which is handy to do that job.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic