Update of /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13398
Modified Files:
ClassWithCompositeIdFixture.cs
Log Message:
Added an hql test for a composite-id
Index: ClassWithCompositeIdFixture.cs
===================================================================
RCS file: /cvsroot/nhibernate/nhibernate/src/NHibernate.Test/NHSpecificTest/ClassWithCompositeIdFixture.cs,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** ClassWithCompositeIdFixture.cs 11 Jun 2004 20:09:30 -0000 1.2
--- ClassWithCompositeIdFixture.cs 17 Jun 2004 21:18:57 -0000 1.3
***************
*** 17,21 ****
private DateTime firstDateTime = new DateTime(2003, 8, 16);
private DateTime secondDateTime = new DateTime(2003, 8, 17);
!
[SetUp]
--- 17,22 ----
private DateTime firstDateTime = new DateTime(2003, 8, 16);
private DateTime secondDateTime = new DateTime(2003, 8, 17);
! private CompositeId id;
! private CompositeId secondId;
[SetUp]
***************
*** 23,26 ****
--- 24,29 ----
{
ExportSchema( new string[] { "NHSpecific.ClassWithCompositeId.hbm.xml" } );
+ id = new CompositeId("stringKey", 3, firstDateTime);
+ secondId = new CompositeId("stringKey2", 5, secondDateTime);
}
***************
*** 54,59 ****
public void TestSimpleCRUD()
{
- CompositeId id = new CompositeId("stringKey", 3, firstDateTime);
- CompositeId secondId = new CompositeId("stringKey2", 5, secondDateTime);
// insert the new objects
--- 57,60 ----
***************
*** 176,179 ****
--- 177,213 ----
}
+ [Test]
+ public void Hql()
+ {
+ // insert the new objects
+ ISession s = sessions.OpenSession();
+ ITransaction t = s.BeginTransaction();
+
+ ClassWithCompositeId theClass = new ClassWithCompositeId();
+ theClass.Id = id;
+ theClass.OneProperty = 5;
+
+ ClassWithCompositeId theSecondClass = new ClassWithCompositeId();
+ theSecondClass.Id = secondId;
+ theSecondClass.OneProperty = 10;
+
+ s.Save(theClass);
+ s.Save(theSecondClass);
+
+ t.Commit();
+ s.Close();
+
+ ISession s2 = sessions.OpenSession();
+
+ IQuery hql = s2.CreateQuery("from ClassWithCompositeId as cwid where cwid.Id.KeyString = :keyString");
+
+ hql.SetString("keyString", id.KeyString);
+
+ IList results = hql.List();
+
+ Assert.AreEqual(1, results.Count);
+
+ }
+
}
|