Hi,
I am new to Hibernate and have been looking for almost two days for a solution and still had no luck.
Can someone give me a small example as how to copy all the child elements from parent1 to parent2. Note: Parent2 is transient, not yet updated to the database, children are of type bag.
Code:
Parent parentOne = Session.Load(typeof(Parent), 1);
Children childrenOne = parentOne.Children;
Parent parentTwo = new Parent();
foreach (Child child in childrenOne)
{
parentTwo.Children.Add(new Child(child.Value));
}
Session.Save(parentTwo)
Can someone tell me what I am doing wrong? I get a NonUniqueException when I try to Save.
Thanks for any help,
Javid
Need help with Hibernate? Read this first:
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version:
Mapping documents:
Code between sessionFactory.openSession() and session.close():
Full stack trace of any exception that occurs:
Name and version of the database you are using:
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt:
Problems with Session and transaction handling?
Read this:
http://hibernate.org/42.html