I posted an exception earlier to the nhusers group (
http://groups.google.com/group/nhusers/browse_thread/thread/e9159d0de38b5731/55a5997192e4fc4f?lnk=gst&q=nullreference#55a5997192e4fc4f
).
It turned out that the problem is with the JetDriver, so i created a
testcase as proposed by Tuna Toksoz.
The test fails with a NullReferenceException here (full code
below):
s.Delete("from Foo foo where foo.ModuleId = :Id", m.ModuleId,
NHibernate.NHibernateUtil.Int32);
Two small modifications are needed to start it over with the
JetTests.db initialized correctly:
- Add this line just after the entities are added to the configuration
in the JetTestBase class
AddEntities();
//--> new:
configuration.AddFile(Path.Combine("Entities","Foo.hbm.xml"));
factory = configuration.BuildSessionFactory();
[...]
So the mappings are loaded correctly from the hbm.xml (make sure to
set the 'always copy' flag of the file in the JetDriver.Tests project)
- Add the ANTLR3.DLL to the project references
Please Help!
Many thanks Nico
If you want i can commit this to svn, however i don't have privileges
yet.
Here comes the test fixture:
using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using NHibernate.JetDriver.Tests.Entities;
namespace NHibernate.JetDriver.Tests
{
[TestFixture]
public class JetHqlDeleteFixture : JetTestBase
{
public JetHqlDeleteFixture()
: base(true) //auto create the tables...
{
}
[Test]
public void HQLDelete()
{
object savedId;
using (ISession s = SessionFactory.OpenSession())
using (ITransaction t = s.BeginTransaction())
{
savedId = s.Save(new Foo
{
ModuleId = -1,
Module = "bar"
});
t.Commit();
}
using (ISession s = SessionFactory.OpenSession())
using (ITransaction t = s.BeginTransaction())
{
var m = s.Get<Foo>(savedId);
m.Module = "bar2";
t.Commit();
}
//delete using a HQL statement
using (ISession s = SessionFactory.OpenSession())
using (ITransaction t = s.BeginTransaction())
{
var m = s.Get<Foo>(savedId);
s.Delete("from Foo foo where foo.ModuleId = :Id",
m.ModuleId,
NHibernate.NHibernateUtil.Int32);
t.Commit();
}
using (ISession s = SessionFactory.OpenSession())
using (ITransaction t = s.BeginTransaction())
{
s.CreateQuery("delete from Foo").ExecuteUpdate();
t.Commit();
}
}
}
}