NHibernate version: 2.0.0.4000
I have two classes like this in C#, SQL code and mappings files:
Code:
public class R
{
private int Id;
private string Name;
private IList W;
public R()
{
Name = string.Empty;
}
public virtual void setId(int value) { Id = value; }
public virtual int getId() { return Id; }
public virtual void setName(string value) { Name = value; }
public virtual string getName() { return Name; }
public virtual void setW(IList value) { W = value; }
public virtual IList getW() { return W; }
}
public class W
{
private int Id;
private double V;
public W(double v)
{
V = v;
}
public virtual void setId(int value) { Id = value; }
public virtual int getId() { return Id; }
public virtual void setV(double v) { V = v; }
public virtual double getV() { return V; }
}
CREATE TABLE W(
Id int identity primary key,
V float null
)
CREATE TABLE R (
Id int identity primary key,
Name varchar(64) null,
)
CREATE TABLE WR (
IdR int not null,
Position int null,
primary key (IdR)
)
alter table WR add constraint WRFK0 FOREIGN KEY(IdR) references R(Id)
<?xml version="1.0"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" namespace="X.Classes" assembly="X">
<class name="X.Classes.R, X" table="R" lazy="false">
<id name="Id" access="field" column="Id">
<generator class="native" />
</id>
<property name="Name" access="field" column="Name" type="String" length="64" not-null="false"/>
<list name="W" table="WR" lazy="true">
<key column="IdR"/>
<index column="Position"/>
</list>
</class>
</hibernate-mapping>
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" auto-import="true" namespace="X.Classes" assembly="X">
<class name="X.Classes.W, X" table="W" lazy="false">
<id name="Id" access="field" column="Id">
<generator class="native" />
</id>
<property name="V" access="field" column="V" type="Double"/>
</class>
</hibernate-mapping>
I want to store an ordered list of W objects in R. The mapping file doesn´t work.