Jet-Driver Issue (NullReference Exception) with Test to reproduce

0 views
Skip to first unread message

nicco80

unread,
Aug 14, 2009, 5:10:01 AM8/14/09
to NHibernate Contrib - Development Group
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();
}
}
}
}

Hadi Eskandari

unread,
Aug 16, 2009, 3:51:50 AM8/16/09
to NHibernate Contrib - Development Group
Okay, I could reproduce the problem using release NH 2.1 but trying to
debug it using current version of NH (built from trunk) there's no
exception anymore and the test is passed. I'm not sure which change
set is related to this issue though.

On Aug 14, 1:10 pm, nicco80 <nicolas...@poczta.onet.pl> wrote:
> I posted an exception earlier to the nhusers group (http://groups.google.com/group/nhusers/browse_thread/thread/e9159d0de...

nicco80

unread,
Aug 18, 2009, 9:18:13 AM8/18/09
to NHibernate Contrib - Development Group
Doh! That's bad news,

- What is the preferred way to go, shall i simply use the trunk
checkout of nh
and go with it or is there high chance that other thinks are broken
in the development version?

- How could i find out by which code part the error was fixed?
- Will my testcase get integrated to the repository?

Thanks nico.

Tuna Toksoz

unread,
Aug 18, 2009, 9:26:42 AM8/18/09
to nhc...@googlegroups.com
NH trunk has always been stable. The only problem for you might be the fact that NH trunk uses 3.5 from now on. Perhaps you can try 2.1.x branch.

Tuna Toksöz
Eternal sunshine of the open source mind.

http://devlicio.us/blogs/tuna_toksoz
http://tunatoksoz.com
http://twitter.com/tehlike

Hadi Eskandari

unread,
Aug 18, 2009, 11:06:35 AM8/18/09
to nhc...@googlegroups.com
Hello,

NHibernate source is quite stable, but I'm not sure which change has
solved this particular issue. If you need to get an urgent fix, I
suggest you build NH branch 2.1.x and use the 2.1.x build.

As for integrating the failing test case, I think I can add it to Jet
tests. If I can pin point the problem / change set in NH source, I'll
let you know.

nicco80

unread,
Aug 19, 2009, 3:14:34 AM8/19/09
to NHibernate Contrib - Development Group
I will try the NH 2.1.x branch.

> As for integrating the failing test case, I think I can add it to Jet
> tests. If I can pin point the problem / change set in NH source, I'll
> let you know.
That would be great, thanks

Regards nico
Reply all
Reply to author
Forward
0 new messages