Hi, I'm new to NHibernate and O/R mapping world. I've been trying to learn how to use the different kinds of mappings, but I got stuck with the one-to-many.
I'm using mysql 4.1. These are my tables:
factura
PK fac_id BIGINT autoincrement
fac_fecha DATETIME
itemfactura
PK itemf_id BIGINT
itemf_producto VARCHAR(45)
FK fac_id BIGINT
Mapping Files:
Factura.hbm.xml
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="TestNHibernate3.Factura, TestNHibernate3" table="factura">
<id name="Id" column="fac_id" type="Int64">
<generator class="native"></generator>
</id>
<property name="Fecha" column="fac_fecha" type="DateTime"></property>
<bag name="Items" cascade="all">
<key column="fac_id"></key>
<one-to-many class="TestNHibernate3.ItemFactura, TestNHibernate3"></one-to-many>
</bag>
</class>
</hibernate-mapping>
ItemFactura.hbm.xmlCode:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="TestNHibernate3.ItemFactura, TestNHibernate3" table="itemfactura">
<id name="Id" column="itemf_id" type="Int64">
<generator class="assigned"></generator>
</id>
<property name="Producto" column="itemf_producto" type="String"></property>
<many-to-one name="Factura" class="TestNHibernate3.Factura, TestNHibernate3" column="fac_id"></many-to-one>
</class>
</hibernate-mapping>
Classes written in C#:Factura[code]
using System;
using System.Collections;
namespace TestNHibernate3
{
/// <summary>
/// Descripci