Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

How to update an entity in a collection  RSS feed

Roger Rustin
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

I have an entity called category. A category can have many items. I am using "set" to have an association between categoty and items.

So I get the list of items like this.

Set items = category.getItems()

Now I need to update an item in the retrieved list. There are two ways I could think of

1) Using the item id get the itme from the DB and update the itme. In this case the category doesn't come into picture.
2) Update the set with the updated item and then save category. I have set cascade="all" so it should work. But in this case it will be a new set and then hibernate will delete all the items in the set and will populate them again.

Was just wondering what's the best practices.

- Roger
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!