| Author |
Updating an entity object without loading the same
|
Keerthi Kumar Narayan
Greenhorn
Joined: Feb 01, 2013
Posts: 2
|
|
Dear All,
Im quite new to JPA. I have a requirement where i need to create a plan and update whenever required. In the current implementation, to update a plan, that plan will be reloaded first and then set or update to the required values and persist it. So, is there any way in JPA to update the plan directly without loading it from the database?
Thanks in advance.
Regards,
Keerthi Kumar N
|
 |
James Sutherland
Ranch Hand
Joined: Oct 01, 2007
Posts: 550
|
|
Reading the object, then updating it is normally the best way to update an object, and ensure correct versioning/locking, caching and consistency.
You can also issue a direct update in JPQL using an UPDATE query,
See, http://en.wikibooks.org/wiki/Java_Persistence/Querying#Update_and_Delete_Queries
|
TopLink : EclipseLink : Book:Java Persistence : Blog:Java Persistence Performance
|
 |
Keerthi Kumar Narayan
Greenhorn
Joined: Feb 01, 2013
Posts: 2
|
|
|
But, here the problem is that i need to update not a single entity. Need to update hierarchy of entities.. Any idea how to achieve this?
|
 |
 |
|
|
subject: Updating an entity object without loading the same
|
|
|