aspose file tools*
The moose likes Object Relational Mapping and the fly likes Updating an entity object without loading the same Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » Object Relational Mapping
Bookmark "Updating an entity object without loading the same" Watch "Updating an entity object without loading the same" New topic
Author

Updating an entity object without loading the same

Keerthi Kumar Narayan
Greenhorn

Joined: Feb 01, 2013
Posts: 4
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: 553
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: 4
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?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Updating an entity object without loading the same