Hi,
Is it possible to copy child elements from one parent to another. I tried something like the code below but I get an NonUniqueException: a different object with same identifier Value.
BTW, I am new to Hibernate and .Net, so please excuse my bad code style.
Thanks,
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():
Code:
Template old = (Template) Db.Session.Get(typeof(Template), int.Parse(oldTemplateID));
Template newtemplate = new Template();
newtemplate.TemplateName = txtTemplateName.Text;
foreach (TemplateValue value in old.TemplateValues)
newtemplate.AddTemplateValue(new TemplateValue(value));
Db.Save(newtemplate);
public void AddTemplateValue(TemplateValue value)
{
if (TemplateValues.Contains(value))
return;
value.Parent = this;
TemplateValues.Add(value);
Db.Session.Save(value);
}
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