Btw, these are my codes...
Code:
/*
* Customer.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
using System.Collections;
namespace NAccounting.Core.Sales
{
/// <summary>
/// Summary description for Customer.
/// </summary>
public class Customer
{
private int id;
.
.
.
private IList orders = new ArrayList();
public Customer() {}
Code:
/*
* SalesOrder.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
using System.Collections;
using NAccounting.Core.Inventory;
namespace NAccounting.Core.Sales
{
/// <summary>
/// Summary description for SalesOrder.
/// </summary>
public class SalesOrder
{
private int number;
private Customer customer;
.
.
.
private IList items = new ArrayList();
public SalesOrder() {}
Code:
/*
* SalesOrderItem.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
using NAccounting.Core.Inventory;
namespace NAccounting.Core.Sales
{
/// <summary>
/// Summary description for SalesOrderItem.
/// </summary>
public class SalesOrderItem
{
private SalesOrder salesOrder;
private Item item;
private int quantity;
public SalesOrderItem() {}
Code:
/*
* Item.cs 0.1
*
* Copyright 2006 Ian Escarro. All rights reserved.
* PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*/
using System;
using System.Collections;
namespace NAccounting.Core.Inventory
{
/// <summary>
/// Summary description for Item.
/// </summary>
public class Item
{
private int id;
.
.
.
public Item() {}
and my mapping file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0"
namespace="NAccounting.Core.Sales" assembly="NAccounting">
<class name="Customer" table="Customers">
<id name="Id" column="Id">
<generator class="identity"/>
</id>
<property name="CustomerName" column="Name"/>
<bag name="Orders" cascade="all" access="nosetter.camelcase" lazy="false" inverse="true">
<key column="Id"/>
<one-to-many class="SalesOrder"/>
</bag>
</class>
<class name="SalesOrder" table="SalesOrders">
<id name="Number" column="Number">
<generator class="identity"/>
</id>
<property name="Date" column="Date"/>
<many-to-one name="Customer" column="CustomerId" class="Customer" cascade="none"/>
<bag name="Items" cascade="all" access="nosetter.camelcase" lazy="false" inverse="true">
<key column="Number"/>
<one-to-many class="SalesOrderItem"/>
</bag>
</class>
<class name="SalesOrderItem" table="SalesOrderItems">
<composite-id>
<key-many-to-one name="Item" column="ItemId" class="NAccounting.Core.Inventory.Item, NAccounting"/>
<key-many-to-one name="SalesOrder" column="Number" class="SalesOrder, NAccounting"/>
</composite-id>
<property name="Quantity" column="Quantity"/>
</class>
</hibernate-mapping>
[EDIT] and the error I'm getting...
Code:
NHibernate: INSERT INTO Customers (Name) VALUES (@p0); select SCOPE_IDENTITY()
@p0 = 'foo'
NHibernate: INSERT INTO SalesOrders (CustomerId, Date) VALUES (@p0, @p1); select SCOPE_IDENTITY()
@p0 = '12'
@p1 = '7/21/2006 5:27:02 PM'
NHibernate: UPDATE SalesOrderItems SET Quantity = @p0 WHERE ItemId = @p1 AND Number = @p2
@p0 = '1'
@p1 = '1'
@p2 = '10'
TestCase 'NAccounting.Core.DataAccess.Tests.CustomerFacadeTest.TestSave'
failed: NHibernate.HibernateException : SQL insert, update or delete failed (expected affected row count: 1, actual affected row count: 0). Possible causes: the row was modified or deleted by another user, or a trigger is reporting misleading row count.
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Object[] oldFields, Boolean[] includeProperty, Object oldVersion, Object obj, SqlString sqlUpdateString, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Update(Object id, Object[] fields, Int32[] dirtyFields, Object[] oldFields, Object oldVersion, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledUpdate.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()
at NHibernate.Impl.SessionImpl.Flush()
at NHibernate.Transaction.AdoTransaction.Commit()
D:\ian\projects\csharp\naccounting\src\NAccounting\Core\DataAccess\CustomerFacade.cs(27,0): at NAccounting.Core.DataAccess.CustomerFacade.Save(Customer c)
d:\ian\projects\csharp\naccounting\src\naccounting\core\dataaccess\tests\customerfacadetest.cs(30,0): at NAccounting.Core.DataAccess.Tests.CustomerFacadeTest.TestSave()
TestFixture failed:
0 passed, 1 failed, 0 skipped, took 3.05 seconds.
Help anyone? Millions of thanks in advance!