• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Updating an entity object without loading the same

 
Keerthi Kumar Narayan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 553
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Keerthi Kumar Narayan
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic