cooler8020002000 wrote:
In Hibernate to update,
we set the values in the POJO classes and then do Session.save(POJO);
However, say we have to update a collection of these POJO's.
To be more clear, I have in my jsp, rows of data which I have to update.
How do I update these rows in one shot.
Else, I have to have a for loop and then set the POJO each time and then do a save.
I want something like Session.save (Collection of POJO).
Is this possible or what is the alternative?
Any help will be deeply appreciated.
Thanks.
If the collection is mapped with
Code:
cascade="save-update"
then you can just:
Code:
session.save(Parent object of collection)
So say if you had a cat, which contains a collection of kittens, you could use
Code:
session.save(cat)
Please see
http://www.hibernate.org/hib_docs/reference/en/html_single/#example-parentchild-collections and the rest of the documentation on collections (playing with cats is a useful example).
HTH!