Hello everybody,
i've got the following problem, in my class i have two IList collections. If i persist the class, with the help of the below listed mapping file, the data is stored like in the following table:
Code:
ID lfd_nr mylist mylist1
===============================================
17 0 firststring <NULL>
17 1 secondstring <NULL>
17 0 <NULL> ShouldBeInRowLikeFirstString
17 0 <NULL> ShouldBeInRowLikeSecondString
How do i have to adapt the mapping file, so that the data is stored like follows?
Code:
ID lfd_nr mylist mylist1
===============================================
17 0 firststring ShouldBeInRowLikeFirstString
17 1 secondstring ShouldBeInRowLikeSecondString
Mapping documents:Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="testnamespace.Classes" assembly="WindowsApplication2">
<class name="Class1" table="TestTable">
<id name="Id" column="ID" type="Int32">
<generator class="native"/>
</id>
<property name="Description" column="TestString" type="String"/>
<list name ="MyList" lazy="true" table="TestTable1">
<key column="ID"/>
<index column="lfd_nr"/>
<element type ="string" column="mylist" not-null="false"/>
</list>
<list name ="MyList1" lazy="true" table="TestTable1">
<key column="ID"/>
<index column="lfd_nr"/>
<element type ="string" column="mylist1" not-null="false"/>
</list>
</class>
</hibernate-mapping>
Class to persistCode:
using System.Collections;
namespace testnamespace.Classes
{
public class Class1
{
private string description;
private IList myList;
private IList myList1;
private int id;
public Class1()
{
this.description = "TestDesciption";
this.myList = new ArrayList();
this.myList1 = new ArrayList();
}
public string Description
{
get { return description; }
set { description = value; }
}
public IList MyList
{
get { return myList; }
set { myList = value; }
}
public IList MyList1
{
get { return myList1; }
set { myList1 = value; }
}
public int Id
{
get { return id; }
set { id = value; }
}
}
}
thx in advance
a NHibernate Newbie