|
From: <te...@us...> - 2008-12-12 14:40:44
|
Revision: 3945
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3945&view=rev
Author: tehlike
Date: 2008-12-12 14:40:38 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
Added tests for NH1349 to support it is not an issue.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Services.cs
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Fixture.cs 2008-12-12 14:40:38 UTC (rev 3945)
@@ -0,0 +1,56 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1349
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using(var session=this.OpenSession())
+ {
+ using(var tran=session.BeginTransaction())
+ {
+ string name = "fabio";
+ string accNum = DateTime.Now.Ticks.ToString(); ;
+ Services newServ = new Services();
+ newServ.AccountNumber = accNum;
+ newServ.Name = name + " person";
+ newServ.Type = (new Random()).Next(0, 9).ToString();
+
+ session.Save(newServ);
+ tran.Commit();
+ }
+ }
+ }
+ protected override void OnTearDown()
+ {
+ using (var session = this.OpenSession())
+ {
+ using (var tran = session.BeginTransaction())
+ {
+ session.Delete("from Services");
+ tran.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void Can_page_with_formula_property()
+ {
+ using (var session = this.OpenSession())
+ {
+ using(var tran=session.BeginTransaction())
+ {
+ IList ret = session.CreateCriteria(typeof(Services)).SetMaxResults(5).List(); //this breaks
+ Assert.That(ret.Count,Is.EqualTo(1));
+ }
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Mappings.hbm.xml 2008-12-12 14:40:38 UTC (rev 3945)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1349"
+ assembly="NHibernate.Test">
+ <class name="Services" table="services">
+ <id name="Id" column="id" type="int">
+ <generator class="increment" />
+ </id>
+ <property name="AccountNumber" column="accountNumber" type="String" length="30"/>
+ <property name="Name" type="String" length="30"/>
+ <property name="Type" type="String" length="30"/>
+ <property name ="CompanyCount"
+ formula="(SELECT COUNT(*) FROM services as c WHERE c.accountNumber LIKE '63%' )"
+ update="false" insert="false" access="nosetter.camelcase"/>
+ <!-- Using a formula seems to trigger it. I guess the query isn't being generated
+ correctly when some formulas are used.
+ -->
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Services.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Services.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1349/Services.cs 2008-12-12 14:40:38 UTC (rev 3945)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1349
+{
+ public class Services
+ {
+ private int id;
+ private int companyCount;
+ private string accountNumber;
+ private string name;
+ private string type;
+
+ public Services()
+ { }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string AccountNumber
+ {
+ get { return accountNumber; }
+ set { accountNumber = value; }
+ }
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ public virtual string Type
+ {
+ get { return type; }
+ set { type = value; }
+ }
+ public virtual int CompanyCount
+ {
+ get { return companyCount; }
+ set { companyCount = value; }
+ }
+ public virtual string ToString()
+ {
+ return (this.id + "] [" + this.accountNumber + "] [" + this.name + "] [" + this.type + "] [" + this.CompanyCount + "]");
+
+ }
+ }
+
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-08 10:53:17 UTC (rev 3944)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-12 14:40:38 UTC (rev 3945)
@@ -469,6 +469,8 @@
<Compile Include="NHSpecificTest\NH1332\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1347\A.cs" />
<Compile Include="NHSpecificTest\NH1347\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1349\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1349\Services.cs" />
<Compile Include="NHSpecificTest\NH1355\Category.cs" />
<Compile Include="NHSpecificTest\NH1355\CustomVersionType.cs" />
<Compile Include="NHSpecificTest\NH1355\UserTypeTimestamp.cs" />
@@ -1556,6 +1558,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1349\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1593\TestIndex.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1594\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1579\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-12-12 15:01:04
|
Revision: 3947
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3947&view=rev
Author: tehlike
Date: 2008-12-12 15:00:59 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
Added tests to support NH-1552 is no longer an issue after applying NH-1603(MSSQL 2005 Paging patch)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/MyClass.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Fixture.cs 2008-12-12 15:00:59 UTC (rev 3947)
@@ -0,0 +1,56 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1552
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using (var session = this.OpenSession())
+ {
+ using (var tran = session.BeginTransaction())
+ {
+ MyClass newServ = new MyClass();
+ newServ.Name = "tuna";
+ session.Save(newServ);
+ tran.Commit();
+ }
+ }
+ }
+ protected override void OnTearDown()
+ {
+ using (var session = this.OpenSession())
+ {
+ using (var tran = session.BeginTransaction())
+ {
+ session.Delete("from MyClass");
+ tran.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void Paging_with_sql_works_as_expected()
+ {
+ using (var session = this.OpenSession())
+ {
+ using (var tran = session.BeginTransaction())
+ {
+ string sql = "select * from MyClass";
+ IList list = session.CreateSQLQuery(sql)
+ .AddEntity(typeof(MyClass))
+ .SetFirstResult(0)
+ .SetMaxResults(50)
+ .List();
+ Assert.That(list.Count, Is.EqualTo(1));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/Mappings.hbm.xml 2008-12-12 15:00:59 UTC (rev 3947)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1552">
+
+ <class name="MyClass">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Name"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/MyClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/MyClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1552/MyClass.cs 2008-12-12 15:00:59 UTC (rev 3947)
@@ -0,0 +1,12 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1552
+{
+ public class MyClass
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-12 14:57:17 UTC (rev 3946)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-12 15:00:59 UTC (rev 3947)
@@ -521,6 +521,8 @@
<Compile Include="NHSpecificTest\NH1508\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1508\Person.cs" />
<Compile Include="NHSpecificTest\NH1515\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1552\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1552\MyClass.cs" />
<Compile Include="NHSpecificTest\NH1556\Claim.cs" />
<Compile Include="NHSpecificTest\NH1556\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1556\Patient.cs" />
@@ -1558,6 +1560,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1552\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1349\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1593\TestIndex.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1594\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2008-12-12 15:39:20
|
Revision: 3948
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3948&view=rev
Author: tehlike
Date: 2008-12-12 15:39:14 +0000 (Fri, 12 Dec 2008)
Log Message:
-----------
Added tests to support NH-1533 is not an issue (also not an issue before new 2005 dialect)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Person.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Fixture.cs 2008-12-12 15:39:14 UTC (rev 3948)
@@ -0,0 +1,104 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1533
+{
+ [TestFixture]
+ public class Fixture:BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete("from Person");
+ tx.Commit();
+ }
+ }
+ }
+ protected override void OnSetUp()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ Person e1 = new Person("Joe", 10, 9);
+ Person e2 = new Person("Sally", 10, 8);
+ Person e3 = new Person("Tim", 20, 40); //20
+ Person e4 = new Person("Fred", 20, 7);
+ Person e5 = new Person("Mike", 50, 50);
+ s.Save(e1);
+ s.Save(e2);
+ s.Save(e3);
+ s.Save(e4);
+ s.Save(e5);
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void Can_query_using_two_orderby_and_limit_altogether()
+ {
+ using(var sess=OpenSession())
+ {
+ using(var tran=sess.BeginTransaction() )
+ {
+ var query =
+ sess.CreateQuery(
+ "select this.Name,this.ShoeSize,this.IQ from Person as this order by this.IQ asc,this.ShoeSize asc");
+ query.SetMaxResults(2);
+ query.SetFirstResult(2);
+ IList results = query.List();
+ Assert.That(results.Count, Is.EqualTo(2));
+ Assert.That(((IList)results[0])[0], Is.EqualTo("Fred"));
+ Assert.That(((IList)results[1])[0], Is.EqualTo("Tim"));
+ }
+ }
+ }
+ [Test]
+ public void Can_query_using_two_orderby_and_limit_with_maxresult_only()
+ {
+ using (var sess = OpenSession())
+ {
+ using (var tran = sess.BeginTransaction())
+ {
+ var query =
+ sess.CreateQuery(
+ "select this.Name,this.ShoeSize,this.IQ from Person as this order by this.IQ asc,this.ShoeSize asc");
+ query.SetMaxResults(2);
+ IList results = query.List();
+ Assert.That(results.Count, Is.EqualTo(2));
+ Assert.That(((IList)results[0])[0], Is.EqualTo("Sally"));
+ Assert.That(((IList)results[1])[0], Is.EqualTo("Joe"));
+ }
+ }
+ }
+
+ [Test]
+ public void Can_query_using_two_orderby_and_limit_with_firstresult_only()
+ {
+ using (var sess = OpenSession())
+ {
+ using (var tran = sess.BeginTransaction())
+ {
+ var query =
+ sess.CreateQuery(
+ "select this.Name,this.ShoeSize,this.IQ from Person as this order by this.IQ asc,this.ShoeSize asc");
+ query.SetFirstResult(2);
+ IList results = query.List();
+ Assert.That(results.Count, Is.EqualTo(3));
+ Assert.That(((IList)results[0])[0], Is.EqualTo("Fred"));
+ Assert.That(((IList)results[1])[0], Is.EqualTo("Tim"));
+ Assert.That(((IList)results[1])[0], Is.EqualTo("Mike"));
+ }
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Mappings.hbm.xml 2008-12-12 15:39:14 UTC (rev 3948)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1533">
+
+ <class name="Person" lazy="false">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ <property name="IQ"/>
+ <property name="ShoeSize"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1533/Person.cs 2008-12-12 15:39:14 UTC (rev 3948)
@@ -0,0 +1,54 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+using ArrayList=System.Collections.ArrayList;
+
+namespace NHibernate.Test.NHSpecificTest.NH1533
+{
+ public class Person
+ {
+ private int id;
+ private int iq;
+ private string name;
+ private IList pets;
+ private int shoeSize;
+
+ public Person()
+ {
+ pets = new ArrayList();
+ }
+
+ public Person(string name, int iq, int shoeSize)
+ {
+ this.name = name;
+ this.iq = iq;
+ this.shoeSize = shoeSize;
+ pets = new ArrayList();
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual int IQ
+ {
+ get { return iq; }
+ set { iq = value; }
+ }
+
+ public virtual int ShoeSize
+ {
+ get { return shoeSize; }
+ set { shoeSize = value; }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-12 15:00:59 UTC (rev 3947)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-12 15:39:14 UTC (rev 3948)
@@ -521,6 +521,8 @@
<Compile Include="NHSpecificTest\NH1508\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1508\Person.cs" />
<Compile Include="NHSpecificTest\NH1515\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1533\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1533\Person.cs" />
<Compile Include="NHSpecificTest\NH1552\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1552\MyClass.cs" />
<Compile Include="NHSpecificTest\NH1556\Claim.cs" />
@@ -1560,6 +1562,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1533\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1552\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1349\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1593\TestIndex.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-17 06:50:04
|
Revision: 3964
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3964&view=rev
Author: davybrion
Date: 2008-12-17 06:50:00 +0000 (Wed, 17 Dec 2008)
Log Message:
-----------
Testfixture for NH-1609
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Entities.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Entities.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Entities.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Entities.cs 2008-12-17 06:50:00 UTC (rev 3964)
@@ -0,0 +1,19 @@
+namespace NHibernate.Test.NHSpecificTest.NH1609
+{
+ public class EntityA
+ {
+ public virtual long Id { get; set; }
+ }
+
+ public class EntityB
+ {
+ public virtual long Id { get; set; }
+ public virtual EntityA A { get; set; }
+ public virtual EntityC C { get; set; }
+ }
+
+ public class EntityC
+ {
+ public virtual long Id { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Fixture.cs 2008-12-17 06:50:00 UTC (rev 3964)
@@ -0,0 +1,75 @@
+using System.Collections;
+
+using NHibernate.Criterion;
+using NHibernate.Test.NHSpecificTest.NH1609;
+
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1609
+{
+ [TestFixture]
+ [Ignore("not fixed yet")]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void Test()
+ {
+ using (ISession session = sessions.OpenSession())
+ using (ITransaction transaction = session.BeginTransaction())
+ {
+ EntityA a1 = CreateEntityA(session);
+ EntityA a2 = CreateEntityA(session);
+ EntityC c = CreateEntityC(session);
+ EntityB b = CreateEntityB(session, a1, c);
+
+ // make sure the created entities are no longer in the session
+ session.Clear();
+
+ IMultiCriteria multi = session.CreateMultiCriteria();
+
+ // the first query is a simple select by id on EntityA
+ multi.Add(session.CreateCriteria(typeof(EntityA)).Add(Restrictions.Eq("Id", a1.Id)));
+ // the second query is also a simple select by id on EntityB
+ multi.Add(session.CreateCriteria(typeof(EntityA)).Add(Restrictions.Eq("Id", a2.Id)));
+ // the final query selects the first element (using SetFirstResult and SetMaxResults) for each EntityB where B.A.Id = a1.Id and B.C.Id = c.Id
+ // the problem is that the paged query uses parameters @p0 and @p1 instead of @p2 and @p3
+ multi.Add(
+ session.CreateCriteria(typeof(EntityB))
+ .Add(Restrictions.Eq("A.Id", a1.Id))
+ .Add(Restrictions.Eq("C.Id", c.Id))
+ .SetFirstResult(0)
+ .SetMaxResults(1));
+
+ var results = multi.List();
+
+ Assert.AreEqual(1, ((IList)results[0]).Count);
+ Assert.AreEqual(1, ((IList)results[1]).Count);
+ Assert.AreEqual(1, ((IList)results[2]).Count);
+ }
+ }
+
+ private EntityA CreateEntityA(ISession session)
+ {
+ EntityA a = new EntityA();
+ session.Save(a);
+ session.Flush();
+ return a;
+ }
+
+ private EntityC CreateEntityC(ISession session)
+ {
+ EntityC c = new EntityC();
+ session.Save(c);
+ session.Flush();
+ return c;
+ }
+
+ private EntityB CreateEntityB(ISession session, EntityA a, EntityC c)
+ {
+ EntityB b = new EntityB { A = a, C = c };
+ session.Save(b);
+ session.Flush();
+ return b;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1609/Mappings.hbm.xml 2008-12-17 06:50:00 UTC (rev 3964)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1609">
+
+ <class name="EntityA" table="EntityA">
+ <id name="Id" column="Id" type="long">
+ <generator class="identity"/>
+ </id>
+ </class>
+
+ <class name="EntityB" table="EntityB">
+ <id name="Id" column="Id" type="long">
+ <generator class="identity"/>
+ </id>
+
+ <many-to-one name="A" column="AId" class="EntityA" />
+ <many-to-one name="C" column="CId" class="EntityC" />
+
+ </class>
+
+ <class name="EntityC" table="EntityC">
+ <id name="Id" column="Id" type="long">
+ <generator class="identity" />
+ </id>
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-16 21:53:58 UTC (rev 3963)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-17 06:50:00 UTC (rev 3964)
@@ -378,6 +378,8 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1605\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1609\Entities.cs" />
+ <Compile Include="NHSpecificTest\NH1609\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Adjunct.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\NH1611OneToOneIdentityFixture.cs" />
<Compile Include="NHSpecificTest\NH1611OneToOneIdentity\Primary.cs" />
@@ -1571,6 +1573,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1609\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1605\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithSpecific.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1443\AclassWithDefault.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dav...@us...> - 2008-12-27 19:54:04
|
Revision: 3966
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3966&view=rev
Author: davybrion
Date: 2008-12-27 19:53:57 +0000 (Sat, 27 Dec 2008)
Log Message:
-----------
added tests to verify that NH-1521 was indeed fixed by the fix for NH-1443
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithDefault.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml 2008-12-27 19:53:57 UTC (rev 3966)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1521"
+ assembly="NHibernate.Test"
+ catalog="nhibernate"
+ schema="dbo">
+
+ <class name="Aclass">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithDefault.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithNothing.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithNothing.hbm.xml 2008-12-27 19:53:57 UTC (rev 3966)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1521"
+ assembly="NHibernate.Test">
+
+ <class name="Aclass">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/AclassWithSpecific.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml 2008-12-27 19:53:57 UTC (rev 3966)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1521"
+ assembly="NHibernate.Test"
+ catalog="somethingDifferent"
+ schema="somethingDifferent">
+
+ <class name="Aclass" catalog="nhibernate" schema="dbo">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ </class>
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/AclassWithSpecific.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs (from rev 3965, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1443/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs 2008-12-27 19:53:57 UTC (rev 3966)
@@ -0,0 +1,62 @@
+using System.Text;
+using NHibernate.Cfg;
+using NHibernate.Tool.hbm2ddl;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1521
+{
+ [TestFixture]
+ public class Fixture
+ {
+ private static void AssertThatCheckOnTableExistenceIsCorrect(Configuration configuration)
+ {
+ var su = new SchemaExport(configuration);
+ var sb = new StringBuilder(500);
+ su.Execute(x => sb.AppendLine(x), false, false, true);
+ string script = sb.ToString();
+ Assert.That(script, Text.Contains("if exists (select * from dbo.sysobjects where id = object_id(N'nhibernate.dbo.Aclass') and OBJECTPROPERTY(id, N'IsUserTable') = 1)"));
+ }
+
+ [Test]
+ public void TestForClassWithDefaultSchema()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithNothing.hbm.xml", GetType().Assembly);
+ cfg.SetProperty(Environment.DefaultCatalog, "nhibernate");
+ cfg.SetProperty(Environment.DefaultSchema, "dbo");
+ AssertThatCheckOnTableExistenceIsCorrect(cfg);
+ }
+
+ [Test]
+ public void WithDefaultValuesInMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly);
+ AssertThatCheckOnTableExistenceIsCorrect(cfg);
+ }
+
+ [Test]
+ public void WithSpecificValuesInMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithSpecific.hbm.xml", GetType().Assembly);
+ AssertThatCheckOnTableExistenceIsCorrect(cfg);
+ }
+
+ [Test]
+ public void WithDefaultValuesInConfigurationPriorityToMapping()
+ {
+ Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration();
+ cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1521.AclassWithDefault.hbm.xml", GetType().Assembly);
+ cfg.SetProperty(Environment.DefaultCatalog, "somethingDifferent");
+ cfg.SetProperty(Environment.DefaultSchema, "somethingDifferent");
+ AssertThatCheckOnTableExistenceIsCorrect(cfg);
+ }
+ }
+
+ public class Aclass
+ {
+ public int Id { get; set; }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1521/Fixture.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-25 19:57:53 UTC (rev 3965)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2008-12-27 19:53:57 UTC (rev 3966)
@@ -377,6 +377,7 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1521\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1605\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1609\Entities.cs" />
<Compile Include="NHSpecificTest\NH1609\Fixture.cs" />
@@ -1576,6 +1577,9 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithSpecific.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithNothing.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1521\AclassWithDefault.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1621\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1609\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1605\Mappings.hbm.xml" />
@@ -1682,4 +1686,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-01-02 14:37:29
|
Revision: 3969
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3969&view=rev
Author: fabiomaulo
Date: 2009-01-02 14:37:21 +0000 (Fri, 02 Jan 2009)
Log Message:
-----------
Test for NH-1612
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/AreaStatistics.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/MonetaryValue.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Area.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,42 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public abstract class Area
+ {
+ public virtual string Code { get; private set; }
+ public virtual string Name { get; private set; }
+ public virtual int Version { get; private set; }
+ public virtual IDictionary<int, AreaStatistics> Statistics { get; private set; }
+
+ protected Area() {}
+
+ protected Area(string code, string name)
+ {
+ Code = code;
+ Name = name;
+ Statistics = new Dictionary<int, AreaStatistics>();
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ var other = obj as Area;
+ if (ReferenceEquals(obj, null))
+ {
+ return false;
+ }
+
+ return GetType() == other.GetType() && Code == other.Code;
+ }
+
+ public override int GetHashCode()
+ {
+ return (Code ?? string.Empty).GetHashCode() ^ GetType().GetHashCode();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/AreaStatistics.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/AreaStatistics.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/AreaStatistics.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,59 @@
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public class AreaStatistics
+ {
+ public virtual MonetaryValue? GDP { get; set; }
+ public virtual int? CitizenCount { get; set; }
+ public virtual Person Reporter { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(this, obj))
+ {
+ return true;
+ }
+
+ var other = obj as AreaStatistics;
+ if (ReferenceEquals(other, null))
+ {
+ return false;
+ }
+
+ return CitizenCount == other.CitizenCount && GDP == other.GDP && Reporter == other.Reporter;
+ }
+
+ public override int GetHashCode()
+ {
+ return (CitizenCount ?? 0) ^ GDP.GetHashCode() ^ (Reporter != null ? Reporter.GetHashCode() : 0);
+ }
+
+ public override string ToString()
+ {
+ var sb = new StringBuilder();
+ if (CitizenCount.HasValue)
+ {
+ sb.Append("CitizenCount: ").Append(CitizenCount);
+ }
+ if (GDP.HasValue)
+ {
+ if (sb.Length > 0)
+ {
+ sb.Append("; ");
+ }
+ sb.Append("GDP: ").Append(GDP);
+ }
+ if (Reporter != null)
+ {
+ if (sb.Length > 0)
+ {
+ sb.Append("; ");
+ }
+ sb.Append("Reporter: ").Append(Reporter.Name);
+ }
+
+ return sb.ToString();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/City.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,24 @@
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public class City : Area
+ {
+ public virtual Country Country { get; private set; }
+
+ protected City() {}
+
+ public City(string code, string name) : base(code, name) {}
+
+ public virtual void SetParent(Country country)
+ {
+ if (Country != null)
+ {
+ Country.Cities.Remove(this);
+ }
+ Country = country;
+ if (country != null)
+ {
+ country.Cities.Add(this);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Country.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,18 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public class Country : Area
+ {
+ public virtual IList<string> Routes { get; private set; }
+ public virtual IList<City> Cities { get; private set; }
+
+ protected Country() {}
+
+ public Country(string code, string name) : base(code, name)
+ {
+ Routes = new List<string>();
+ Cities = new List<City>();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Mappings.hbm.xml 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1612"
+ default-cascade="save-update">
+
+ <class name="Area" table="areas">
+ <id name="Code" column="code" type="String" length="3">
+ <generator class="assigned"/>
+ </id>
+ <discriminator column="area_type" type="String" length="2" not-null="true" />
+ <version name="Version" column="version" type="Int32" generated="never" unsaved-value="0" />
+ <property name="Name" column="name" type="String" length="50" not-null="true" />
+ <map name="Statistics" table="stats">
+ <key column="area_code" />
+ <index column="year" type="Int32" />
+ <composite-element class="AreaStatistics">
+ <property name="CitizenCount" column="citizen_count" type="Int32" />
+ <nested-composite-element name="GDP" class="MonetaryValue">
+ <property name="CurrencySymbol" column="gdp_currency" type="String" length="3" />
+ <property name="Amount" column="gdp_amount" type="double" not-null="false" />
+ </nested-composite-element>
+ <many-to-one name="Reporter" column="reporter_id" class="Person" />
+ </composite-element>
+ <loader query-ref="AreaStatisticsLoader" />
+ </map>
+
+ <subclass name="Country" discriminator-value="CO">
+ <list name="Routes" table="routes" generic="true">
+ <key column="country_code" />
+ <index column="route_no" />
+ <element column="name" type="String" length="50" />
+ <loader query-ref="CountryRouteLoader" />
+ </list>
+
+ <bag name="Cities" table="cities" inverse="true" generic="true">
+ <key column="country_code" />
+ <one-to-many class="City" />
+ <loader query-ref="CountryCityLoader" />
+ </bag>
+ </subclass>
+
+ <subclass name="City" discriminator-value="CI">
+ <!-- Cascading saves disabled, because it causes exceptions -->
+ <many-to-one name="Country" column="country_code" class="Country" />
+ </subclass>
+ </class>
+
+ <class name="Person" table="persons">
+ <id name="PersonId" column="id">
+ <generator class="assigned" />
+ </id>
+ <version name="Version" column="version" type="Int32" generated="never" unsaved-value="0" />
+ <property name="Name" type="String" length="100" />
+ </class>
+
+ <!--
+ Collection loaders
+ -->
+
+ <sql-query name="CountryRouteLoader" xml:space="preserve">
+ <load-collection role="Country.Routes" alias="r" />
+ SELECT {r.*}
+ FROM routes r
+ WHERE r.country_code = :country_code
+ </sql-query>
+
+ <sql-query name="CountryCityLoader" xml:space="preserve">
+ <load-collection role="Country.Cities" alias="ci" />
+ SELECT {ci.*}
+ FROM areas ci
+ WHERE ci.country_code = :country_code
+ AND ci.area_type = 'CI'
+ </sql-query>
+
+ <sql-query name="CountryStatisticsLoader" xml:space="preserve">
+ <load-collection role="Area.Statistics" alias="s">
+ <return-property name="key" column="code" />
+ <return-property name="index" column="year" />
+ <return-property name="element.CitizenCount" column="citizen_count" />
+ <return-property name="element.GDP">
+ <return-column name="gdp_currency" />
+ <return-column name="gdp_amount" />
+ </return-property>
+ <return-property name="element.Reporter" column="reporter_id" />
+ </load-collection>
+ SELECT area_code
+ , year
+ , citizen_count
+ , gdp_currency
+ , gdp_amount
+ , reporter_id
+ FROM stats
+ WHERE area_code = :area_code
+ </sql-query>
+
+
+ <!--
+ Entity queries with non-lazy loading of collections
+ -->
+
+ <sql-query name="LoadCountryRoutesWithSimpleHbmAliasInjection" xml:space="preserve">
+ <return class="Country" alias="c" />
+ <return-join alias="r" property="c.Routes" />
+ SELECT {c.*}
+ , {r.*}
+ FROM areas c
+ LEFT OUTER JOIN routes r
+ ON c.code = r.country_code
+ WHERE c.code = :country_code
+ </sql-query>
+
+ <sql-query name="LoadCountryRoutesWithCustomAliases" xml:space="preserve">
+ <return class="Country" alias="c">
+ <return-property name="id" column="code" />
+ <return-property name="Version" column="version" />
+ <return-property name="Name" column="country_name" />
+ </return>
+ <return-join property="c.Routes" alias="r">
+ <return-property name="key" column="country_code" />
+ <return-property name="index" column="route_no" />
+ <return-property name="element" column="route_name" />
+ </return-join>
+ SELECT c.code
+ , c.version
+ , c.name AS country_name
+ , r.country_code
+ , r.route_no
+ , r.name AS route_name
+ FROM areas c
+ LEFT OUTER JOIN routes r
+ ON c.code = r.country_code
+ WHERE c.code = :country_code
+ </sql-query>
+
+ <sql-query name="LoadCountryCitiesWithSimpleHbmAliasInjection" xml:space="preserve">
+ <return class="Country" alias="co" />
+ <return-join property="co.Cities" alias="ci" />
+ SELECT {co.*}
+ , {ci.*}
+ FROM areas co
+ LEFT OUTER JOIN areas ci
+ ON ci.country_code = co.code
+ AND ci.area_type = 'CI'
+ WHERE co.code = :country_code
+ AND co.area_type = 'CO'
+ </sql-query>
+
+ <sql-query name="LoadCountryCitiesWithComplexHbmAliasInjection" xml:space="preserve">
+ <return class="Country" alias="co" />
+ <return-join property="co.Cities" alias="ci" />
+ SELECT co.code AS {co.id}
+ , co.version AS {co.Version}
+ , co.name AS {co.Name}
+ , ci.country_code AS {ci.key}
+ , ci.code AS {ci.element}
+ , ci.code AS {ci.element.id}
+ , ci.version AS {ci.element.Version}
+ , ci.name AS {ci.element.Name}
+ , ci.country_code AS {ci.element.Country}
+ FROM areas co
+ LEFT OUTER JOIN areas ci
+ ON ci.country_code = co.code
+ AND ci.area_type = 'CI'
+ WHERE co.code = :country_code
+ AND co.area_type = 'CO'
+ </sql-query>
+
+ <sql-query name="LoadCountryCitiesWithCustomAliases" xml:space="preserve">
+ <return class="Country" alias="co">
+ <return-property name="id" column="country_code" />
+ <return-property name="Version" column="country_version" />
+ <return-property name="Name" column="country_name" />
+ </return>
+ <return-join property="co.Cities" alias="ci">
+ <return-property name="key" column="country_code" />
+ <return-property name="element" column="city_code" />
+ <return-property name="element.id" column="city_code" />
+ <return-property name="element.Version" column="city_version" />
+ <return-property name="element.Name" column="city_name" />
+ <return-property name="element.Country" column="country_name" />
+ </return-join>
+ SELECT co.code AS country_code
+ , co.version AS country_version
+ , co.name AS country_name
+ , ci.code AS city_code
+ , ci.version AS city_version
+ , ci.name AS city_name
+ FROM areas co
+ LEFT OUTER JOIN areas ci
+ ON ci.country_code = co.code
+ AND ci.area_type = 'CI'
+ WHERE co.code = :country_code
+ AND co.area_type = 'CO'
+ </sql-query>
+
+ <sql-query name="LoadAreaStatisticsWithSimpleHbmAliasInjection" xml:space="preserve">
+ <return class="Area" alias="a" />
+ <return-join property="a.Statistics" alias="s" />
+ SELECT {a.*}
+ , {s.*}
+ FROM areas a
+ LEFT OUTER JOIN stats s
+ ON a.code = s.area_code
+ WHERE a.code = :country_code
+ </sql-query>
+
+ <sql-query name="LoadAreaStatisticsWithComplexHbmAliasInjection" xml:space="preserve">
+ <return class="Area" alias="a" />
+ <return-join property="a.Statistics" alias="s" />
+ SELECT a.code AS {a.id}
+ , a.area_type AS {a.class}
+ , a.version AS {a.Version}
+ , a.name AS {a.Name}
+ , s.area_code AS {s.key}
+ , s.year AS {s.index}
+ , s.citizen_count AS {s.element.CitizenCount}
+ , s.gdp_currency AS {s.element.GDP.CurrencySymbol}
+ , s.gdp_amount AS {s.element.GDP.Amount}
+ , s.reporter_id AS {s.element.Reporter}
+ FROM areas a
+ LEFT OUTER JOIN stats s
+ ON a.code = s.area_code
+ WHERE a.code = :country_code
+ </sql-query>
+
+ <sql-query name="LoadAreaStatisticsWithCustomAliases" xml:space="preserve">
+ <return class="Area" alias="a">
+ <return-discriminator column="area_type" />
+ <return-property name="id" column="code" />
+ <return-property name="Version" column="version" />
+ <return-property name="Name" column="name" />
+ </return>
+ <return-join property="a.Statistics" alias="s">
+ <return-property name="key" column="code" />
+ <return-property name="index" column="year" />
+ <return-property name="element.CitizenCount" column="citizen_count" />
+ <return-property name="element.GDP">
+ <return-column name="gdp_currency" />
+ <return-column name="gdp_amount" />
+ </return-property>
+ <return-property name="element.Reporter" column="reporter_id" />
+ </return-join>
+ SELECT a.code
+ , a.area_type
+ , a.version
+ , a.name
+ , s.year
+ , s.citizen_count
+ , s.gdp_currency
+ , s.gdp_amount
+ , s.reporter_id
+ FROM areas a
+ LEFT OUTER JOIN stats s
+ ON a.code = s.area_code
+ WHERE a.code = :country_code
+ </sql-query>
+
+ <sql-query name="LoadAreaStatisticsWithFaultyHbmAliasInjection" xml:space="preserve">
+ <return class="Area" alias="a" />
+ <return-join property="a.Statistics" alias="s" />
+ SELECT a.code AS {a.id}
+ , a.area_type AS {a.class}
+ , a.version AS {a.Version}
+ , a.name AS {a.Name}
+ , s.area_code AS {s.key}
+ , s.year AS {s.index}
+ , s.citizen_count AS {s.element.CitizenCountMisspelled}
+ , s.gdp_currency AS {s.element.GDP.CurrencySymbol}
+ , s.gdp_amount AS {s.element.GDP.Amount}
+ FROM areas a
+ LEFT OUTER JOIN stats s
+ ON a.code = s.area_code
+ WHERE a.code = :country_code
+ </sql-query>
+
+
+ <!--
+ Update queries
+ -->
+
+ <sql-query name="UpdateQueryWithoutResults">
+ -- NOP
+ </sql-query>
+
+
+ <!--
+ Scalar queries
+ -->
+
+ <sql-query name="ScalarQueryWithDefinedResultset">
+ <return-scalar column="result" type="Int32" />
+ SELECT 2 AS result
+ </sql-query>
+
+ <sql-query name="ScalarQueryWithDefinedResultsetButNoResults">
+ <!-- Pathetic case, query declares resultset but does not deliver the goods -->
+ <return-scalar column="dummy" type="Int32" />
+ <return class="Area" alias="a" />
+ -- NOP
+ </sql-query>
+
+ <sql-query name="ScalarQueryWithUndefinedResultset">
+ SELECT 1
+ </sql-query>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/MonetaryValue.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/MonetaryValue.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/MonetaryValue.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,51 @@
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public struct MonetaryValue
+ {
+ private string _currencySymbol;
+ private double _amount;
+
+ public MonetaryValue(string currencySymbol, double amount)
+ {
+ _currencySymbol = currencySymbol;
+ _amount = amount;
+ }
+
+ public string CurrencySymbol
+ {
+ get { return _currencySymbol; }
+ private set { _currencySymbol = value; }
+ }
+
+ public double Amount
+ {
+ get { return _amount; }
+ private set { _amount = value; }
+ }
+
+ public static bool operator ==(MonetaryValue left, MonetaryValue right)
+ {
+ return left._currencySymbol == right._currencySymbol && left._amount == right._amount;
+ }
+
+ public static bool operator !=(MonetaryValue left, MonetaryValue right)
+ {
+ return !(left == right);
+ }
+
+ public override bool Equals(object obj)
+ {
+ return obj is MonetaryValue ? this == (MonetaryValue) obj : false;
+ }
+
+ public override int GetHashCode()
+ {
+ return (_currencySymbol ?? string.Empty).GetHashCode() ^ _amount.GetHashCode();
+ }
+
+ public override string ToString()
+ {
+ return string.Format("{0} {1}", _currencySymbol, _amount);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/NativeSqlCollectionLoaderFixture.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,335 @@
+using System.Collections;
+using System.Collections.Generic;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ [TestFixture, Ignore("Not fixed yet.")]
+ public class NativeSqlCollectionLoaderFixture : BugTestCase
+ {
+ #region Tests - <return-join>
+
+ [Test]
+ public void LoadElementsWithWithSimpleHbmAliasInjection()
+ {
+ string[] routes = CreateRoutes();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(routes), "LoadCountryRoutesWithSimpleHbmAliasInjection");
+
+ Assert.That(country, Is.Not.Null);
+ Assert.That(country.Routes, Is.EquivalentTo(routes));
+
+ // cleanup
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete(country);
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void LoadElementsWithExplicitColumnMappings()
+ {
+ string[] routes = CreateRoutes();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(routes), "LoadCountryRoutesWithCustomAliases");
+ Assert.That(country, Is.Not.Null);
+ Assert.That(country.Routes, Is.EquivalentTo(routes));
+ // cleanup
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete(country);
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void LoadCompositeElementsWithWithSimpleHbmAliasInjection()
+ {
+ IDictionary<int, AreaStatistics> stats = CreateStatistics();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithSimpleHbmAliasInjection");
+
+ Assert.That(country, Is.Not.Null);
+ Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
+ Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
+ // cleanup
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Delete(country);
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void LoadCompositeElementsWithWithComplexHbmAliasInjection()
+ {
+ IDictionary<int, AreaStatistics> stats = CreateStatistics();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithComplexHbmAliasInjection");
+
+ Assert.That(country, Is.Not.Null);
+ Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
+ Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
+ }
+
+ [Test]
+ public void LoadCompositeElementsWithWithCustomAliases()
+ {
+ IDictionary<int, AreaStatistics> stats = CreateStatistics();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithCustomAliases");
+
+ Assert.That(country, Is.Not.Null);
+ Assert.That((ICollection) country.Statistics.Keys, Is.EquivalentTo((ICollection) stats.Keys), "Keys");
+ Assert.That((ICollection) country.Statistics.Values, Is.EquivalentTo((ICollection) stats.Values), "Elements");
+ }
+
+ [Test]
+ public void LoadEntitiesWithWithSimpleHbmAliasInjection()
+ {
+ City[] cities = CreateCities();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithSimpleHbmAliasInjection");
+ Assert.That(country, Is.Not.Null);
+ Assert.That(country.Cities, Is.EquivalentTo(cities));
+ }
+
+ [Test]
+ public void LoadEntitiesWithComplexHbmAliasInjection()
+ {
+ City[] cities = CreateCities();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithComplexHbmAliasInjection");
+ Assert.That(country, Is.Not.Null);
+ Assert.That(country.Cities, Is.EquivalentTo(cities));
+ }
+
+ [Test]
+ public void LoadEntitiesWithExplicitColumnMappings()
+ {
+ City[] cities = CreateCities();
+ Country country = LoadCountryWithNativeSQL(CreateCountry(cities), "LoadCountryCitiesWithCustomAliases");
+ Assert.That(country, Is.Not.Null);
+ Assert.That(country.Cities, Is.EquivalentTo(cities));
+ }
+
+ [Test, ExpectedException(typeof (QueryException))]
+ public void NativeQueryWithUnresolvedHbmAliasInjection()
+ {
+ IDictionary<int, AreaStatistics> stats = CreateStatistics();
+ LoadCountryWithNativeSQL(CreateCountry(stats), "LoadAreaStatisticsWithFaultyHbmAliasInjection");
+ }
+
+ private Country LoadCountryWithNativeSQL(Country country, string queryName)
+ {
+ // Ensure country is saved and session cache is empty to force from now on the reload of all
+ // persistence objects from the database.
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Save(country);
+ tx.Commit();
+ }
+ }
+ using (ISession session = OpenSession())
+ {
+ return session.GetNamedQuery(queryName).SetString("country_code", country.Code).UniqueResult<Country>();
+ }
+ }
+
+ #endregion
+
+ #region Tests - <load-collection>
+
+ [Test]
+ public void LoadElementCollectionWithCustomLoader()
+ {
+ string[] routes = CreateRoutes();
+ Country country = CreateCountry(routes);
+ Country c = SaveAndReload(country);
+ Assert.That(c, Is.Not.Null, "country");
+ Assert.That(c.Routes, Is.EquivalentTo(routes), "country.Routes");
+
+ }
+
+ [Test]
+ public void LoadCompositeElementCollectionWithCustomLoader()
+ {
+ IDictionary<int, AreaStatistics> stats = CreateStatistics();
+ Country country = CreateCountry(stats);
+ Area a = SaveAndReload(country);
+ Assert.That(a, Is.Not.Null, "area");
+ Assert.That((ICollection)a.Statistics.Keys, Is.EquivalentTo((ICollection)stats.Keys), "area.Keys");
+ Assert.That((ICollection)a.Statistics.Values, Is.EquivalentTo((ICollection)stats.Values), "area.Elements");
+ }
+
+ [Test]
+ public void LoadEntityCollectionWithCustomLoader()
+ {
+ City[] cities = CreateCities();
+ Country country = CreateCountry(cities);
+ Country c = SaveAndReload(country);
+ Assert.That(c, Is.Not.Null, "country");
+ Assert.That(c.Cities, Is.EquivalentTo(cities), "country.Cities");
+ }
+
+ private TArea SaveAndReload<TArea>(TArea area) where TArea : Area
+ {
+ //Ensure country is saved and session cache is empty to force from now on the reload of all
+ //persistence objects from the database.
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Save(area);
+ tx.Commit();
+ }
+
+ }
+ using (ISession session = OpenSession())
+ {
+ return session.Get<TArea>(area.Code);
+ }
+ }
+
+ #endregion
+
+ #region Tests - corner cases to verify backwards compatibility of NH-1612 patch
+
+ [Test]
+ public void NativeUpdateQueryWithoutResults()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.GetNamedQuery("UpdateQueryWithoutResults").ExecuteUpdate();
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void NativeScalarQueryWithoutResults()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ // Native SQL Query outcome is not validated against <return-*>
+ // resultset declarations.
+ session.GetNamedQuery("ScalarQueryWithDefinedResultsetButNoResults").ExecuteUpdate();
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void NativeScalarQueryWithUndefinedResultset()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (session.BeginTransaction())
+ {
+ // Native SQL Query outcome is not validated against <return-*>
+ // resultset declarations.
+ var result = session.GetNamedQuery("ScalarQueryWithUndefinedResultset").UniqueResult<int>();
+ Assert.That(result, Is.EqualTo(1));
+ }
+ }
+ }
+
+ [Test]
+ public void NativeScalarQueryWithDefinedResultset()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (session.BeginTransaction())
+ {
+ // Native SQL Query outcome is not validated against <return-*>
+ // resultset declarations.
+ var result = session.GetNamedQuery("ScalarQueryWithDefinedResultset").UniqueResult<int>();
+ Assert.That(result, Is.EqualTo(2));
+ }
+ }
+ }
+
+ #endregion
+
+ #region Factory methods
+
+ private static Country CreateCountry()
+ {
+ const string COUNTRY_CODE = "WL";
+ const string COUNTRY_NAME = "Wonderland";
+ return new Country(COUNTRY_CODE, COUNTRY_NAME);
+ }
+
+ private static Country CreateCountry(params string[] routes)
+ {
+ Country country = CreateCountry();
+ foreach (var route in routes)
+ {
+ country.Routes.Add(route);
+ }
+ return country;
+ }
+
+ private static Country CreateCountry(params City[] cities)
+ {
+ Country country = CreateCountry();
+ foreach (var city in cities)
+ {
+ city.SetParent(country);
+ }
+ return country;
+ }
+
+ private static Country CreateCountry(IDictionary<int, AreaStatistics> statistics)
+ {
+ Country country = CreateCountry();
+ foreach (var pair in statistics)
+ {
+ country.Statistics.Add(pair);
+ }
+ return country;
+ }
+
+ private static string[] CreateRoutes()
+ {
+ return new[] {"Yellow Road", "Muddy Path"};
+ }
+
+ private static City[] CreateCities()
+ {
+ return new[] {new City("EMR", "Emerald City"), new City("GLD", "Golden Town"), new City("NTH", "North End")};
+ }
+
+ private static IDictionary<int, AreaStatistics> CreateStatistics()
+ {
+ var archimedes = new Person("Archimedes");
+ var archibald = new Person("Archibald");
+ var amy = new Person("Amy");
+ return new Dictionary<int, AreaStatistics>
+ {
+ {
+ 1850,
+ new AreaStatistics {CitizenCount = 10000, GDP = new MonetaryValue("USD", 20000), Reporter = archimedes}
+ },
+ {
+ 1900,
+ new AreaStatistics {CitizenCount = 20000, GDP = new MonetaryValue("USD", 50000), Reporter = archibald}
+ },
+ {1950, new AreaStatistics {CitizenCount = 40000, GDP = new MonetaryValue("USD", 125000)}},
+ {2000, new AreaStatistics {CitizenCount = 80000, GDP = new MonetaryValue("USD", 500000), Reporter = amy}},
+ };
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1612/Person.cs 2009-01-02 14:37:21 UTC (rev 3969)
@@ -0,0 +1,52 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1612
+{
+ public class Person
+ {
+ public virtual Guid PersonId { get; private set; }
+ public virtual string Name...
[truncated message content] |
|
From: <fab...@us...> - 2009-01-10 12:47:37
|
Revision: 3985
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3985&view=rev
Author: fabiomaulo
Date: 2009-01-10 12:47:32 +0000 (Sat, 10 Jan 2009)
Log Message:
-----------
Test for NH-1584
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Calico.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/CoatPattern.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Female.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Male.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Tabby.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Calico.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Calico.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Calico.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,19 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ /// <summary>
+ /// This class describes a few of the attributes possbile for a "Calico" coat.
+ /// </summary>
+ public class Calico : CoatPattern
+ {
+ public Calico()
+ {
+ Description = "Orange, black and white coloration.";
+ }
+
+ public virtual Female Cat { get; set; }
+
+ public virtual bool HasPatches { get; set; }
+
+ public virtual bool IsMottled { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Cat.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,9 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ public abstract class Cat
+ {
+ public virtual int Id { get; private set; }
+
+ public virtual string Name { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/CoatPattern.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/CoatPattern.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/CoatPattern.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,9 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ public abstract class CoatPattern
+ {
+ public virtual int Id { get; private set; }
+
+ public virtual string Description { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Female.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Female.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Female.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,23 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ /// <summary>
+ /// This class assumes that all female cats have a calico coat (which is not actually true).
+ /// </summary>
+ public class Female : Cat
+ {
+ private Calico _coat;
+
+ public virtual Calico Coat
+ {
+ get { return _coat; }
+ set
+ {
+ if (value != null)
+ {
+ _coat = value;
+ _coat.Cat = this;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Male.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Male.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Male.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,23 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ /// <summary>
+ /// This class assumes that all male cats have a tabby coat pattern (which is not true).
+ /// </summary>
+ public class Male : Cat
+ {
+ private Tabby _coat;
+
+ public virtual Tabby Coat
+ {
+ get { return _coat; }
+ set
+ {
+ if (value != null)
+ {
+ _coat = value;
+ _coat.Cat = this;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Mappings.hbm.xml 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1584" >
+ <class name="Cat" abstract="true" >
+ <id name="Id" unsaved-value="0">
+ <generator class="native"/>
+ </id>
+ <property name="Name"/>
+
+ <joined-subclass name="Male">
+ <key column="CatId"/>
+ <one-to-one name="Coat" cascade="all"/>
+ </joined-subclass>
+
+ <joined-subclass name="Female">
+ <key column="CatId"/>
+ <one-to-one name="Coat" cascade="all"/>
+ </joined-subclass>
+ </class>
+
+ <class name="Tabby">
+ <id name="Id">
+ <generator class="foreign">
+ <param name="property">Cat</param>
+ </generator>
+ </id>
+ <property name="HasSpots" />
+ <property name="HasStripes" />
+ <property name="HasSwirls" />
+ <one-to-one name="Cat" constrained="true"/>
+ </class>
+
+ <class name="Calico">
+ <id name="Id">
+ <generator class="foreign">
+ <param name="property">Cat</param>
+ </generator>
+ </id>
+ <property name="HasPatches" />
+ <property name="IsMottled" />
+ <one-to-one name="Cat" constrained="true"/>
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Tabby.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Tabby.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/Tabby.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,21 @@
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ /// <summary>
+ /// This class describes a few of the properties of a "Tabby" coat pattern.
+ /// </summary>
+ public class Tabby : CoatPattern
+ {
+ public Tabby()
+ {
+ Description = "A distinctive coat that features stripes, dots, or swirling patterns.";
+ }
+
+ public virtual Male Cat { get; set; }
+
+ public virtual bool HasSpots { get; set; }
+
+ public virtual bool HasStripes { get; set; }
+
+ public virtual bool HasSwirls { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1584/TestFixture.cs 2009-01-10 12:47:32 UTC (rev 3985)
@@ -0,0 +1,60 @@
+/*
+ The documentation for NHibernate likes to work with cats / kittens for examples or demonstrations.
+*/
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1584
+{
+ [TestFixture, Ignore("Not supported yet.")]
+ public class TestFixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1584"; }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction trx = session.BeginTransaction())
+ {
+ session.Delete("from Male");
+ trx.Commit();
+ }
+ }
+ }
+
+ /// <summary>
+ /// Demostrate that the session is able to load the one-to-one composition between a joined subclass and its related entity.
+ /// </summary>
+ [Test]
+ public void Load_One_To_One_Composition_For_Joined_Subclass_Succeeds()
+ {
+ var tabby = new Tabby {HasSpots = true, HasStripes = true, HasSwirls = false};
+
+ var newInstance = new Male {Name = "Male", Coat = tabby};
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction trx = session.BeginTransaction())
+ {
+ session.Save(newInstance);
+ trx.Commit();
+ }
+ }
+
+ Assert.AreNotEqual(0, newInstance.Id);
+ Assert.AreNotEqual(0, tabby.Id);
+
+ using (ISession session = OpenSession())
+ {
+ ICriteria criteria = session.CreateCriteria(typeof (Cat));
+ var loaded = criteria.Add(Restrictions.Eq("Id", newInstance.Id)).UniqueResult<Male>();
+
+ Assert.IsNotNull(loaded.Coat);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 02:25:05 UTC (rev 3984)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-01-10 12:47:32 UTC (rev 3985)
@@ -382,6 +382,13 @@
<Compile Include="NHSpecificTest\NH1549\EntityInt32.cs" />
<Compile Include="NHSpecificTest\NH1549\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1549\ProductWithInheritedId.cs" />
+ <Compile Include="NHSpecificTest\NH1584\Calico.cs" />
+ <Compile Include="NHSpecificTest\NH1584\Cat.cs" />
+ <Compile Include="NHSpecificTest\NH1584\CoatPattern.cs" />
+ <Compile Include="NHSpecificTest\NH1584\Female.cs" />
+ <Compile Include="NHSpecificTest\NH1584\Male.cs" />
+ <Compile Include="NHSpecificTest\NH1584\Tabby.cs" />
+ <Compile Include="NHSpecificTest\NH1584\TestFixture.cs" />
<Compile Include="NHSpecificTest\NH1605\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1609\Entities.cs" />
<Compile Include="NHSpecificTest\NH1609\Fixture.cs" />
@@ -1590,6 +1597,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1584\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1632\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1612\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1549\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-03 12:45:35
|
Revision: 4017
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4017&view=rev
Author: fabiomaulo
Date: 2009-02-03 12:45:32 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
Example of OracleClientExceptionConverterExample
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs
Added: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/OracleClientExceptionConverterExample.cs 2009-02-03 12:45:32 UTC (rev 4017)
@@ -0,0 +1,31 @@
+using System;
+using System.Data.OracleClient;
+using NHibernate.Exceptions;
+using NHibernate.SqlCommand;
+
+namespace NHibernate.Test.ExceptionsTest
+{
+ public class OracleClientExceptionConverterExample : ISQLExceptionConverter
+ {
+ #region ISQLExceptionConverter Members
+
+ public ADOException Convert(Exception sqlException, string message, SqlString sql)
+ {
+ var sqle = ADOExceptionHelper.ExtractDbException(sqlException) as OracleException;
+ if (sqle != null)
+ {
+ if (sqle.Code == 1036)
+ {
+ return new ConstraintViolationException(message, sqle.InnerException, sql, null);
+ }
+ if (sqle.Code == 942)
+ {
+ return new SQLGrammarException(message, sqle.InnerException, sql);
+ }
+ }
+ return SQLStateConverter.HandledNonSpecificException(sqlException, message, sql);
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-03 04:21:15 UTC (rev 4016)
+++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-03 12:45:32 UTC (rev 4017)
@@ -18,16 +18,21 @@
protected override IList Mappings
{
- get { return new string[] { "ExceptionsTest.User.hbm.xml", "ExceptionsTest.Group.hbm.xml" }; }
+ get { return new[] { "ExceptionsTest.User.hbm.xml", "ExceptionsTest.Group.hbm.xml" }; }
}
protected override void Configure(Cfg.Configuration configuration)
{
if(Dialect is MsSql2000Dialect)
{
- configuration.SetProperty(NHibernate.Cfg.Environment.SqlExceptionConverter,
+ configuration.SetProperty(Cfg.Environment.SqlExceptionConverter,
typeof (MSSQLExceptionConverterExample).AssemblyQualifiedName);
}
+ if (Dialect is Oracle8iDialect)
+ {
+ configuration.SetProperty(Cfg.Environment.SqlExceptionConverter,
+ typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName);
+ }
}
[Test]
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 04:21:15 UTC (rev 4016)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 12:45:32 UTC (rev 4017)
@@ -65,6 +65,7 @@
<Reference Include="System" />
<Reference Include="System.configuration" />
<Reference Include="System.Data" />
+ <Reference Include="System.Data.OracleClient" />
<Reference Include="System.Transactions" />
<Reference Include="System.Xml" />
</ItemGroup>
@@ -197,6 +198,7 @@
<Compile Include="Events\Collections\Values\ValuesBagCollectionEventFixture.cs" />
<Compile Include="ExceptionsTest\Group.cs" />
<Compile Include="ExceptionsTest\MSSQLExceptionConverterExample.cs" />
+ <Compile Include="ExceptionsTest\OracleClientExceptionConverterExample.cs" />
<Compile Include="ExceptionsTest\PropertyAccessExceptionFixture.cs" />
<Compile Include="ExceptionsTest\SQLExceptionConversionTest.cs" />
<Compile Include="ExceptionsTest\User.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-03 17:16:04
|
Revision: 4023
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4023&view=rev
Author: fabiomaulo
Date: 2009-02-03 17:16:02 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
Ignoring test (Multi-query)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs 2009-02-03 16:43:11 UTC (rev 4022)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1253/Fixture.cs 2009-02-03 17:16:02 UTC (rev 4023)
@@ -1,5 +1,6 @@
using System.Collections;
using System.Collections.Generic;
+using NHibernate.Driver;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.NH1253
@@ -80,6 +81,12 @@
[Test]
public void MultiQuerySingleInList()
{
+ IDriver driver = sessions.ConnectionProvider.Driver;
+ if (!driver.SupportsMultipleQueries)
+ {
+ Assert.Ignore("Driver {0} does not support multi-queries", driver.GetType().FullName);
+ }
+
using (ISession s = OpenSession())
{
using (ITransaction tx = s.BeginTransaction())
Modified: trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2009-02-03 16:43:11 UTC (rev 4022)
+++ trunk/nhibernate/src/NHibernate.Test/ProjectionFixtures/Fixture.cs 2009-02-03 17:16:02 UTC (rev 4023)
@@ -1,7 +1,5 @@
-using System;
-using NHibernate;
using NHibernate.Criterion;
-using NHibernate.Test.PropertyRef;
+using NHibernate.Driver;
using NUnit.Framework;
namespace NHibernate.Test.ProjectionFixtures
@@ -65,12 +63,17 @@
[Test]
- [ExpectedException(typeof(ADOException), ExpectedMessage = @"could not execute query
-[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = @p0 ]
-Positional parameters: #0>2
-[SQL: SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = @p0]")]
public void ErrorFromDBWillGiveTheActualSQLExecuted()
{
+ string pName = ((ISqlParameterFormatter) sessions.ConnectionProvider.Driver).GetParameterName(0);
+ string expectedMessage =
+ string.Format(
+ @"could not execute query
+[ SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = {0} ]
+Positional parameters: #0>2
+[SQL: SELECT this_.Id as y0_, count(this_.Area) as y1_ FROM TreeNode this_ WHERE this_.Id = {1}]",
+ pName, pName);
+
DetachedCriteria projection = DetachedCriteria.For<TreeNode>("child")
.Add(Restrictions.Eq("child.Key.Id", 2))
.SetProjection(
@@ -78,7 +81,8 @@
.Add(Projections.Property("child.Key.Id"))
.Add(Projections.Count("child.Key.Area"))
);
-
+ try
+ {
using (var s = sessions.OpenSession())
using (var tx = s.BeginTransaction())
{
@@ -87,6 +91,13 @@
tx.Commit();
}
+ Assert.Fail();
+ }
+ catch (ADOException e)
+ {
+ if(e.Message != expectedMessage)
+ throw;
+ }
}
[Test]
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-03 22:32:24
|
Revision: 4026
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4026&view=rev
Author: fabiomaulo
Date: 2009-02-03 22:32:20 +0000 (Tue, 03 Feb 2009)
Log Message:
-----------
Simple Pagination test
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Pagination/
trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.cs
trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Pagination/PaginationFixture.cs
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 20:14:58 UTC (rev 4025)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-03 22:32:20 UTC (rev 4026)
@@ -855,6 +855,8 @@
<Compile Include="Operations\PersonalDetails.cs" />
<Compile Include="Operations\TimestampedEntity.cs" />
<Compile Include="Operations\VersionedEntity.cs" />
+ <Compile Include="Pagination\DataPoint.cs" />
+ <Compile Include="Pagination\PaginationFixture.cs" />
<Compile Include="ProjectionFixtures\Key.cs" />
<Compile Include="ProjectionFixtures\Fixture.cs" />
<Compile Include="ProjectionFixtures\NodeType.cs" />
@@ -1614,6 +1616,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
Added: trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.cs 2009-02-03 22:32:20 UTC (rev 4026)
@@ -0,0 +1,10 @@
+namespace NHibernate.Test.Pagination
+{
+ public class DataPoint
+ {
+ public virtual long Id { get; set; }
+ public virtual double X { get; set; }
+ public virtual double Y { get; set; }
+ public virtual string Description { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Pagination/DataPoint.hbm.xml 2009-02-03 22:32:20 UTC (rev 4026)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Pagination">
+
+ <class name="DataPoint" dynamic-update="true">
+ <!--rowid="rowid"-->
+ <!-- remove this if not oracle -->
+ <id name="Id">
+ <generator class="increment"/>
+ </id>
+ <property name="X">
+ <column name="xval" not-null="true" precision="4" unique-key="xy"/>
+ </property>
+ <property name="Y">
+ <column name="yval" not-null="true" precision="4" unique-key="xy"/>
+ </property>
+ <property name="Description"/>
+ </class>
+
+</hibernate-mapping>
+
Added: trunk/nhibernate/src/NHibernate.Test/Pagination/PaginationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Pagination/PaginationFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Pagination/PaginationFixture.cs 2009-02-03 22:32:20 UTC (rev 4026)
@@ -0,0 +1,73 @@
+using System;
+using System.Collections;
+using NHibernate.Cfg;
+using NHibernate.Criterion;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+using Environment=NHibernate.Cfg.Environment;
+
+namespace NHibernate.Test.Pagination
+{
+ [TestFixture]
+ public class PaginationFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"Pagination.DataPoint.hbm.xml"}; }
+ }
+
+ protected override void Configure(Configuration configuration)
+ {
+ cfg.SetProperty(Environment.DefaultBatchFetchSize, "20");
+ }
+
+ protected override string CacheConcurrencyStrategy
+ {
+ get { return null; }
+ }
+
+ [Test]
+ public void PagTest()
+ {
+ using(ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ for (int i = 0; i < 10; i++)
+ {
+ var dp = new DataPoint {X = (i * 0.1d)};
+ dp.Y = Math.Cos(dp.X);
+ s.Persist(dp);
+ }
+ t.Commit();
+ }
+
+ using(ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ int size =
+ s.CreateSQLQuery("select Id, xval, yval, Description from DataPoint order by xval, yval").AddEntity(
+ typeof (DataPoint)).SetMaxResults(5).List().Count;
+ Assert.That(size, Is.EqualTo(5));
+ size = s.CreateQuery("from DataPoint dp order by dp.X, dp.Y").SetFirstResult(5).SetMaxResults(2).List().Count;
+ Assert.That(size, Is.EqualTo(2));
+ size =
+ s.CreateCriteria(typeof (DataPoint)).AddOrder(Order.Asc("X")).AddOrder(Order.Asc("Y")).SetFirstResult(8).List().
+ Count;
+ Assert.That(size, Is.EqualTo(2));
+ t.Commit();
+ }
+
+ using(ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Delete("from DataPoint");
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-04 04:19:04
|
Revision: 4030
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4030&view=rev
Author: darioquintana
Date: 2009-02-04 04:18:37 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Exception Converter example for PostgreSQL
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs
Added: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/PostgresExceptionConverterExample.cs 2009-02-04 04:18:37 UTC (rev 4030)
@@ -0,0 +1,31 @@
+using System;
+using System.Data.Common;
+using NHibernate;
+using NHibernate.Exceptions;
+using NHibernate.SqlCommand;
+
+public class PostgresExceptionConverterExample : ISQLExceptionConverter
+{
+ #region ISQLExceptionConverter Members
+
+ public ADOException Convert(Exception sqlException, string message, SqlString sql)
+ {
+ var sqle = ADOExceptionHelper.ExtractDbException(sqlException) as DbException;
+ if (sqle != null)
+ {
+ string code = (string) sqle.GetType().GetProperty("Code").GetValue(sqle, null);
+
+ if (code == "23503")
+ {
+ return new ConstraintViolationException(message, sqle.InnerException, sql, null);
+ }
+ if (code == "42P01")
+ {
+ return new SQLGrammarException(message, sqle.InnerException, sql);
+ }
+ }
+ return SQLStateConverter.HandledNonSpecificException(sqlException, message, sql);
+ }
+
+ #endregion
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-04 03:40:06 UTC (rev 4029)
+++ trunk/nhibernate/src/NHibernate.Test/ExceptionsTest/SQLExceptionConversionTest.cs 2009-02-04 04:18:37 UTC (rev 4030)
@@ -33,6 +33,12 @@
configuration.SetProperty(Cfg.Environment.SqlExceptionConverter,
typeof(OracleClientExceptionConverterExample).AssemblyQualifiedName);
}
+
+ if (Dialect is PostgreSQL82Dialect)
+ {
+ configuration.SetProperty(Cfg.Environment.SqlExceptionConverter,
+ typeof(PostgresExceptionConverterExample).AssemblyQualifiedName);
+ }
}
[Test]
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 03:40:06 UTC (rev 4029)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 04:18:37 UTC (rev 4030)
@@ -196,6 +196,7 @@
<Compile Include="Events\Collections\IParentWithCollection.cs" />
<Compile Include="Events\Collections\Values\ParentWithCollectionOfValues.cs" />
<Compile Include="Events\Collections\Values\ValuesBagCollectionEventFixture.cs" />
+ <Compile Include="ExceptionsTest\PostgresExceptionConverterExample.cs" />
<Compile Include="ExceptionsTest\Group.cs" />
<Compile Include="ExceptionsTest\MSSQLExceptionConverterExample.cs" />
<Compile Include="ExceptionsTest\OracleClientExceptionConverterExample.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-04 04:21:18
|
Revision: 4031
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4031&view=rev
Author: darioquintana
Date: 2009-02-04 04:21:16 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
renaming the fixture and using removed
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-02-04 04:18:37 UTC (rev 4030)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs 2009-02-04 04:21:16 UTC (rev 4031)
@@ -1,124 +0,0 @@
-using NHibernate.Criterion;
-using NHibernate.Impl;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.Futures
-{
- using System.Collections;
-
- [TestFixture]
- public class Fixture : TestCase
- {
-
- protected override IList Mappings
- {
- get { return new string[] { "NHSpecificTest.Futures.Mappings.hbm.xml" }; }
- }
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- [Test]
- public void CanUseFutureCriteria()
- {
- using (var s = sessions.OpenSession())
- {
- if(((SessionFactoryImpl)sessions)
- .ConnectionProvider.Driver.SupportsMultipleQueries == false)
- {
- Assert.Ignore("Not applicable for dialects that do not support multiple queries");
- }
-
- var persons10 = s.CreateCriteria(typeof(Person))
- .SetMaxResults(10)
- .Future<Person>();
- var persons5 = s.CreateCriteria(typeof(Person))
- .SetMaxResults(5)
- .Future<int>();
-
- using (var logSpy = new SqlLogSpy())
- {
- foreach (var person in persons5)
- {
-
- }
-
- foreach (var person in persons10)
- {
-
- }
-
- var events = logSpy.Appender.GetEvents();
- Assert.AreEqual(1, events.Length);
- }
- }
- }
-
- [Test]
- public void TwoFuturesRunInTwoRoundTrips()
- {
- using (var s = sessions.OpenSession())
- {
- if (((SessionFactoryImpl)sessions)
- .ConnectionProvider.Driver.SupportsMultipleQueries == false)
- {
- Assert.Ignore("Not applicable for dialects that do not support multiple queries");
- }
-
- using (var logSpy = new SqlLogSpy())
- {
- var persons10 = s.CreateCriteria(typeof(Person))
- .SetMaxResults(10)
- .Future<Person>();
-
- foreach (var person in persons10) { } // fire first future round-trip
-
- var persons5 = s.CreateCriteria(typeof(Person))
- .SetMaxResults(5)
- .Future<int>();
-
- foreach (var person in persons5) { } // fire second future round-trip
-
- var events = logSpy.Appender.GetEvents();
- Assert.AreEqual(2, events.Length);
- }
- }
- }
-
- [Test]
- public void CanCombineSingleFutureValueWithEnumerableFutures()
- {
- using (var s = sessions.OpenSession())
- {
- if (((SessionFactoryImpl)sessions)
- .ConnectionProvider.Driver.SupportsMultipleQueries == false)
- {
- Assert.Ignore("Not applicable for dialects that do not support multiple queries");
- }
-
- var persons = s.CreateCriteria(typeof(Person))
- .SetMaxResults(10)
- .Future<Person>();
-
- var personCount = s.CreateCriteria(typeof(Person))
- .SetProjection(Projections.RowCount())
- .FutureValue<int>();
-
- using (var logSpy = new SqlLogSpy())
- {
- int count = personCount.Value;
-
- foreach (var person in persons)
- {
-
- }
-
- var events = logSpy.Appender.GetEvents();
- Assert.AreEqual(1, events.Length);
- }
- }
- }
- }
-}
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs (from rev 4029, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureCriteriaFixture.cs 2009-02-04 04:21:16 UTC (rev 4031)
@@ -0,0 +1,124 @@
+using NHibernate.Criterion;
+using NHibernate.Impl;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Futures
+{
+ using System.Collections;
+
+ [TestFixture]
+ public class FutureCriteriaFixture : TestCase
+ {
+
+ protected override IList Mappings
+ {
+ get { return new string[] { "NHSpecificTest.Futures.Mappings.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ public void CanUseFutureCriteria()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if(((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons10 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+ var persons5 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(5)
+ .Future<int>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ foreach (var person in persons5)
+ {
+
+ }
+
+ foreach (var person in persons10)
+ {
+
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
+
+ [Test]
+ public void TwoFuturesRunInTwoRoundTrips()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ var persons10 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ foreach (var person in persons10) { } // fire first future round-trip
+
+ var persons5 = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(5)
+ .Future<int>();
+
+ foreach (var person in persons5) { } // fire second future round-trip
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(2, events.Length);
+ }
+ }
+ }
+
+ [Test]
+ public void CanCombineSingleFutureValueWithEnumerableFutures()
+ {
+ using (var s = sessions.OpenSession())
+ {
+ if (((SessionFactoryImpl)sessions)
+ .ConnectionProvider.Driver.SupportsMultipleQueries == false)
+ {
+ Assert.Ignore("Not applicable for dialects that do not support multiple queries");
+ }
+
+ var persons = s.CreateCriteria(typeof(Person))
+ .SetMaxResults(10)
+ .Future<Person>();
+
+ var personCount = s.CreateCriteria(typeof(Person))
+ .SetProjection(Projections.RowCount())
+ .FutureValue<int>();
+
+ using (var logSpy = new SqlLogSpy())
+ {
+ int count = personCount.Value;
+
+ foreach (var person in persons)
+ {
+
+ }
+
+ var events = logSpy.Appender.GetEvents();
+ Assert.AreEqual(1, events.Length);
+ }
+ }
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs 2009-02-04 04:18:37 UTC (rev 4030)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/FutureQueryFixture.cs 2009-02-04 04:21:16 UTC (rev 4031)
@@ -1,5 +1,4 @@
-using NHibernate.Criterion;
-using NHibernate.Impl;
+using NHibernate.Impl;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.Futures
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 04:18:37 UTC (rev 4030)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 04:21:16 UTC (rev 4031)
@@ -381,7 +381,7 @@
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
- <Compile Include="NHSpecificTest\Futures\Fixture.cs" />
+ <Compile Include="NHSpecificTest\Futures\FutureCriteriaFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
<Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\AllDates.cs" />
<Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\DateTime2AndDateTimeOffSetFixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-04 12:59:44
|
Revision: 4034
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4034&view=rev
Author: darioquintana
Date: 2009-02-04 12:59:40 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
adding test for NH-1654
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Employee.cs 2009-02-04 12:59:40 UTC (rev 4034)
@@ -0,0 +1,11 @@
+namespace NHibernate.Test.NHSpecificTest.NH1654
+{
+ public class Employee
+ {
+ public virtual int Id { get; set; }
+
+ public virtual string FirstName { get; set; }
+
+ public virtual string FirstNameFormula { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Fixture.cs 2009-02-04 12:59:40 UTC (rev 4034)
@@ -0,0 +1,48 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1654
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1654"; }
+ }
+
+ [Test,Ignore]
+ public void Test()
+ {
+ int employeeId;
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ var emp = new Employee();
+ emp.Id = 1;
+ emp.FirstName = "John";
+
+ sess.Save(emp);
+
+ tx.Commit();
+
+ employeeId = emp.Id;
+ }
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ var load = sess.Load<Employee>(employeeId);
+ Assert.AreEqual("John", load.FirstNameFormula);
+
+ tx.Commit();
+ }
+
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ sess.Delete("from Employee");
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1654/Mappings.hbm.xml 2009-02-04 12:59:40 UTC (rev 4034)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1654"
+ assembly="NHibernate.Test">
+
+ <class name="Employee" table="EMPLOYEES" >
+ <id name="Id" column="EMPLOYEE_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+ <property name="FirstName" column="FirstName" type="String" />
+ <property name="FirstNameFormula"
+ formula="(SELECT TOP 1 FirstName FROM EMPLOYEES e WHERE e.EMPLOYEE_ID = EMPLOYEE_ID)"
+ />
+
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 12:59:40 UTC (rev 4034)
@@ -593,6 +593,8 @@
<Compile Include="NHSpecificTest\NH1643\Department.cs" />
<Compile Include="NHSpecificTest\NH1643\Employee.cs" />
<Compile Include="NHSpecificTest\NH1643\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1654\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1654\Employee.cs" />
<Compile Include="NHSpecificTest\NH280\Fixture.cs" />
<Compile Include="NHSpecificTest\NH280\Foo.cs" />
<Compile Include="NHSpecificTest\NH1018\Employee.cs" />
@@ -1617,6 +1619,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1654\Mappings.hbm.xml" />
<EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-04 22:19:13
|
Revision: 4044
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4044&view=rev
Author: darioquintana
Date: 2009-02-04 21:49:37 +0000 (Wed, 04 Feb 2009)
Log Message:
-----------
Refactoring: running datetimes test in a separated way
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/AllDates.cs 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/AllDates.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,6 +1,6 @@
using System;
-namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
+namespace NHibernate.Test.NHSpecificTest.Dates
{
public class AllDates
{
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2AndDateTimeOffSetFixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,85 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Dialect;
-using NHibernate.Type;
-using NUnit.Framework;
-
-namespace NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet
-{
- [TestFixture]
- public class DateTime2AndDateTimeOffSetFixture : TestCase
- {
- protected override IList Mappings
- {
- get { return new[] {"NHSpecificTest.DateTime2AndDateTimeOffSet.Mappings.hbm.xml"}; }
- }
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- protected override bool AppliesTo(Dialect.Dialect dialect)
- {
- return dialect is MsSql2008Dialect;
- }
-
-
- public class DateTimeAssert
- {
- public static void AreEqual(DateTime dt1, DateTime dt2)
- {
- bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
-
- if (!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
-
- public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
- {
- bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
-
- if (!areEqual)
- Assert.Fail("Expected {0} but was {1}");
- }
- }
-
- [Test]
- public void SavingAndRetrieving()
- {
- DateTime Now = DateTime.Now;
- DateTimeOffset NowOS = DateTimeOffset.Now;
- var dates = new AllDates
- {
- Sql_datetime = Now,
- Sql_datetime2 = DateTime.MinValue,
- Sql_datetimeoffset = NowOS,
- };
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- s.Save(dates);
- tx.Commit();
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
-
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetime, Now);
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetime2, DateTime.MinValue);
- DateTimeAssert.AreEqual(datesRecovered.Sql_datetimeoffset, NowOS);
- }
-
- using (ISession s = OpenSession())
- using (ITransaction tx = s.BeginTransaction())
- {
- var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
- s.Delete(datesRecovered);
- tx.Commit();
- }
- }
- }
-}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTime2Fixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class DateTime2Fixture : DatesFixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.DateTime2.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTime Now = DateTime.Now;
+
+ SavingAndRetrievingAction(new AllDates {Sql_datetime2 = Now},
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, Now));
+
+
+ SavingAndRetrievingAction(new AllDates { Sql_datetime2 = DateTime.MinValue },
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, DateTime.MinValue));
+
+ SavingAndRetrievingAction(new AllDates { Sql_datetime2 = DateTime.MaxValue },
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetime2, DateTime.MaxValue));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeAssert.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,25 @@
+using System;
+using NHibernate.Type;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ public class DateTimeAssert
+ {
+ public static void AreEqual(DateTime dt1, DateTime dt2)
+ {
+ bool areEqual = new DateTimeType().IsEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail(string.Format("Expected {0} but was {1}",dt1,dt2));
+ }
+
+ public static void AreEqual(DateTimeOffset dt1, DateTimeOffset dt2)
+ {
+ bool areEqual = new DateTimeOffsetType().IsEqual(dt1, dt2);
+
+ if (!areEqual)
+ Assert.Fail(string.Format("Expected {0} but was {1}", dt1, dt2));
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/DateTime2AndDateTimeOffSetFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DateTimeOffSetFixture.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,24 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public class DateTimeOffSetFixture : DatesFixtureBase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.Dates.Mappings.DateTimeOffset.hbm.xml"}; }
+ }
+
+ [Test]
+ public void SavingAndRetrievingTest()
+ {
+ DateTimeOffset NowOS = DateTimeOffset.Now;
+
+ SavingAndRetrievingAction(new AllDates {Sql_datetimeoffset = NowOS},
+ entity => DateTimeAssert.AreEqual(entity.Sql_datetimeoffset, NowOS));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/DatesFixtureBase.cs 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,51 @@
+using System;
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.Dates
+{
+ [TestFixture]
+ public abstract class DatesFixtureBase : TestCase
+ {
+ protected abstract override IList Mappings { get; }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2008Dialect;
+ }
+
+ protected void SavingAndRetrievingAction(AllDates entity, Action<AllDates> action)
+ {
+ AllDates dates = entity;
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(dates);
+ tx.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+
+ action.Invoke(datesRecovered);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var datesRecovered = s.CreateQuery("from AllDates").UniqueResult<AllDates>();
+ s.Delete(datesRecovered);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTime2.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_datetime2" type="datetime2" />
+
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml (from rev 4033, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings/DateTimeOffset.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Dates"
+ assembly="NHibernate.Test">
+
+ <class name="AllDates" lazy="false">
+
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+
+ <property name="Sql_datetimeoffset" type="datetimeoffset" />
+
+ </class>
+
+</hibernate-mapping>
Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/DateTime2AndDateTimeOffSet/Mappings.hbm.xml 2009-02-04 04:46:26 UTC (rev 4033)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/Mappings.hbm.xml 2009-02-04 21:49:37 UTC (rev 4044)
@@ -1,18 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
- namespace="NHibernate.Test.NHSpecificTest.DateTime2AndDateTimeOffSet"
- assembly="NHibernate.Test">
-
- <class name="AllDates" lazy="false">
-
- <id name="Id">
- <generator class="identity"/>
- </id>
-
- <property name="Sql_datetime" />
- <property name="Sql_datetime2" type="datetime2" />
- <property name="Sql_datetimeoffset" type="datetimeoffset" />
-
- </class>
-
-</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 20:49:36 UTC (rev 4043)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 21:49:37 UTC (rev 4044)
@@ -380,11 +380,14 @@
<Compile Include="NHSpecificTest\BasicTimeFixture.cs" />
<Compile Include="NHSpecificTest\BugTestCase.cs" />
<Compile Include="NHSpecificTest\CollectionFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\DatesFixtureBase.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
<Compile Include="NHSpecificTest\Futures\FutureCriteriaFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
- <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\AllDates.cs" />
- <Compile Include="NHSpecificTest\DateTime2AndDateTimeOffSet\DateTime2AndDateTimeOffSetFixture.cs" />
+ <Compile Include="NHSpecificTest\Dates\AllDates.cs" />
+ <Compile Include="NHSpecificTest\Dates\DateTimeOffSetFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
@@ -1619,9 +1622,10 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTimeOffset.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1654\Mappings.hbm.xml" />
<EmbeddedResource Include="Pagination\DataPoint.hbm.xml" />
- <EmbeddedResource Include="NHSpecificTest\DateTime2AndDateTimeOffSet\Mappings.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\Dates\Mappings\DateTime2.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Futures\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1643\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1640\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-05 04:47:08
|
Revision: 4047
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4047&view=rev
Author: fabiomaulo
Date: 2009-02-05 04:47:03 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Test for SequenceIdentity feature
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.cs
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.hbm.xml
trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.cs 2009-02-05 04:47:03 UTC (rev 4047)
@@ -0,0 +1,19 @@
+namespace NHibernate.Test.Generatedkeys.Seqidentity
+{
+ public class MyEntity
+ {
+ private int id;
+ private string name;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/MyEntity.hbm.xml 2009-02-05 04:47:03 UTC (rev 4047)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Generatedkeys.Seqidentity"
+ default-access="field">
+
+ <class name="MyEntity" table="my_entity">
+
+ <id name="id">
+ <generator class="sequence-identity"/>
+ </id>
+ <natural-id>
+ <property name="name"/>
+ </natural-id>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Generatedkeys/Seqidentity/SequenceIdentityFixture.cs 2009-02-05 04:47:03 UTC (rev 4047)
@@ -0,0 +1,41 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Generatedkeys.Seqidentity
+{
+ [TestFixture, Ignore("Solution not implemented yet.")]
+ public class SequenceIdentityFixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "Generatedkeys.Seqidentity.MyEntity.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect.SupportsSequences;
+ }
+
+ [Test]
+ public void SequenceIdentityGenerator()
+ {
+ ISession session = OpenSession();
+ session.BeginTransaction();
+
+ var e = new MyEntity{Name="entity-1"};
+ session.Save(e);
+
+ // this insert should happen immediately!
+ Assert.AreEqual(1, e.Id, "id not generated through forced insertion");
+
+ session.Delete(e);
+ session.Transaction.Commit();
+ session.Close();
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-04 22:54:43 UTC (rev 4046)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 04:47:03 UTC (rev 4047)
@@ -250,6 +250,8 @@
<Compile Include="Generatedkeys\Identity\MySibling.cs" />
<Compile Include="Generatedkeys\Select\MyEntity.cs" />
<Compile Include="Generatedkeys\Select\SelectGeneratorTest.cs" />
+ <Compile Include="Generatedkeys\Seqidentity\MyEntity.cs" />
+ <Compile Include="Generatedkeys\Seqidentity\SequenceIdentityFixture.cs" />
<Compile Include="GeneratedTest\AbstractGeneratedPropertyTest.cs" />
<Compile Include="GeneratedTest\Component.cs" />
<Compile Include="GeneratedTest\ComponentOwner.cs" />
@@ -1627,6 +1629,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Generatedkeys\Seqidentity\MyEntity.hbm.xml" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Dates\Mappings\Time.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Dates\Mappings\Date.hbm.xml" />
@@ -1750,4 +1753,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-05 06:51:14
|
Revision: 4050
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4050&view=rev
Author: darioquintana
Date: 2009-02-05 06:50:53 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Workaround to use SqlServer2008 FileStream
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Convert.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/VendorCatalog.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Convert.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Convert.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Convert.cs 2009-02-05 06:50:53 UTC (rev 4050)
@@ -0,0 +1,20 @@
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.FileStreamSql2008
+{
+ /// <summary>
+ /// Byte[]-to-String and String-to-Byte[] converter
+ /// </summary>
+ public class Convert
+ {
+ public static byte[] ToBytes(string str)
+ {
+ return new ASCIIEncoding().GetBytes(str);
+ }
+
+ public static string ToStr(byte[] bytes)
+ {
+ return new ASCIIEncoding().GetString(bytes);
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Fixture.cs (from rev 4046, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Dates/FixtureBase.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Fixture.cs 2009-02-05 06:50:53 UTC (rev 4050)
@@ -0,0 +1,102 @@
+using System;
+using System.Collections;
+using NHibernate.Cfg;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.FileStreamSql2008
+{
+ /// <summary>
+ /// Workaround to use FileStream feature
+ /// http://blogs.msdn.com/manisblog/archive/2007/10/21/filestream-data-type-sql-server-2008.aspx
+ /// </summary>
+ [TestFixture]
+ public class Fixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.FileStreamSql2008.Mappings.hbm.xml"}; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2008Dialect;
+ }
+
+ protected override void Configure(Configuration cfg)
+ {
+ //Points to the database created with FileStream Filegroup.
+ cfg.Properties["connection.connection_string"] =
+ @"Data Source=localhost\SQLEXPRESS;Initial Catalog=FileStreamDB;Integrated Security=True;Pooling=False";
+
+ #region CREATE DATABASE example
+/*
+ CREATE DATABASE FileStreamDB ON PRIMARY
+ ( NAME = FileStreamDB_data,
+ FILENAME = N'C:\FSDemo\FileStreamDB_data.mdf',
+ SIZE = 10MB,
+ MAXSIZE = 50MB,
+ FILEGROWTH = 10%),
+ FILEGROUP RowGroup1
+ ( NAME = FileStreamDB_group1,
+ FILENAME = N'C:\FSDemo\FileStreamDB_group1.ndf',
+ SIZE = 10MB,
+ MAXSIZE = 50MB,
+ FILEGROWTH = 5MB),
+ FILEGROUP FileStreamGroup1 CONTAINS FILESTREAM
+ ( NAME = FileStreamDBResumes,
+ FILENAME = N'C:\FSDemo\VendorCatalog')
+ LOG ON
+ ( NAME = 'FileStreamDB_log',
+ FILENAME = N'C:\FSDemo\FileStreamDB_log.ldf',
+ SIZE = 5MB,
+ MAXSIZE = 25MB,
+ FILEGROWTH = 5MB);
+*/
+#endregion
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ Guid rowId = Guid.NewGuid();
+
+ var entity = new VendorCatalog
+ {
+ Name = "Dario",
+ CatalogID = rowId,
+ Catalog = Convert.ToBytes("Aqui me pongo a cantar...al compas de la viguela")
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+ }
+
+ VendorCatalog entityReturned = null;
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ entityReturned = s.CreateQuery("from VendorCatalog").UniqueResult<VendorCatalog>();
+
+ Assert.AreEqual("Dario", entityReturned.Name);
+ Assert.AreEqual(rowId.ToString(), entityReturned.CatalogID.ToString());
+ Assert.AreEqual("Aqui me pongo a cantar...al compas de la viguela",Convert.ToStr(entityReturned.Catalog));
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entityReturned);
+ tx.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Mappings.hbm.xml (from rev 4046, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/Mappings.hbm.xml 2009-02-05 06:50:53 UTC (rev 4050)
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.FileStreamSql2008"
+ assembly="NHibernate.Test">
+
+ <!-- Mapping the entity as usual -->
+ <class name="VendorCatalog">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Name"/>
+ <property name="CatalogID"/>
+ <property name="Catalog"/>
+ </class>
+
+ <!--
+ The workaround consist in alter the table with the special
+ columns needed to support the FileStream feature.
+ -->
+ <database-object>
+ <create>
+ <![CDATA[
+
+ ALTER TABLE VendorCatalog DROP COLUMN CatalogID
+ ALTER TABLE VendorCatalog ADD CatalogID UNIQUEIDENTIFIER ROWGUIDCOL NOT NULL UNIQUE
+ ALTER TABLE VendorCatalog DROP COLUMN Catalog
+ ALTER TABLE VendorCatalog ADD Catalog varbinary(max) FILESTREAM
+
+ ]]>
+ </create>
+ <drop/>
+ </database-object>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/VendorCatalog.cs (from rev 4046, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Futures/Person.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/VendorCatalog.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/FileStreamSql2008/VendorCatalog.cs 2009-02-05 06:50:53 UTC (rev 4050)
@@ -0,0 +1,27 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.FileStreamSql2008
+{
+ public class VendorCatalog
+ {
+ /// <summary>
+ /// Usual Object Id, nothing weird
+ /// </summary>
+ public virtual int Id { get; set; }
+
+ /// <summary>
+ /// Simple string property, nothing weird
+ /// </summary>
+ public virtual string Name { get; set; }
+
+ /// <summary>
+ /// Represents the mandatory UNIQUEIDENTIFIER ROWGUIDCOL
+ /// </summary>
+ public virtual Guid CatalogID { get; set; }
+
+ /// <summary>
+ /// FileStream property
+ /// </summary>
+ public virtual Byte[] Catalog { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 04:59:33 UTC (rev 4049)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 06:50:53 UTC (rev 4050)
@@ -390,6 +390,9 @@
<Compile Include="NHSpecificTest\Dates\FixtureBase.cs" />
<Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
<Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
+ <Compile Include="NHSpecificTest\FileStreamSql2008\VendorCatalog.cs" />
+ <Compile Include="NHSpecificTest\FileStreamSql2008\Fixture.cs" />
+ <Compile Include="NHSpecificTest\FileStreamSql2008\Convert.cs" />
<Compile Include="NHSpecificTest\Futures\FutureQueryFixture.cs" />
<Compile Include="NHSpecificTest\Futures\FutureCriteriaFixture.cs" />
<Compile Include="NHSpecificTest\Futures\Person.cs" />
@@ -1629,6 +1632,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\FileStreamSql2008\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Seqidentity\MyEntity.hbm.xml" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\Dates\Mappings\Time.hbm.xml" />
@@ -1753,4 +1757,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-02-05 23:22:19
|
Revision: 4054
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4054&view=rev
Author: tehlike
Date: 2009-02-05 22:15:53 +0000 (Thu, 05 Feb 2009)
Log Message:
-----------
Ignored test for NH-1289
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_Product.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseItem.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseOrder.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Product.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseItem.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseOrder.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/WorkflowItem.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_Product.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_Product.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_Product.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,19 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ [Serializable]
+ public class Cons_Product : Product
+ {
+ #region Fields
+
+
+ public virtual string ImageName
+ {
+ get;
+ set;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseItem.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseItem.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseItem.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,9 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ public class Cons_PurchaseItem : PurchaseItem
+ {
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseOrder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseOrder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Cons_PurchaseOrder.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,11 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+
+ [Serializable]
+ public class Cons_PurchaseOrder : PurchaseOrder
+ {
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Fixture.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,72 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using Iesi.Collections.Generic;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ [TestFixture,Ignore]
+ public class Fixture:BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ using(var ses=OpenSession())
+ using(var tran=ses.BeginTransaction())
+ {
+ var purchaseOrder = new Cons_PurchaseOrder
+ {
+ PurchaseItems = new HashedSet<PurchaseItem>(),
+ };
+ var product = new Cons_Product
+ {
+ ProductName = "abc",
+ Units = 5,
+ Price = "123",
+ Description = "desc",
+ ImageName = "abc"
+ };
+
+
+ var purchaseItem = new Cons_PurchaseItem
+ {
+ Product = product,
+ PurchaseOrder = purchaseOrder
+ };
+ purchaseOrder.PurchaseItems.Add(purchaseItem);
+ ses.Save(product);
+ ses.Save(purchaseOrder);
+ ses.Save(purchaseItem);
+
+ tran.Commit();
+ }
+
+
+ }
+ protected override void OnTearDown()
+ {
+ using (var ses = OpenSession())
+ using (var tran = ses.BeginTransaction())
+ {
+ ses.Delete("from Cons_PurchaseOrder");
+ ses.Delete("from Cons_PurchaseItem");
+ ses.Delete("from Cons_Product");
+ tran.Commit();
+ }
+ }
+
+ [Test]
+ public void ManyToOne_gets_implicit_polymorphism_correctly()
+ {
+ using (var ses = OpenSession())
+ using (var tran = ses.BeginTransaction())
+ {
+ var purchaseItem = ses.Get<PurchaseItem>(1);
+ Assert.That(purchaseItem, Is.AssignableFrom(typeof(Cons_PurchaseItem)));
+ Assert.That(purchaseItem.Product, Is.AssignableFrom(typeof(Cons_Product)));
+ tran.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Mappings.hbm.xml 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,54 @@
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1289">
+ <joined-subclass name="PurchaseOrder" table="PurchaseOrder"
+ extends="WorkflowItem">
+ <key column="Id"/>
+
+ <set name="PurchaseItems" lazy="true" inverse="true" cascade="all" table="PurchaseItem">
+ <key column="PurchaseOrderId" />
+ <one-to-many class="PurchaseItem" />
+ </set>
+ </joined-subclass>
+
+ <joined-subclass name="Cons_Product" table="Cons_Product" extends="Product">
+ <key column="Id"/>
+ <property name="ImageName" column="ImageName" not-null="false" />
+ </joined-subclass>
+
+ <joined-subclass name="Cons_PurchaseItem" table="Cons_PurchaseItem" extends="PurchaseItem">
+ <key column="Id"/>
+ </joined-subclass>
+
+ <joined-subclass name="Cons_PurchaseOrder" table="Cons_PurchaseOrder" extends="PurchaseOrder" >
+ <key column="Id"/>
+ </joined-subclass>
+
+ <class name="Product" table="Product">
+
+ <id name="Id" column="Id" type="System.Int32">
+ <generator class="native"/>
+ </id>
+ <property name="Description" column="Description" not-null="false" />
+ <property name="Price" column="Price" not-null="false" />
+ <property name="ProductName" column="ProductName" not-null="false" />
+ <property name="Units" column="Units" not-null="false" />
+
+ </class>
+
+ <class name="PurchaseItem" table="PurchaseItem">
+ <id name="Id" column="Id" type="System.Int32">
+ <generator class="native"/>
+ </id>
+ <many-to-one name="Product" column="ProductId" not-null="true" />
+ <many-to-one name="PurchaseOrder" column="PurchaseOrderId" not-null="true" />
+ </class>
+
+
+
+ <class name="WorkflowItem" table="WorkflowItem">
+
+ <id name="Id" column="Id" type="System.Int32">
+ <generator class="native">
+ </generator>
+ </id>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Product.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Product.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/Product.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,43 @@
+using System;
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ [Serializable]
+ public class Product
+ {
+ #region Fields
+ public virtual String Description
+ {
+ get;
+ set;
+ }
+
+ public virtual Int32 Id
+ {
+ get;
+ set;
+ }
+
+ public virtual String Price
+ {
+ get;
+ set;
+ }
+
+ public virtual String ProductName
+ {
+ get;
+ set;
+ }
+
+
+ public virtual Int32? Units
+ {
+ get;
+ set;
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseItem.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseItem.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseItem.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,31 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ public class PurchaseItem
+ {
+ #region Fields
+
+ public virtual Int32 Id
+ {
+ get;
+ set;
+ }
+
+ #endregion
+
+
+ public virtual PurchaseOrder PurchaseOrder
+ {
+ get;
+ set;
+ }
+
+
+ public virtual Product Product
+ {
+ get;
+ set;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseOrder.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseOrder.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/PurchaseOrder.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,14 @@
+using System;
+using Iesi.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ public class PurchaseOrder : WorkflowItem
+ {
+ public virtual ISet<PurchaseItem> PurchaseItems
+ {
+ get;
+ set;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/WorkflowItem.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/WorkflowItem.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1289/WorkflowItem.cs 2009-02-05 22:15:53 UTC (rev 4054)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1289
+{
+ [Serializable]
+ public class WorkflowItem
+ {
+ public virtual int Id { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 21:57:10 UTC (rev 4053)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-05 22:15:53 UTC (rev 4054)
@@ -401,6 +401,14 @@
<Compile Include="NHSpecificTest\NH1274ExportExclude\Home.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\NH1274ExportExcludeFixture.cs" />
<Compile Include="NHSpecificTest\NH1274ExportExclude\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1289\Cons_Product.cs" />
+ <Compile Include="NHSpecificTest\NH1289\Cons_PurchaseItem.cs" />
+ <Compile Include="NHSpecificTest\NH1289\Cons_PurchaseOrder.cs" />
+ <Compile Include="NHSpecificTest\NH1289\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1289\Product.cs" />
+ <Compile Include="NHSpecificTest\NH1289\PurchaseItem.cs" />
+ <Compile Include="NHSpecificTest\NH1289\PurchaseOrder.cs" />
+ <Compile Include="NHSpecificTest\NH1289\WorkflowItem.cs" />
<Compile Include="NHSpecificTest\NH1443\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1521\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1549\CategoryWithInheritedId.cs" />
@@ -1632,6 +1640,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1289\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\FileStreamSql2008\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Seqidentity\MyEntity.hbm.xml" />
<EmbeddedResource Include="IdGen\NativeGuid\NativeGuidPoid.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-02-06 18:25:57
|
Revision: 4061
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4061&view=rev
Author: tehlike
Date: 2009-02-06 18:25:52 +0000 (Fri, 06 Feb 2009)
Log Message:
-----------
Ignored test that verifies SessionFactory is Serializable
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/
trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.cs
trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/SessionFactorySerializationFixture.cs
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-06 17:27:04 UTC (rev 4060)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-06 18:25:52 UTC (rev 4061)
@@ -920,6 +920,8 @@
<Compile Include="QueryTest\PositionalParametersFixture.cs" />
<Compile Include="QueryTest\QueryParametersFixture.cs" />
<Compile Include="ReflectionOptimizerTest\LcgFixture.cs" />
+ <Compile Include="SessionFactoryTest\Item.cs" />
+ <Compile Include="SessionFactoryTest\SessionFactorySerializationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" />
<Compile Include="SecondLevelCacheTest\AnotherItem.cs" />
@@ -1643,6 +1645,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="SessionFactoryTest\Item.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1289\Mappings.hbm.xml" />
<EmbeddedResource Include="TypesTest\TimeSpanClass.hbm.xml" />
<EmbeddedResource Include="TypesTest\TimeSpanInt64Class.hbm.xml" />
@@ -1771,4 +1774,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest
___________________________________________________________________
Added: svn:mergeinfo
+
Added: trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.cs 2009-02-06 18:25:52 UTC (rev 4061)
@@ -0,0 +1,66 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.SessionFactoryTest
+{
+ public class Item
+ {
+ private int id;
+ private IList children = new ArrayList();
+ private Item parent;
+ private string name;
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual Item Parent
+ {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual IList Children
+ {
+ get { return children; }
+ set { children = value; }
+ }
+ }
+ public class AnotherItem
+ {
+ private int id;
+ private string name;
+
+ public AnotherItem()
+ {
+
+ }
+
+ public AnotherItem(string name)
+ {
+ this.name = name;
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/Item.hbm.xml 2009-02-06 18:25:52 UTC (rev 4061)
@@ -0,0 +1,22 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.SessionFactoryTest"
+ assembly="NHibernate.Test">
+ <class name="Item">
+ <cache usage="read-write"/>
+ <id name="Id">
+ <generator class="assigned"/>
+ </id>
+ <property name="Name"/>
+ <many-to-one name="Parent" column="ParentId"
+ lazy="proxy" not-found="ignore"
+ class="Item"/>
+ <bag name="Children"
+ table="Item"
+ lazy="true">
+ <cache usage="read-write"/>
+ <key column="ParentId" foreign-key="none"/>
+ <one-to-many class="Item"/>
+ </bag>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/SessionFactorySerializationFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/SessionFactorySerializationFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SessionFactoryTest/SessionFactorySerializationFixture.cs 2009-02-06 18:25:52 UTC (rev 4061)
@@ -0,0 +1,121 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Reflection;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Text;
+using NHibernate.Engine;
+using NHibernate.Impl;
+using NUnit.Framework;
+using NUnit.Framework.SyntaxHelpers;
+
+namespace NHibernate.Test.SessionFactoryTest
+{
+ [TestFixture,Ignore]
+ public class SessionFactorySerializationFixture:TestCase
+ {
+ protected ISessionFactory SerializeAndDeserialize()
+ {
+ var ncfg = base.cfg;
+ ncfg.Properties["session_factory_name"] = "myfactory";
+ var sessionFactory = ncfg.BuildSessionFactory();
+ var uuidField = typeof (SessionFactoryImpl).GetField("uuid",
+ BindingFlags.Instance |
+ BindingFlags.NonPublic |
+ BindingFlags.GetField);
+ var uuid = uuidField.GetValue(sessionFactory) as string;
+ var stream = new MemoryStream();
+ var formatter = new BinaryFormatter();
+ formatter.Serialize(stream, sessionFactory);
+ sessionFactory.Dispose();
+ stream.Position = 0;
+ var factory = formatter.Deserialize(stream) as ISessionFactoryImplementor;
+ stream.Dispose();
+ return factory;
+ }
+ protected void Serialize(ISessionFactoryImplementor factory,MemoryStream ms)
+ {
+ var formatter = new BinaryFormatter();
+ formatter.Serialize(ms, this.sessions);
+ }
+ [Test]
+ public void SessionFactory_should_be_serializable()
+ {
+ using (var stream = new MemoryStream())
+ {
+ Serialize(this.sessions, stream);
+ Assert.That(stream.Length, Is.Not.EqualTo(0));
+ }
+ }
+
+ [Test]
+ public void SessionFactory_should_be_deserialized()
+ {
+ var factory = SerializeAndDeserialize();
+ Assert.That(factory, Is.Not.Null);
+ }
+ [Test]
+ public void CRUD_works_correctly_after_deserialization()
+ {
+ var sessionFactory = SerializeAndDeserialize();
+
+ using(var session=sessionFactory.OpenSession())
+ using(var tran=session.BeginTransaction())
+ {
+ var obj = new Item {Name = "object1"};
+ var obj2 = new Item {Name = "object2"};
+ obj.Children.Add(obj2);
+ obj2.Parent = obj;
+ session.Save(obj);
+ session.Save(obj);
+ tran.Commit();
+ }
+
+ using (var session = sessionFactory.OpenSession())
+ using (var tran = session.BeginTransaction())
+ {
+ var item = session.Get<Item>(1);
+ Assert.That(item, Is.Not.Null);
+ Assert.That(item.Children.Count, Is.EqualTo(1));
+
+ item.Name = "object5";
+ session.Save(item);
+ tran.Commit();
+ }
+
+ using(var session=sessionFactory.OpenSession())
+ {
+ var item = session.Get<Item>(1);
+ Assert.That(item.Name, Is.EqualTo("object5"));
+ }
+
+ using (var session = sessionFactory.OpenSession())
+ {
+ var item = session.Get<Item>(1);
+ session.Delete(item);
+ session.Evict(item);
+ item = session.Get<Item>(1);
+ Assert.That(item, Is.Null);
+ }
+
+ }
+ protected override System.Collections.IList Mappings
+ {
+ get
+ {
+ return new string[]
+ {
+ "SessionFactoryTest.Item.hbm.xml",
+
+ };
+ }
+ }
+ protected override string MappingsAssembly
+ {
+ get
+ {
+ return "NHibernate.Test";
+ }
+ }
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-07 19:06:42
|
Revision: 4067
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4067&view=rev
Author: darioquintana
Date: 2009-02-07 19:06:18 +0000 (Sat, 07 Feb 2009)
Log Message:
-----------
NH-1619: not an issue. Tests added are passing.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Model.cs
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Fixture.cs (from rev 4055, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Fixture.cs 2009-02-07 19:06:18 UTC (rev 4067)
@@ -0,0 +1,51 @@
+using NHibernate.Dialect;
+using NHibernate.SqlTypes;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1619
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "NH1619"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is PostgreSQLDialect;
+ }
+
+ [Test]
+ public void SavingAndRetrieving()
+ {
+ var entity = new Dude
+ {
+ BooleanValue = true
+ };
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(entity);
+ tx.Commit();
+
+ Assert.AreEqual(true, s.CreateQuery("from Dude").UniqueResult<Dude>().BooleanValue);
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete(entity);
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void UsingBooleanPostgreSQLType()
+ {
+ Assert.AreEqual("boolean", Dialect.GetTypeName(SqlTypeFactory.Boolean));
+ }
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Mappings.hbm.xml (from rev 4055, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Mappings.hbm.xml 2009-02-07 19:06:18 UTC (rev 4067)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1619"
+ assembly="NHibernate.Test"
+>
+ <class name="Dude" lazy="false">
+ <id name="Id">
+ <generator class="hilo"/>
+ </id>
+ <property name="BooleanValue"/>
+ </class>
+
+</hibernate-mapping>
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Model.cs (from rev 4055, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1621/Model.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1619/Model.cs 2009-02-07 19:06:18 UTC (rev 4067)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.NHSpecificTest.NH1619
+{
+ public class Dude
+ {
+ public virtual int Id { get; set; }
+ public virtual bool BooleanValue { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 16:44:07 UTC (rev 4066)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 19:06:18 UTC (rev 4067)
@@ -612,6 +612,8 @@
<Compile Include="NHSpecificTest\NH1612\MonetaryValue.cs" />
<Compile Include="NHSpecificTest\NH1612\NativeSqlCollectionLoaderFixture.cs" />
<Compile Include="NHSpecificTest\NH1612\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1619\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1619\Model.cs" />
<Compile Include="NHSpecificTest\NH1621\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1621\Model.cs" />
<Compile Include="NHSpecificTest\NH1632\Fixture.cs" />
@@ -1652,6 +1654,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1619\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1665\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\ByTrigger\MyEntity.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\Identity\MyEntityIdentity.hbm.xml" />
@@ -1784,4 +1787,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
\ No newline at end of file
+</Project>
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-02-08 12:46:26
|
Revision: 4071
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4071&view=rev
Author: fabiomaulo
Date: 2009-02-08 12:46:06 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
Reorganization of Tests about custom queries
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/Item.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueries.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/NativeSQLQueriesFixture.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Query/SelfReferencingCollectionLoadTest.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/SqlTest/General.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/GeneralTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Item.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Item.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/SelfReferencingCollectionLoadTest.cs
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-07 22:32:27 UTC (rev 4070)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 12:46:06 UTC (rev 4071)
@@ -951,10 +951,10 @@
<Compile Include="SqlTest\Dimension.cs" />
<Compile Include="SqlTest\Employment.cs" />
<Compile Include="SqlTest\FireBirdTest.cs" />
- <Compile Include="SqlTest\GeneralTest.cs" />
+ <Compile Include="SqlTest\Query\NativeSQLQueriesFixture.cs" />
<Compile Include="SqlTest\HandSQLTest.cs" />
<Compile Include="SqlTest\IdentityInsertWithStoredProcsTest.cs" />
- <Compile Include="SqlTest\Item.cs" />
+ <Compile Include="SqlTest\Query\Item.cs" />
<Compile Include="SqlTest\MonetaryAmount.cs" />
<Compile Include="SqlTest\MonetaryAmountUserType.cs" />
<Compile Include="SqlTest\MSSQLIdentityInsertWithStoredProcsTest.cs" />
@@ -964,7 +964,7 @@
<Compile Include="SqlTest\Organization.cs" />
<Compile Include="SqlTest\Person.cs" />
<Compile Include="SqlTest\Product.cs" />
- <Compile Include="SqlTest\SelfReferencingCollectionLoadTest.cs" />
+ <Compile Include="SqlTest\Query\SelfReferencingCollectionLoadTest.cs" />
<Compile Include="SqlTest\SpaceShip.cs" />
<Compile Include="SqlTest\Speech.cs" />
<Compile Include="Stateless\Document.cs" />
@@ -1255,7 +1255,7 @@
<EmbeddedResource Include="SqlTest\MSSQLEmployment.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="SqlTest\General.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Query\NativeSQLQueries.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NHSpecificTest\NH719\Mappings.hbm.xml" />
@@ -1343,7 +1343,7 @@
<EmbeddedResource Include="NHSpecificTest\NH776\Mappings.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="SqlTest\Item.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Query\Item.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Criteria\Enrolment.hbm.xml" />
@@ -1770,6 +1770,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
+ <Folder Include="SqlTest\Custom\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
@@ -1787,4 +1788,4 @@
if exist "$(ProjectDir)hibernate.cfg.xml" (copy "$(ProjectDir)hibernate.cfg.xml" "hibernate.cfg.xml")
copy /y "..\..\..\NHibernate.DomainModel\ABC.hbm.xml" "ABC.hbm.xml"</PostBuildEvent>
</PropertyGroup>
-</Project>
+</Project>
\ No newline at end of file
Deleted: trunk/nhibernate/src/NHibernate.Test/SqlTest/General.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/General.hbm.xml 2009-02-07 22:32:27 UTC (rev 4070)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/General.hbm.xml 2009-02-08 12:46:06 UTC (rev 4071)
@@ -1,263 +0,0 @@
-<?xml version="1.0" encoding="utf-8" ?>
-<!--
-
- This mapping demonstrates the use of Hibernate with
- all-handwritten SQL!
-
- This version is for Sybase/mssql
--->
-
-<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-access="field.camelcase"
- namespace="NHibernate.Test.SqlTest"
- assembly="NHibernate.Test">
-
- <class name="Organization" table="ORGANIZATION">
- <id name="id" unsaved-value="0" column="ORGID">
- <generator class="increment"/>
- </id>
- <property name="name" column="NAME" not-null="true"/>
- <set lazy="true" name="employments"
- inverse="true">
- <key column="EMPLOYER"/>
- <!-- only needed for DDL generation -->
- <one-to-many class="Employment"/>
- </set>
- </class>
-
- <class name="Person" table="PERSON">
- <id name="id" unsaved-value="0" column="PERID">
- <generator class="increment"/>
- </id>
- <property name="name" column="NAME" not-null="true"/>
-
- </class>
-
- <class name="Employment" table="EMPLOYMENT">
- <id name="employmentId" unsaved-value="0" column="EMPID">
- <generator class="increment"/>
- </id>
- <many-to-one name="employee" column="EMPLOYEE" not-null="true" update="false"/>
- <many-to-one name="employer" column="EMPLOYER" not-null="true" update="false"/>
- <property name="startDate" column="STARTDATE" not-null="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test" />
- <property name="endDate" column="ENDDATE" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test" />
- <property name="regionCode" column="REGIONCODE" update="false"/>
- <property name="salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test">
- <column name="AVALUE" sql-type="float"/>
- <column name="CURRENCY"/>
- </property>
- </class>
-
- <class name="Order" table="TBL_ORDER">
- <composite-id name="orderId" class="Order+OrderIdType">
- <key-property name="orgid"/>
- <key-property name="ordernumber"/>
- </composite-id>
-
- <many-to-one name="product">
- <column name="PROD_ORGID"/>
- <column name="PROD_NO"/>
- </many-to-one>
- <many-to-one name="person"/>
- </class>
-
- <class name="Product">
- <composite-id name="productId" class="Product+ProductIdType">
- <key-property name="orgid"/>
- <key-property name="productnumber"/>
- </composite-id>
-
- <property name="name"/>
-
- <set name="orders" inverse="true">
- <key>
- <column name="PROD_ORGID"/>
- <column name="PROD_NO"/>
- </key>
- <one-to-many class="Order"/>
- </set>
- </class>
-
- <class name="Dimension">
- <id name="id" type="long">
- <generator class="increment"/>
- </id>
- <property name="length" column="d_len"/>
- <property name="width" column="d_width"/>
- </class>
-
- <class name="SpaceShip">
- <id name="id" type="integer">
- <generator class="increment"/>
- </id>
- <property name="name" column="fld_name"/>
- <property name="model" column="fld_model"/>
- <property name="speed" column="fld_speed"/>
- <component name="dimensions">
- <property name="length" column="fld_length"/>
- <property name="width" column="fld_width"/>
- </component>
- </class>
-
- <class name="Speech">
- <id name="id" type="integer">
- <generator class="increment"/>
- </id>
- <property name="name" column="name"/>
- <property name="length" column="flength"/>
- </class>
-
- <resultset name="org-emp-regionCode">
- <return-scalar column="regionCode" type="string"/>
- <return alias="org" class="Organization"/>
- <return-join alias="emp" property="org.employments"/>
- </resultset>
-
- <resultset name="org-emp-person">
- <return alias="org" class="Organization"/>
- <return-join alias="emp" property="org.employments"/>
- <return-join alias="pers" property="emp.employee"/>
- </resultset>
-
-
- <resultset name="org-description">
- <return alias="org" class="Organization"/>
- <return-join alias="emp" property="org.employments"/>
- </resultset>
-
- <resultset name="spaceship-vol">
- <return alias="sps" class="SpaceShip">
- <return-property name="id" column="id"/>
- <return-property name="name" column="name"/>
- <return-property name="model" column="model"/>
- <return-property name="speed" column="speed"/>
- <return-property name="dimensions.length" column="length"/>
- <return-property name="dimensions.width" column="width"/>
- </return>
- <return-scalar column="surface" type="double" />
- <return-scalar column="volume" type="double" />
- </resultset>
-
- <resultset name="speech">
- <return alias="sp" class="Speech">
- <return-property name="id" column="id"/>
- <return-property name="name" column="name"/>
- <return-property name="length" column="flength"/>
- </return>
- <return-scalar column="scalarName" type="string" />
- </resultset>
-
- <sql-query name="spaceship" resultset-ref="spaceship-vol">
- select id as id,
- fld_name as name,
- fld_model as model,
- fld_speed as speed,
- fld_length as flength,
- fld_width as width,
- fld_length * fld_width as surface,
- fld_length * fld_width *10 as volume
- from SpaceShip
- </sql-query>
-
- <sql-query name="orgNamesOnly">
- <return-scalar column="NAME" type="string"/>
- SELECT org.NAME FROM ORGANIZATION org
- </sql-query>
-
- <sql-query name="orgNamesAndOrgs">
- <return-scalar column="thename" type="string"/>
- <return alias="org" class="Organization"/>
- SELECT org.NAME AS thename, org.NAME AS {org.name}, org.ORGID AS {org.id}
- FROM ORGANIZATION org
- ORDER BY thename
- </sql-query>
-
- <sql-query name="orgsAndOrgNames">
- <return alias="org" class="Organization"/>
- <return-scalar column="thename" type="string"/>
- SELECT org.NAME AS thename, org.NAME AS {org.name}, org.ORGID AS {org.id}
- FROM ORGANIZATION org
- ORDER BY thename
- </sql-query>
-
- <sql-query name="orgIdsAndOrgNames">
- <return-scalar column="orgid" type="long"/>
- <return-scalar column="thename" type="string"/>
- SELECT NAME AS thename, ORGID AS orgid
- FROM ORGANIZATION
- ORDER BY thename
- </sql-query>
-
- <sql-query name="AllEmploymentAsMapped">
- <return class="Employment"/>
- SELECT * FROM EMPLOYMENT
- </sql-query>
-
- <sql-query name="EmploymentAndPerson">
- <return class="Employment"/>
- <return class="Person"/>
- SELECT * FROM EMPLOYMENT, PERSON
- </sql-query>
-
- <sql-query name="organizationEmploymentsExplicitAliases">
- <load-collection alias="empcol" role="Organization.employments"/>
- SELECT empcol.EMPLOYER as {empcol.key}, empcol.EMPID as {empcol.element}, {empcol.element.*}
- FROM EMPLOYMENT empcol
- WHERE EMPLOYER = :id
- ORDER BY STARTDATE ASC, EMPLOYEE ASC
- </sql-query>
-
- <sql-query name="organizationreturnproperty">
- <return alias="org" class="Organization">
- <return-property name="id" column="ORGID"/>
- <return-property name="name" column="NAME"/>
- </return>
- <return-join alias="emp" property="org.employments">
- <return-property name="key" column="EMPLOYER"/>
- <return-property name="element" column="EMPID"/>
- <return-property name="element.employee" column="EMPLOYEE"/>
- <return-property name="element.employer" column="EMPLOYER"/>
- <return-property name="element.startDate" column="XSTARTDATE"/>
- <return-property name="element.endDate" column="ENDDATE"/>
- <return-property name="element.regionCode" column="REGIONCODE"/>
- <return-property name="element.employmentId" column="EMPID"/>
- <return-property name="element.salary">
- <return-column name="AVALUE"/>
- <return-column name="CURRENCY"/>
- </return-property>
- </return-join>
- SELECT org.ORGID as orgid,
- org.NAME as name,
- emp.EMPLOYER as employer,
- emp.EMPID as empid,
- emp.EMPLOYEE as employee,
- emp.EMPLOYER as employer,
- emp.STARTDATE as xstartDate,
- emp.ENDDATE as endDate,
- emp.REGIONCODE as regionCode,
- emp.AVALUE as AVALUE,
- emp.CURRENCY as CURRENCY
- FROM ORGANIZATION org
- LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
- </sql-query>
-
-
- <sql-query name="organizationautodetect" resultset-ref="org-description">
- <!-- equal to "organizationpropertyreturn" but since no {} nor return-property are used hibernate will fallback to use the columns directly from the mapping -->
- <return alias="org" class="Organization"/>
- <return-join alias="emp" property="org.employments"/>
- SELECT org.ORGID as orgid,
- org.NAME as name,
- emp.EMPLOYER as employer,
- emp.EMPID as empid,
- emp.EMPLOYEE as employee,
- emp.EMPLOYER as employer,
- emp.STARTDATE as startDate,
- emp.ENDDATE as endDate,
- emp.REGIONCODE as regionCode,
- emp.AVALUE as AVALUE,
- emp.CURRENCY as CURRENCY
- FROM ORGANIZATION org
- LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
- </sql-query>
-
-</hibernate-mapping>
Deleted: trunk/nhibernate/src/NHibernate.Test/SqlTest/GeneralTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/GeneralTest.cs 2009-02-07 22:32:27 UTC (rev 4070)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/GeneralTest.cs 2009-02-08 12:46:06 UTC (rev 4071)
@@ -1,601 +0,0 @@
-using System;
-using System.Collections;
-using NHibernate.Transform;
-using NUnit.Framework;
-using NHibernate.Criterion;
-
-namespace NHibernate.Test.SqlTest
-{
- [TestFixture]
- public class GeneralTest : TestCase
- {
- protected const string OrganizationFetchJoinEmploymentSQL =
- "SELECT org.ORGID as {org.id}, " +
- " org.NAME as {org.name}, " +
- " emp.EMPLOYER as {emp.key}, " +
- " emp.EMPID as {emp.element}, " +
- " {emp.element.*} " +
- "FROM ORGANIZATION org " +
- " LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER";
-
- protected const string OrganizationJoinEmploymentSQL =
- "SELECT org.ORGID as {org.id}, " +
- " org.NAME as {org.name}, " +
- " {emp.*} " +
- "FROM ORGANIZATION org " +
- " LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER";
-
- protected const string EmploymentSQL = "SELECT * FROM EMPLOYMENT";
-
- protected string EmploymentSQLMixedScalarEntity =
- "SELECT e.*, e.employer as employerid FROM EMPLOYMENT e";
-
- protected const string OrgEmpRegionSQL =
- "select {org.*}, {emp.*}, emp.REGIONCODE " +
- "from ORGANIZATION org " +
- " left outer join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER";
-
- protected string OrgEmpPersonSQL =
- "select {org.*}, {emp.*}, {pers.*} " +
- "from ORGANIZATION org " +
- " join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER " +
- " join PERSON pers on pers.PERID = emp.EMPLOYEE ";
-
- protected override IList Mappings
- {
- get { return new string[] {"SqlTest.General.hbm.xml"}; }
- }
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- [Test]
- public void FailOnNoAddEntityOrScalar()
- {
- // Note: this passes, but for the wrong reason.
- // there is actually an exception thrown, but it is the database
- // throwing a sql exception because the SQL gets passed
- // "un-processed"...
- ISession s = OpenSession();
- try
- {
- string sql = "select {org.*} " +
- "from organization org";
- s.CreateSQLQuery(sql).List();
- Assert.Fail("Should throw an exception since no AddEntity nor AddScalar has been performed.");
- }
- catch (HibernateException)
- {
- // expected behavior
- }
- finally
- {
- s.Close();
- }
- }
-
- [Test]
- public void SQLQueryInterface()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
- Person gavin = new Person("Gavin");
- Employment emp = new Employment(gavin, jboss, "AU");
-
- s.Save(ifa);
- s.Save(jboss);
- s.Save(gavin);
- s.Save(emp);
-
- IList l = s.CreateSQLQuery(OrgEmpRegionSQL)
- .AddEntity("org", typeof(Organization))
- .AddJoin("emp", "org.employments")
- .AddScalar("regionCode", NHibernateUtil.String)
- .List();
- Assert.AreEqual(2, l.Count);
-
- l = s.CreateSQLQuery(OrgEmpPersonSQL)
- .AddEntity("org", typeof(Organization))
- .AddJoin("emp", "org.employments")
- .AddJoin("pers", "emp.employee")
- .List();
- Assert.AreEqual(l.Count, 1);
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
-
- l = s.CreateSQLQuery("select {org.*}, {emp.*} " +
- "from ORGANIZATION org " +
- " left outer join EMPLOYMENT emp on org.ORGID = emp.EMPLOYER, ORGANIZATION org2")
- .AddEntity("org", typeof(Organization))
- .AddJoin("emp", "org.employments")
- .SetResultTransformer(new DistinctRootEntityResultTransformer())
- .List();
- Assert.AreEqual(l.Count, 2);
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
-
- s.Delete(emp);
- s.Delete(gavin);
- s.Delete(ifa);
- s.Delete(jboss);
-
- t.Commit();
- s.Close();
- }
-
- [Test]
- public void ResultSetMappingDefinition()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
- Person gavin = new Person("Gavin");
- Employment emp = new Employment(gavin, jboss, "AU");
-
- s.Save(ifa);
- s.Save(jboss);
- s.Save(gavin);
- s.Save(emp);
-
- IList l = s.CreateSQLQuery(OrgEmpRegionSQL)
- .SetResultSetMapping("org-emp-regionCode")
- .List();
- Assert.AreEqual(l.Count, 2);
-
- l = s.CreateSQLQuery(OrgEmpPersonSQL)
- .SetResultSetMapping("org-emp-person")
- .List();
- Assert.AreEqual(l.Count, 1);
-
- s.Delete(emp);
- s.Delete(gavin);
- s.Delete(ifa);
- s.Delete(jboss);
-
- t.Commit();
- s.Close();
- }
-
- [Test]
- public void ScalarValues()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
-
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
-
- object idIfa = s.Save(ifa);
- object idJBoss = s.Save(jboss);
-
- s.Flush();
-
- IList result = s.GetNamedQuery("orgNamesOnly").List();
- Assert.IsTrue(result.Contains("IFA"));
- Assert.IsTrue(result.Contains("JBoss"));
-
- result = s.GetNamedQuery("orgNamesOnly").SetResultTransformer(CriteriaSpecification.AliasToEntityMap).List();
- IDictionary m = (IDictionary) result[0];
- Assert.AreEqual(2, result.Count);
- Assert.AreEqual(1, m.Count);
- Assert.IsTrue(m.Contains("NAME"));
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
-
- IEnumerator iter = s.GetNamedQuery("orgNamesAndOrgs").List().GetEnumerator();
- iter.MoveNext();
- object[] o = (object[]) iter.Current;
- Assert.AreEqual(o[0], "IFA");
- Assert.AreEqual(((Organization) o[1]).Name, "IFA");
- iter.MoveNext();
- o = (object[]) iter.Current;
- Assert.AreEqual(o[0], "JBoss");
- Assert.AreEqual(((Organization) o[1]).Name, "JBoss");
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
-
- // test that the ordering of the results is truly based on the order in which they were defined
- iter = s.GetNamedQuery("orgsAndOrgNames").List().GetEnumerator();
- iter.MoveNext();
- object[] row = (object[]) iter.Current;
- Assert.AreEqual(typeof(Organization), row[0].GetType(), "expecting non-scalar result first");
- Assert.AreEqual(typeof(string), row[1].GetType(), "expecting scalar result second");
- Assert.AreEqual("IFA", ((Organization) row[0]).Name);
- Assert.AreEqual(row[1], "IFA");
- iter.MoveNext();
- row = (object[]) iter.Current;
- Assert.AreEqual(typeof(Organization), row[0].GetType(), "expecting non-scalar result first");
- Assert.AreEqual(typeof(string), row[1].GetType(), "expecting scalar result second");
- Assert.AreEqual(((Organization) row[0]).Name, "JBoss");
- Assert.AreEqual(row[1], "JBoss");
- Assert.IsFalse(iter.MoveNext());
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
-
- iter = s.GetNamedQuery("orgIdsAndOrgNames").List().GetEnumerator();
- iter.MoveNext();
- o = (object[]) iter.Current;
- Assert.AreEqual(o[1], "IFA");
- Assert.AreEqual(o[0], idIfa);
- iter.MoveNext();
- o = (object[]) iter.Current;
- Assert.AreEqual(o[1], "JBoss");
- Assert.AreEqual(o[0], idJBoss);
-
- s.Delete(ifa);
- s.Delete(jboss);
- t.Commit();
- s.Close();
- }
-
- [Test]
- public void MappedAliasStrategy()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
- Person gavin = new Person("Gavin");
- Employment emp = new Employment(gavin, jboss, "AU");
- s.Save(jboss);
- s.Save(ifa);
- s.Save(gavin);
- s.Save(emp);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- IQuery namedQuery = s.GetNamedQuery("AllEmploymentAsMapped");
- IList list = namedQuery.List();
- Assert.AreEqual(1, list.Count);
- Employment emp2 = (Employment) list[0];
- Assert.AreEqual(emp2.EmploymentId, emp.EmploymentId);
- Assert.AreEqual(emp2.StartDate.Date, emp.StartDate.Date);
- Assert.AreEqual(emp2.EndDate, emp.EndDate);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- IQuery sqlQuery = s.GetNamedQuery("EmploymentAndPerson");
- sqlQuery.SetResultTransformer(CriteriaSpecification.AliasToEntityMap);
- list = sqlQuery.List();
- Assert.AreEqual(1, list.Count);
- object res = list[0];
- AssertClassAssignability(res.GetType(), typeof(IDictionary));
- IDictionary m = (IDictionary) res;
- Assert.AreEqual(2, m.Count);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- sqlQuery = s.GetNamedQuery("organizationreturnproperty");
- sqlQuery.SetResultTransformer(CriteriaSpecification.AliasToEntityMap);
- list = sqlQuery.List();
- Assert.AreEqual(2, list.Count);
- m = (IDictionary) list[0];
- Assert.IsTrue(m.Contains("org"));
- AssertClassAssignability(m["org"].GetType(), typeof(Organization));
- Assert.IsTrue(m.Contains("emp"));
- AssertClassAssignability(m["emp"].GetType(), typeof(Employment));
- Assert.AreEqual(2, m.Count);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- namedQuery = s.GetNamedQuery("EmploymentAndPerson");
- list = namedQuery.List();
- Assert.AreEqual(1, list.Count);
- object[] objs = (object[]) list[0];
- Assert.AreEqual(2, objs.Length);
- emp2 = (Employment) objs[0];
- gavin = (Person) objs[1];
- s.Delete(emp2);
- s.Delete(jboss);
- s.Delete(gavin);
- s.Delete(ifa);
- t.Commit();
- s.Close();
- }
-
- /* test for native sql composite id joins which has never been implemented */
-
- [Test, Ignore("Failure expected")]
- public void CompositeIdJoinsFailureExpected()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
- Person person = new Person();
- person.Name = "Noob";
-
- Product product = new Product();
- product.ProductId = new Product.ProductIdType();
- product.ProductId.Orgid = "x";
- product.ProductId.Productnumber = "1234";
- product.Name = "Hibernate 3";
-
- Order order = new Order();
- order.OrderId = new Order.OrderIdType();
- order.OrderId.Ordernumber = "1";
- order.OrderId.Orgid = "y";
-
- product.Orders.Add(order);
- order.Product = product;
- order.Person = person;
-
- s.Save(product);
- s.Save(order);
- s.Save(person);
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- Product p = (Product) s.CreateQuery("from Product p join fetch p.orders").List()[0];
- Assert.IsTrue(NHibernateUtil.IsInitialized(p.Orders));
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- object[] o = (object[]) s.CreateSQLQuery("select\r\n" +
- " product.orgid as {product.id.orgid}," +
- " product.productnumber as {product.id.productnumber}," +
- " {prod_orders}.orgid as orgid3_1_,\r\n" +
- " {prod_orders}.ordernumber as ordernum2_3_1_,\r\n" +
- " product.name as {product.name}," +
- " {prod_orders.element.*}," +
- /*" orders.PROD_NO as PROD4_3_1_,\r\n" +
- " orders.person as person3_1_,\r\n" +
- " orders.PROD_ORGID as PROD3_0__,\r\n" +
- " orders.PROD_NO as PROD4_0__,\r\n" +
- " orders.orgid as orgid0__,\r\n" +
- " orders.ordernumber as ordernum2_0__ \r\n" +*/
- " from\r\n" +
- " Product product \r\n" +
- " inner join\r\n" +
- " TBL_ORDER {prod_orders} \r\n" +
- " on product.orgid={prod_orders}.PROD_ORGID \r\n" +
- " and product.productnumber={prod_orders}.PROD_NO")
- .AddEntity("product", typeof(Product))
- .AddJoin("prod_orders", "product.orders")
- .List()[0];
-
- p = (Product) o[0];
- Assert.IsTrue(NHibernateUtil.IsInitialized(p.Orders));
- IEnumerator en = p.Orders.GetEnumerator();
- Assert.IsTrue(en.MoveNext());
- Assert.IsNotNull(en.Current);
- t.Commit();
- s.Close();
- }
-
- [Test]
- public void AutoDetectAliasing()
- {
- ISession s = OpenSession();
- ITransaction t = s.BeginTransaction();
- Organization ifa = new Organization("IFA");
- Organization jboss = new Organization("JBoss");
- Person gavin = new Person("Gavin");
- Employment emp = new Employment(gavin, jboss, "AU");
- s.Save(jboss);
- s.Save(ifa);
- s.Save(gavin);
- s.Save(emp);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- IList list = s.CreateSQLQuery(EmploymentSQL)
- .AddEntity(typeof(Employment).FullName)
- .List();
- Assert.AreEqual(1, list.Count);
-
- Employment emp2 = (Employment) list[0];
- Assert.AreEqual(emp2.EmploymentId, emp.EmploymentId);
- Assert.AreEqual(emp2.StartDate.Date, emp.StartDate.Date);
- Assert.AreEqual(emp2.EndDate, emp.EndDate);
-
- s.Clear();
-
- list = s.CreateSQLQuery(EmploymentSQL)
- .AddEntity(typeof(Employment).FullName)
- .SetResultTransformer(CriteriaSpecification.AliasToEntityMap)
- .List();
- Assert.AreEqual(1, list.Count);
- IDictionary m = (IDictionary) list[0];
- Assert.IsTrue(m.Contains("Employment"));
- Assert.AreEqual(1, m.Count);
-
- list = s.CreateSQLQuery(EmploymentSQL).List();
- Assert.AreEqual(1, list.Count);
- object[] o = (object[]) list[0];
- Assert.AreEqual(8, o.Length);
-
- list = s.CreateSQLQuery(EmploymentSQL).SetResultTransformer(CriteriaSpecification.AliasToEntityMap).List();
- Assert.AreEqual(1, list.Count);
- m = (IDictionary) list[0];
- Assert.IsTrue(m.Contains("EMPID"));
- Assert.IsTrue(m.Contains("AVALUE"));
- Assert.IsTrue(m.Contains("ENDDATE"));
- Assert.AreEqual(8, m.Count);
-
- // TODO H3: H3.2 can guess the return column type so they can use just addScalar("employerid"),
- // but NHibernate currently can't do it.
- list =
- s.CreateSQLQuery(EmploymentSQLMixedScalarEntity).AddScalar("employerid", NHibernateUtil.Int64).AddEntity(
- typeof(Employment)).List();
- Assert.AreEqual(1, list.Count);
- o = (object[]) list[0];
- Assert.AreEqual(2, o.Length);
- AssertClassAssignability(o[0].GetType(), typeof(long));
- AssertClassAssignability(o[1].GetType(), typeof(Employment));
-
-
- IQuery queryWithCollection = s.GetNamedQuery("organizationEmploymentsExplicitAliases");
- queryWithCollection.SetInt64("id", jboss.Id);
- list = queryWithCollection.List();
- Assert.AreEqual(list.Count, 1);
-
- s.Clear();
-
- list = s.CreateSQLQuery(OrganizationJoinEmploymentSQL)
- .AddEntity("org", typeof(Organization))
- .AddJoin("emp", "org.employments")
- .List();
- Assert.AreEqual(2, list.Count);
-
- s.Clear();
-
- list = s.CreateSQLQuery(OrganizationFetchJoinEmploymentSQL)
- .AddEntity("org", typeof(Organization))
- .AddJoin("emp", "org.employments")
- .List();
- Assert.AreEqual(2, list.Count);
-
- s.Clear();
-
- // TODO : why twice?
- s.GetNamedQuery("organizationreturnproperty").List();
- list = s.GetNamedQuery("organizationreturnproperty").List();
- Assert.AreEqual(2, list.Count);
-
- s.Clear();
-
- list = s.GetNamedQuery("organizationautodetect").List();
- Assert.AreEqual(2, list.Count);
-
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- s.Delete(emp2);
-
- s.Delete(jboss);
- s.Delete(gavin);
- s.Delete(ifa);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- Dimension dim = new Dimension(3, int.MaxValue);
- s.Save(dim);
- // s.Flush();
- s.CreateSQLQuery("select d_len * d_width as surface, d_len * d_width * 10 as volume from Dimension").List();
- s.Delete(dim);
- t.Commit();
- s.Close();
-
- s = OpenSession();
- t = s.BeginTransaction();
- SpaceShip enterprise = new SpaceShip();
- enterprise.Model = "USS";
- enterprise.Name = "Entreprise";
- enterprise.Speed = 50d;
- Dimension d = new Dimension(45, 10);
- enterprise.Dimensions = d;
- s.Save(enterprise);
- // s.Flush();
- object[] result = (object[]) s.GetNamedQuery("spaceship").UniqueResult();
- enterprise = (SpaceShip) result[0];
- Assert.IsTrue(50d == enterprise.Speed);
- Asse...
[truncated message content] |
|
From: <fab...@us...> - 2009-02-08 13:37:29
|
Revision: 4072
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4072&view=rev
Author: fabiomaulo
Date: 2009-02-08 13:37:25 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
Reorganization of Tests about custom queries and StoredProcedure
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomStoredProcSupportTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/IdentityInsertWithStoredProcsTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcs.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Identity/MsSQL/MSSQLIdentityInsertWithStoredProcsTest.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/SqlTest/FireBirdEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/FireBirdTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/HandSQLTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/IdentityInsertWithStoredProcsTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLEmployment.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcs.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLIdentityInsertWithStoredProcsTest.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLTest.cs
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 12:46:06 UTC (rev 4071)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 13:37:25 UTC (rev 4072)
@@ -931,6 +931,8 @@
<Compile Include="ReflectionOptimizerTest\LcgFixture.cs" />
<Compile Include="SessionFactoryTest\Item.cs" />
<Compile Include="SessionFactoryTest\SessionFactorySerializationFixture.cs" />
+ <Compile Include="SqlTest\Custom\CustomSQLSupportTest.cs" />
+ <Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" />
<Compile Include="SecondLevelCacheTest\AnotherItem.cs" />
@@ -950,15 +952,14 @@
<Compile Include="SqlCommandTest\TemplateFixture.cs" />
<Compile Include="SqlTest\Dimension.cs" />
<Compile Include="SqlTest\Employment.cs" />
- <Compile Include="SqlTest\FireBirdTest.cs" />
+ <Compile Include="SqlTest\Custom\Firebird\FireBirdTest.cs" />
<Compile Include="SqlTest\Query\NativeSQLQueriesFixture.cs" />
- <Compile Include="SqlTest\HandSQLTest.cs" />
- <Compile Include="SqlTest\IdentityInsertWithStoredProcsTest.cs" />
+ <Compile Include="SqlTest\Identity\IdentityInsertWithStoredProcsTest.cs" />
<Compile Include="SqlTest\Query\Item.cs" />
<Compile Include="SqlTest\MonetaryAmount.cs" />
<Compile Include="SqlTest\MonetaryAmountUserType.cs" />
- <Compile Include="SqlTest\MSSQLIdentityInsertWithStoredProcsTest.cs" />
- <Compile Include="SqlTest\MSSQLTest.cs" />
+ <Compile Include="SqlTest\Identity\MsSQL\MSSQLIdentityInsertWithStoredProcsTest.cs" />
+ <Compile Include="SqlTest\Custom\MsSQL\MSSQLTest.cs" />
<Compile Include="SqlTest\NullDateUserType.cs" />
<Compile Include="SqlTest\Order.cs" />
<Compile Include="SqlTest\Organization.cs" />
@@ -1252,7 +1253,7 @@
<EmbeddedResource Include="FilterTest\FilterMapping.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="SqlTest\MSSQLEmployment.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Custom\MsSQL\MSSQLEmployment.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="SqlTest\Query\NativeSQLQueries.hbm.xml" />
@@ -1301,7 +1302,7 @@
<EmbeddedResource Include="NHSpecificTest\NH606\Mapping.hbm.xml" />
</ItemGroup>
<ItemGroup>
- <EmbeddedResource Include="SqlTest\FireBirdEmployment.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Custom\Firebird\FireBirdEmployment.hbm.xml" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="NHSpecificTest\NH732\Mappings.hbm.xml" />
@@ -1725,7 +1726,7 @@
<EmbeddedResource Include="EntityModeTest\Xml\Basic\AB.hbm.xml" />
<EmbeddedResource Include="EntityModeTest\Xml\Basic\Account.hbm.xml" />
<EmbeddedResource Include="EntityModeTest\Xml\Basic\Employer.hbm.xml" />
- <EmbeddedResource Include="SqlTest\MSSQLIdentityInsertWithStoredProcs.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Identity\MsSQL\MSSQLIdentityInsertWithStoredProcs.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1508\Mappings.hbm.xml" />
<EmbeddedResource Include="GenericTest\OrderedSetGeneric\OrderedSetFixture.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1293\Mappings.hbm.xml" />
@@ -1770,7 +1771,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
- <Folder Include="SqlTest\Custom\" />
+ <Folder Include="SqlTest\Custom\Oracle\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomSQLSupportTest.cs 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,85 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom
+{
+ public abstract class CustomSQLSupportTest: TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected static object GetFirstItem(IEnumerable it)
+ {
+ IEnumerator en = it.GetEnumerator();
+ return en.MoveNext() ? en.Current : null;
+ }
+
+ [Test]
+ public void HandSQL()
+ {
+ ISession s = OpenSession();
+ ITransaction t = s.BeginTransaction();
+ Organization ifa = new Organization("IFA");
+ Organization jboss = new Organization("JBoss");
+ Person gavin = new Person("Gavin");
+ Employment emp = new Employment(gavin, jboss, "AU");
+ object orgId = s.Save(jboss);
+ s.Save(ifa);
+ s.Save(gavin);
+ s.Save(emp);
+ t.Commit();
+
+ t = s.BeginTransaction();
+ Person christian = new Person("Christian");
+ s.Save(christian);
+ Employment emp2 = new Employment(christian, jboss, "EU");
+ s.Save(emp2);
+ t.Commit();
+ s.Close();
+
+ sessions.Evict(typeof(Organization));
+ sessions.Evict(typeof(Person));
+ sessions.Evict(typeof(Employment));
+
+ s = OpenSession();
+ t = s.BeginTransaction();
+ jboss = (Organization)s.Get(typeof(Organization), orgId);
+ Assert.AreEqual(jboss.Employments.Count, 2);
+ emp = (Employment)GetFirstItem(jboss.Employments);
+ gavin = emp.Employee;
+ Assert.AreEqual(gavin.Name, "GAVIN");
+ Assert.AreEqual(s.GetCurrentLockMode(gavin), LockMode.Upgrade);
+ emp.EndDate = DateTime.Today;
+ Employment emp3 = new Employment(gavin, jboss, "US");
+ s.Save(emp3);
+ t.Commit();
+ s.Close();
+
+ s = OpenSession();
+ t = s.BeginTransaction();
+ IEnumerator iter = s.GetNamedQuery("allOrganizationsWithEmployees").List().GetEnumerator();
+ Assert.IsTrue(iter.MoveNext());
+ Organization o = (Organization)iter.Current;
+ Assert.AreEqual(o.Employments.Count, 3);
+
+ foreach (Employment e in o.Employments)
+ {
+ s.Delete(e);
+ }
+
+ foreach (Employment e in o.Employments)
+ {
+ s.Delete(e.Employee);
+ }
+ s.Delete(o);
+ Assert.IsFalse(iter.MoveNext());
+ s.Delete(ifa);
+ t.Commit();
+ s.Close();
+ }
+
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomStoredProcSupportTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomStoredProcSupportTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/CustomStoredProcSupportTest.cs 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,73 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom
+{
+ public abstract class CustomStoredProcSupportTest : CustomSQLSupportTest
+ {
+ [Test]
+ public void ScalarStoredProcedure()
+ {
+ ISession s = OpenSession();
+ IQuery namedQuery = s.GetNamedQuery("simpleScalar");
+ namedQuery.SetInt64("number", 43L);
+ IList list = namedQuery.List();
+ object[] o = (object[])list[0];
+ Assert.AreEqual(o[0], "getAll");
+ Assert.AreEqual(o[1], 43L);
+ s.Close();
+ }
+
+ [Test]
+ public void ParameterHandling()
+ {
+ ISession s = OpenSession();
+
+ IQuery namedQuery = s.GetNamedQuery("paramhandling");
+ namedQuery.SetInt64(0, 10L);
+ namedQuery.SetInt64(1, 20L);
+ IList list = namedQuery.List();
+ object[] o = (Object[])list[0];
+ Assert.AreEqual(o[0], 10L);
+ Assert.AreEqual(o[1], 20L);
+
+ namedQuery = s.GetNamedQuery("paramhandling_mixed");
+ namedQuery.SetInt64(0, 10L);
+ namedQuery.SetInt64("second", 20L);
+ list = namedQuery.List();
+ o = (object[])list[0];
+ Assert.AreEqual(o[0], 10L);
+ Assert.AreEqual(o[1], 20L);
+ s.Close();
+ }
+
+ [Test]
+ public void EntityStoredProcedure()
+ {
+ ISession s = OpenSession();
+ ITransaction t = s.BeginTransaction();
+
+ Organization ifa = new Organization("IFA");
+ Organization jboss = new Organization("JBoss");
+ Person gavin = new Person("Gavin");
+ Employment emp = new Employment(gavin, jboss, "AU");
+ s.Save(ifa);
+ s.Save(jboss);
+ s.Save(gavin);
+ s.Save(emp);
+
+ IQuery namedQuery = s.GetNamedQuery("selectAllEmployments");
+ IList list = namedQuery.List();
+ Assert.IsTrue(list[0] is Employment);
+ s.Delete(emp);
+ s.Delete(ifa);
+ s.Delete(jboss);
+ s.Delete(gavin);
+
+ t.Commit();
+ s.Close();
+ }
+
+ }
+}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml (from rev 4070, trunk/nhibernate/src/NHibernate.Test/SqlTest/FireBirdEmployment.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,235 @@
+<?xml version="1.0"?>
+<!--
+
+ This mapping demonstrates the use of Hibernate with
+ all-handwritten SQL!
+
+ This version is for Firebird
+-->
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.SqlTest"
+ default-access="field.camelcase">
+
+ <class name="Organization" table="ORGANIZATION">
+ <id name="Id" unsaved-value="0" column="ORGID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <set name="Employments"
+ inverse="true"
+ order-by="DUMMY">
+ <key column="EMPLOYER"/>
+ <!-- only needed for DDL generation -->
+ <one-to-many class="Employment"/>
+ <loader query-ref="organizationEmployments"/>
+ </set>
+ <!-- query-list name="currentEmployments"
+ query-ref="organizationCurrentEmployments"-->
+ <loader query-ref="organization"/>
+ <sql-insert>INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update>
+ <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete>
+ </class>
+
+ <class name="Person" table="PERSON">
+ <id name="Id" unsaved-value="0" column="PERID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <loader query-ref="person"/>
+ <sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
+ <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
+ </class>
+
+ <class name="Employment" table="EMPLOYMENT">
+ <id name="employmentId" unsaved-value="0" column="EMPID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="Employee" column="EMPLOYEE" not-null="true" update="false"/>
+ <many-to-one name="Employer" column="EMPLOYER" not-null="true" update="false"/>
+ <property name="StartDate" column="STARTDATE" not-null="true" update="false" insert="false"/>
+ <property name="EndDate" column="ENDDATE" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test"/>
+ <property name="RegionCode" column="REGIONCODE" update="false"/>
+ <property name="Salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test">
+ <column name="AVALUE" sql-type="float"/>
+ <column name="CURRENCY"/>
+ </property>
+ <loader query-ref="employment"/>
+ <sql-insert>
+ INSERT INTO EMPLOYMENT
+ (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, AVALUE, CURRENCY, EMPID)
+ VALUES (?, ?, 'NOW', UPPER(?), ?, ?, ?)
+ </sql-insert>
+ <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, AVALUE=?, CURRENCY=? WHERE EMPID=?</sql-update>
+ <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
+ </class>
+
+ <resultset name="org-emp-regionCode">
+ <return-scalar column="regionCode" type="string"/>
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ </resultset>
+
+ <resultset name="org-emp-person">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ <return-join alias="pers" property="emp.Employee"/>
+ </resultset>
+
+ <sql-query name="person">
+ <return alias="p" class="Person" lock-mode="upgrade"/>
+ SELECT NAME AS {p.Name}, PERID AS {p.Id} FROM PERSON WHERE PERID=? FOR UPDATE
+ </sql-query>
+
+ <sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ SELECT {org.*}, {emp.*}
+ FROM ORGANIZATION org
+ LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
+ WHERE org.ORGID=?
+ </sql-query>
+
+
+ <!--sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ SELECT NAME AS {org.name}, ORGID AS {org.id} FROM ORGANIZATION
+ WHERE ORGID=?
+ </sql-query-->
+
+ <sql-query name="allOrganizationsWithEmployees">
+ <!-- TODO H3: add flush-mode="never" -->
+ <return alias="org" class="Organization"/>
+ SELECT DISTINCT org.NAME AS {org.Name}, org.ORGID AS {org.Id}
+ FROM ORGANIZATION org
+ INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID
+ </sql-query>
+
+ <sql-query name="employment">
+ <return alias="emp" class="Employment"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.Id}
+ FROM EMPLOYMENT
+ WHERE EMPID = ?
+ </sql-query>
+
+ <sql-query name="organizationEmployments">
+ <load-collection alias="empcol" role="Organization.Employments"/>
+ SELECT {empcol.*}
+ FROM EMPLOYMENT empcol
+ WHERE EMPLOYER = :id
+ ORDER BY STARTDATE ASC, EMPLOYEE ASC
+ </sql-query>
+
+
+ <sql-query name="organizationCurrentEmployments">
+ <return alias="emp" class="Employment">
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="AVALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ <!-- Here we are remapping endDate. Notice that we can still use {emp.EndDate} in the SQL. -->
+ <return-property name="EndDate" column="myEndDate"/>
+ </return>
+ <synchronize table="EMPLOYMENT"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.Id}, AVALUE, CURRENCY
+ FROM EMPLOYMENT
+ WHERE EMPLOYER = :id AND ENDDATE IS NULL
+ ORDER BY STARTDATE ASC
+ </sql-query>
+
+ <sql-query name="simpleScalar">
+ <return-scalar column="name" type="string"/>
+ <return-scalar column="value1" type="long"/>
+ SELECT * FROM simpleScalar(:number)
+ </sql-query>
+
+ <sql-query name="paramhandling">
+ <return-scalar column="value1" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ SELECT * FROM paramHandling( ?, ?)
+ </sql-query>
+
+ <sql-query name="paramhandling_mixed">
+ <return-scalar column="value1" type="long" />
+ <return-scalar column="value2" type="long" />
+ SELECT * FROM paramHandling( ?, :second)
+ </sql-query>
+
+ <sql-query name="selectAllEmployments">
+ <return class="Employment">
+ <return-property name="Employee" column="EMPLOYEE"/>
+ <return-property name="Employer" column="EMPLOYER"/>
+ <return-property name="StartDate" column="STARTDATE"/>
+ <return-property name="EndDate" column="ENDDATE"/>
+ <return-property name="RegionCode" column="REGIONCODE"/>
+ <return-property name="id" column="EMPID"/>
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="AVALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ </return>
+ SELECT * FROM selectAllEmployments
+ </sql-query>
+
+ <database-object>
+ <create>
+CREATE PROCEDURE selectAllEmployments
+RETURNS(EMPLOYEE BIGINT, EMPLOYER BIGINT, STARTDATE TIMESTAMP, ENDDATE DATE,
+REGIONCODE VARCHAR(255) CHARACTER SET WIN1252, EMPID BIGINT, AVALUE FLOAT,
+CURRENCY VARCHAR(3) CHARACTER SET WIN1252)
+AS
+BEGIN
+FOR SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE, REGIONCODE, EMPID, AVALUE, CURRENCY FROM EMPLOYMENT
+INTO :EMPLOYEE, :EMPLOYER, :STARTDATE, :ENDDATE, :REGIONCODE, :EMPID, :AVALUE, :CURRENCY DO
+SUSPEND;
+END;
+ </create>
+ <drop>
+ DROP PROCEDURE selectAllEmployments
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+CREATE PROCEDURE paramHandling(J INTEGER, I INTEGER)
+RETURNS(VALUE1 INTEGER, VALUE2 INTEGER)
+AS
+BEGIN
+VALUE1 = :J;
+VALUE2 = :I;
+SUSPEND;
+END;
+ </create>
+ <drop>
+ DROP PROCEDURE paramHandling
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+CREATE PROCEDURE simpleScalar(ANUMBER INTEGER)
+RETURNS(VALUE1 INTEGER, NAME VARCHAR(10) CHARACTER SET UNICODE_FSS)
+AS
+BEGIN
+VALUE1 = :ANUMBER;
+NAME = 'getAll';
+SUSPEND;
+END;
+ </create>
+ <drop>
+ DROP PROCEDURE simpleScalar
+ </drop>
+ </database-object>
+
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdEmployment.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs (from rev 4070, trunk/nhibernate/src/NHibernate.Test/SqlTest/FireBirdTest.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,20 @@
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom.Firebird
+{
+ [TestFixture]
+ public class FireBirdTest : CustomStoredProcSupportTest
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"SqlTest.Custom.Firebird.FireBirdEmployment.hbm.xml"}; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is FirebirdDialect;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Firebird/FireBirdTest.cs
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml (from rev 4070, trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLEmployment.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,221 @@
+<?xml version="1.0"?>
+<!--
+
+ This mapping demonstrates the use of Hibernate with
+ all-handwritten SQL!
+
+ This version is for Sybase/mssql
+-->
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.SqlTest"
+ default-access="field.camelcase">
+
+ <class name="Organization" table="ORGANIZATION">
+ <id name="Id" unsaved-value="0" column="ORGID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <set name="Employments"
+ inverse="true"
+ order-by="DUMMY">
+ <key column="EMPLOYER"/>
+ <!-- only needed for DDL generation -->
+ <one-to-many class="Employment"/>
+ <loader query-ref="organizationEmployments"/>
+ </set>
+ <!-- query-list name="currentEmployments"
+ query-ref="organizationCurrentEmployments"-->
+ <loader query-ref="organization"/>
+ <sql-insert>INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update>
+ <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete>
+ </class>
+
+ <class name="Person" table="PERSON">
+ <id name="Id" unsaved-value="0" column="PERID">
+ <generator class="increment"/>
+ </id>
+ <property name="Name" not-null="true" column="NAME"/>
+ <loader query-ref="person"/>
+ <sql-insert>INSERT INTO PERSON (NAME, PERID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
+ <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
+ </class>
+
+ <class name="Employment" table="EMPLOYMENT">
+ <id name="employmentId" unsaved-value="0" column="EMPID">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="Employee" column="EMPLOYEE" not-null="true" update="false"/>
+ <many-to-one name="Employer" column="EMPLOYER" not-null="true" update="false"/>
+ <property name="StartDate" column="STARTDATE" not-null="true" update="false" insert="false"/>
+ <property name="EndDate" column="ENDDATE" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test"/>
+ <property name="RegionCode" column="REGIONCODE" update="false"/>
+ <property name="Salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test">
+ <column name="VALUE" sql-type="float"/>
+ <column name="CURRENCY"/>
+ </property>
+ <loader query-ref="employment"/>
+ <sql-insert>
+ INSERT INTO EMPLOYMENT
+ (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID)
+ VALUES (?, ?, getdate(), UPPER(?), ?, ?, ?)
+ </sql-insert>
+ <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, VALUE=?, CURRENCY=? WHERE EMPID=?</sql-update>
+ <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
+ </class>
+
+ <resultset name="org-emp-regionCode">
+ <return-scalar column="regionCode" type="string"/>
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ </resultset>
+
+ <resultset name="org-emp-person">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ <return-join alias="pers" property="emp.Employee"/>
+ </resultset>
+
+ <sql-query name="person">
+ <return alias="p" class="Person" lock-mode="upgrade"/>
+ SELECT NAME AS {p.Name}, PERID AS {p.Id} FROM PERSON WHERE PERID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.Employments"/>
+ SELECT {org.*}, {emp.*}
+ FROM ORGANIZATION org
+ LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
+ WHERE org.ORGID=?
+ </sql-query>
+
+
+ <!--sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ SELECT NAME AS {org.name}, ORGID AS {org.id} FROM ORGANIZATION
+ WHERE ORGID=?
+ </sql-query-->
+
+ <sql-query name="allOrganizationsWithEmployees">
+ <!-- TODO H3: add flush-mode="never" -->
+ <return alias="org" class="Organization"/>
+ SELECT DISTINCT org.NAME AS {org.Name}, org.ORGID AS {org.Id}
+ FROM ORGANIZATION org
+ INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID
+ </sql-query>
+
+
+
+
+
+ <sql-query name="employment">
+ <return alias="emp" class="Employment"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.employmentId}
+ FROM EMPLOYMENT
+ WHERE EMPID = ?
+ </sql-query>
+
+ <sql-query name="organizationEmployments">
+ <load-collection alias="empcol" role="Organization.Employments"/>
+ SELECT {empcol.*}
+ FROM EMPLOYMENT empcol
+ WHERE EMPLOYER = :id
+ ORDER BY STARTDATE ASC, EMPLOYEE ASC
+ </sql-query>
+
+
+ <sql-query name="organizationCurrentEmployments">
+ <return alias="emp" class="Employment">
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ <!-- Here we are remapping endDate. Notice that we can still use {emp.EndDate} in the SQL. -->
+ <return-property name="EndDate" column="myEndDate"/>
+ </return>
+ <synchronize table="EMPLOYMENT"/>
+ SELECT EMPLOYEE AS {emp.Employee}, EMPLOYER AS {emp.Employer},
+ STARTDATE AS {emp.StartDate}, ENDDATE AS {emp.EndDate},
+ REGIONCODE as {emp.RegionCode}, EMPID AS {emp.employmentId}, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ WHERE EMPLOYER = :id AND ENDDATE IS NULL
+ ORDER BY STARTDATE ASC
+ </sql-query>
+
+ <sql-query name="simpleScalar">
+ <return-scalar column="name" type="string"/>
+ <return-scalar column="value" type="long"/>
+ exec simpleScalar :number
+ </sql-query>
+
+ <sql-query name="paramhandling">
+ <return-scalar column="value" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ exec paramHandling ?, ?
+ </sql-query>
+
+ <sql-query name="paramhandling_mixed">
+ <return-scalar column="value" type="long" />
+ <return-scalar column="value2" type="long" />
+ exec paramHandling ?, :second
+ </sql-query>
+
+ <sql-query name="selectAllEmployments">
+ <return class="Employment">
+ <return-property name="Employee" column="EMPLOYEE"/>
+ <return-property name="Employer" column="EMPLOYER"/>
+ <return-property name="StartDate" column="STARTDATE"/>
+ <return-property name="EndDate" column="ENDDATE"/>
+ <return-property name="RegionCode" column="REGIONCODE"/>
+ <return-property name="id" column="EMPID"/>
+ <return-property name="Salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ </return>
+ exec selectAllEmployments
+ </sql-query>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE selectAllEmployments AS
+ SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE,
+ REGIONCODE, EMPID, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ </create>
+ <drop>
+ DROP PROCEDURE selectAllEmployments
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE paramHandling @j int, @i int AS
+ SELECT @j as value, @i as value2
+ </create>
+ <drop>
+ DROP PROCEDURE paramHandling
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE PROCEDURE simpleScalar @number int AS
+ SELECT @number as value, 'getAll' as name
+ </create>
+ <drop>
+ DROP PROCEDURE simpleScalar
+ </drop>
+ </database-object>
+
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLEmployment.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs (from rev 4070, trunk/nhibernate/src/NHibernate.Test/SqlTest/MSSQLTest.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/MsSQL/MSSQLTest.cs 2009-02-08 13:37:25 UTC (rev 4072)
@@ -0,0 +1,20 @@
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom.MsSQL
+{
+ [TestFixture]
+ public class MSSQLTest : CustomStoredProcSupportTest
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "SqlTest.Custom.MsSQL.MSSQLEmployment.hbm.xml" }; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is MsSql2000Dialect;
+ }
+ }
+}
\ No newline at end of file
Property changes on: trunk/nhibernate/...
[truncated message content] |
|
From: <fab...@us...> - 2009-02-08 16:11:30
|
Revision: 4073
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4073&view=rev
Author: fabiomaulo
Date: 2009-02-08 16:11:27 +0000 (Sun, 08 Feb 2009)
Log Message:
-----------
Oracle custom Stored Procedures test (perhaps to fix NH-847 too)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/OracleCustomSQLFixture.cs
trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/StoredProcedures.hbm.xml
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 13:37:25 UTC (rev 4072)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 16:11:27 UTC (rev 4073)
@@ -933,6 +933,7 @@
<Compile Include="SessionFactoryTest\SessionFactorySerializationFixture.cs" />
<Compile Include="SqlTest\Custom\CustomSQLSupportTest.cs" />
<Compile Include="SqlTest\Custom\CustomStoredProcSupportTest.cs" />
+ <Compile Include="SqlTest\Custom\Oracle\OracleCustomSQLFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\MigrationFixture.cs" />
<Compile Include="Tools\hbm2ddl\SchemaUpdate\Version.cs" />
<Compile Include="SecondLevelCacheTest\AnotherItem.cs" />
@@ -1655,6 +1656,8 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="SqlTest\Custom\Oracle\Mappings.hbm.xml" />
+ <EmbeddedResource Include="SqlTest\Custom\Oracle\StoredProcedures.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1619\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1665\Mappings.hbm.xml" />
<EmbeddedResource Include="Generatedkeys\ByTrigger\MyEntity.hbm.xml" />
@@ -1771,7 +1774,6 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Properties\" />
- <Folder Include="SqlTest\Custom\Oracle\" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/Mappings.hbm.xml 2009-02-08 16:11:27 UTC (rev 4073)
@@ -0,0 +1,209 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+
+ This mapping demonstrates the use of Hibernate with
+ all-handwritten SQL!
+
+ This version is for Oracle
+-->
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.SqlTest"
+ default-access="field">
+
+ <class name="Organization">
+ <id name="id" unsaved-value="0" column="orgid">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <set name="employments"
+ inverse="true"
+ order-by="DUMMY">
+ <key column="employer"/>
+ <!-- only needed for DDL generation -->
+ <one-to-many class="Employment"/>
+ <loader query-ref="organizationEmployments"/>
+ </set>
+ <!-- query-list name="currentEmployments"
+ query-ref="organizationCurrentEmployments"-->
+ <loader query-ref="organization"/>
+ <sql-insert>INSERT INTO ORGANIZATION (NAME, ORGID) VALUES ( UPPER(?), ? )</sql-insert>
+ <sql-update>UPDATE ORGANIZATION SET NAME=UPPER(?) WHERE ORGID=?</sql-update>
+ <sql-delete>DELETE FROM ORGANIZATION WHERE ORGID=?</sql-delete>
+ </class>
+
+ <class name="Person">
+ <id name="id" unsaved-value="0" column="perid">
+ <generator class="increment"/>
+ </id>
+ <property name="name" not-null="true"/>
+ <loader query-ref="person"/>
+ <sql-insert callable="true" check="none">call createPerson(?,?)</sql-insert>
+ <sql-update>UPDATE PERSON SET NAME=UPPER(?) WHERE PERID=?</sql-update>
+ <sql-delete>DELETE FROM PERSON WHERE PERID=?</sql-delete>
+ </class>
+
+ <class name="Employment">
+ <id name="employmentId" unsaved-value="0" column="empid">
+ <generator class="increment"/>
+ </id>
+ <many-to-one name="employee" not-null="true" update="false"/>
+ <many-to-one name="employer" not-null="true" update="false"/>
+ <property name="startDate" not-null="true" update="false" insert="false"/>
+ <property name="endDate" insert="false" type="NHibernate.Test.SqlTest.NullDateUserType, NHibernate.Test"/>
+ <property name="regionCode" update="false"/>
+ <property name="salary" type="NHibernate.Test.SqlTest.MonetaryAmountUserType, NHibernate.Test">
+ <column name="VALUE" sql-type="float"/>
+ <column name="CURRENCY"/>
+ </property>
+ <loader query-ref="employment"/>
+ <sql-insert>
+ INSERT INTO EMPLOYMENT
+ (EMPLOYEE, EMPLOYER, STARTDATE, REGIONCODE, VALUE, CURRENCY, EMPID)
+ VALUES (?, ?, CURRENT_DATE, UPPER(?), ?, ?, ?)
+ </sql-insert>
+ <sql-update>UPDATE EMPLOYMENT SET ENDDATE=?, VALUE=?, CURRENCY=? WHERE EMPID=?</sql-update>
+ <sql-delete>DELETE FROM EMPLOYMENT WHERE EMPID=?</sql-delete>
+ </class>
+
+ <resultset name="org-emp-regionCode">
+ <return-scalar column="regionCode" type="string"/>
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ </resultset>
+
+ <resultset name="org-emp-person">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ <return-join alias="pers" property="emp.employee"/>
+ </resultset>
+
+ <sql-query name="person">
+ <return alias="p" class="Person" lock-mode="upgrade"/>
+ SELECT NAME AS {p.name}, PERID AS {p.id} FROM PERSON WHERE PERID=? /*FOR UPDATE*/
+ </sql-query>
+
+ <sql-query name="organization">
+ <return alias="org" class="Organization"/>
+ <return-join alias="emp" property="org.employments"/>
+ SELECT {org.*}, {emp.*}
+ FROM ORGANIZATION org
+ LEFT OUTER JOIN EMPLOYMENT emp ON org.ORGID = emp.EMPLOYER
+ WHERE org.ORGID=?
+ </sql-query>
+
+ <sql-query name="allOrganizationsWithEmployees" flush-mode="never">
+ <return alias="org" class="Organization"/>
+ SELECT DISTINCT org.NAME AS {org.name}, org.ORGID AS {org.id}
+ FROM ORGANIZATION org
+ INNER JOIN EMPLOYMENT e ON e.EMPLOYER = org.ORGID
+ </sql-query>
+
+
+ <sql-query name="employment">
+ <return alias="emp" class="Employment"/>
+ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},
+ STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},
+ REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}
+ FROM EMPLOYMENT
+ WHERE EMPID = ?
+ </sql-query>
+
+ <sql-query name="organizationEmployments">
+ <load-collection alias="empcol" role="Organization.employments"/>
+ SELECT {empcol.*}
+ FROM EMPLOYMENT empcol
+ WHERE EMPLOYER = :id
+ ORDER BY STARTDATE ASC, EMPLOYEE ASC
+ </sql-query>
+
+ <sql-query name="organizationCurrentEmployments">
+ <return alias="emp" class="Employment">
+ <return-property name="salary">
+ <!-- as multi column properties are not supported via the
+ {}-syntax, we need to provide an explicit column list for salary via <return-property> -->
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ <!-- Here we are remapping endDate. Notice that we can still use {emp.endDate} in the SQL. -->
+ <return-property name="endDate" column="myEndDate"/>
+ </return>
+ <synchronize table="EMPLOYMENT"/>
+ SELECT EMPLOYEE AS {emp.employee}, EMPLOYER AS {emp.employer},
+ STARTDATE AS {emp.startDate}, ENDDATE AS {emp.endDate},
+ REGIONCODE as {emp.regionCode}, EMPID AS {emp.id}, VALUE, CURRENCY
+ FROM EMPLOYMENT
+ WHERE EMPLOYER = :id AND ENDDATE IS NULL
+ ORDER BY STARTDATE ASC
+ </sql-query>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE FUNCTION testParamHandling (j number, i number)
+ RETURN SYS_REFCURSOR AS st_cursor SYS_REFCURSOR;
+ BEGIN
+ OPEN st_cursor FOR
+ SELECT j as value, i as value2 from dual;
+ RETURN st_cursor;
+ END;
+ </create>
+ <drop>
+ DROP FUNCTION testParamHandling
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE FUNCTION simpleScalar (j number)
+ RETURN SYS_REFCURSOR AS st_cursor SYS_REFCURSOR;
+ BEGIN
+ OPEN st_cursor FOR
+ SELECT j as value, 'getAll' as name from dual;
+ RETURN st_cursor;
+ END;
+ </create>
+ <drop>
+ DROP FUNCTION simpleScalar
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE FUNCTION allEmployments
+ RETURN SYS_REFCURSOR AS st_cursor SYS_REFCURSOR;
+ BEGIN
+ OPEN st_cursor FOR
+ SELECT EMPLOYEE, EMPLOYER, STARTDATE, ENDDATE,
+ REGIONCODE, EMPID, VALUE, CURRENCY
+ FROM EMPLOYMENT;
+ RETURN st_cursor;
+ END;
+ </create>
+ <drop>
+ DROP FUNCTION allEmployments
+ </drop>
+ </database-object>
+
+ <database-object>
+ <create>
+ CREATE OR REPLACE PROCEDURE createPerson(p_name PERSON.NAME%TYPE, p_id PERSON.PERID%TYPE)
+ AS
+ rowcount INTEGER;
+ BEGIN
+ INSERT INTO PERSON ( PERID, NAME ) VALUES ( p_id, UPPER( p_name ) );
+ rowcount := SQL%ROWCOUNT;
+ IF rowcount = 1 THEN
+ NULL;
+ ELSE
+ RAISE_APPLICATION_ERROR( -20001, 'Unexpected rowcount [' || rowcount || ']' );
+ END IF;
+ END;
+ </create>
+ <drop>
+ DROP PROCEDURE createPerson;
+ </drop>
+ </database-object>
+
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/OracleCustomSQLFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/OracleCustomSQLFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/OracleCustomSQLFixture.cs 2009-02-08 16:11:27 UTC (rev 4073)
@@ -0,0 +1,20 @@
+using System.Collections;
+using NHibernate.Dialect;
+using NUnit.Framework;
+
+namespace NHibernate.Test.SqlTest.Custom.Oracle
+{
+ [TestFixture, Ignore("Not supported yet.")]
+ public class OracleCustomSQLFixture : CustomStoredProcSupportTest
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "SqlTest.Custom.Oracle.Mappings.hbm.xml", "SqlTest.Custom.Oracle.StoredProcedures.hbm.xml" }; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ return dialect is Oracle8iDialect;
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/StoredProcedures.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/StoredProcedures.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/SqlTest/Custom/Oracle/StoredProcedures.hbm.xml 2009-02-08 16:11:27 UTC (rev 4073)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<!--
+ This version is for Oracle drivers handling of stored procedures/functions.
+
+
+ NOTE: so far this is the JAVA syntax, probably we will do something different in .NET
+ or we can use the same syntax and solve the problem in each Oracle drive
+-->
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.SqlTest"
+ default-access="field">
+
+ <sql-query name="simpleScalar" callable="true">
+ <return-scalar column="name" type="string"/>
+ <return-scalar column="value" type="long"/>
+ call simpleScalar(:number)
+ </sql-query>
+
+ <sql-query name="paramhandling" callable="true">
+ <return-scalar column="value" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ call testParamHandling(?,?)
+ </sql-query>
+
+ <sql-query name="paramhandling_mixed" callable="true">
+ <return-scalar column="value" type="long"/>
+ <return-scalar column="value2" type="long"/>
+ call testParamHandling(?,:second)
+ </sql-query>
+
+ <sql-query name="selectAllEmployments" callable="true">
+ <return alias="emp" class="Employment">
+ <return-property name="employee" column="EMPLOYEE"/>
+ <return-property name="employer" column="EMPLOYER"/>
+ <return-property name="startDate" column="STARTDATE"/>
+ <return-property name="endDate" column="ENDDATE"/>
+ <return-property name="regionCode" column="REGIONCODE"/>
+ <return-property name="employmentId" column="EMPID"/>
+ <return-property name="salary">
+ <return-column name="VALUE"/>
+ <return-column name="CURRENCY"/>
+ </return-property>
+ </return>
+ call allEmployments()
+ </sql-query>
+
+</hibernate-mapping>
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-09 00:15:07
|
Revision: 4080
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4080&view=rev
Author: darioquintana
Date: 2009-02-09 00:14:43 +0000 (Mon, 09 Feb 2009)
Log Message:
-----------
passing for PostgreSQL: the type for a System.Boolean is 'boolean' instead of 'int'
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/MappingsFilterAsBoolean.hbm.xml
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2009-02-08 23:48:01 UTC (rev 4079)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Fixture.cs 2009-02-09 00:14:43 UTC (rev 4080)
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using NHibernate.Criterion;
+using NHibernate.Dialect;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.NH1293
@@ -8,6 +9,17 @@
[TestFixture]
public class Fixture : BugTestCase
{
+ protected override System.Collections.IList Mappings
+ {
+ get
+ {
+ if (Dialect is PostgreSQLDialect)
+ return new[] {"NHSpecificTest.NH1293.MappingsFilterAsBoolean.hbm.xml"};
+
+ return base.Mappings;
+ }
+ }
+
[Test]
public void Criteria_Does_Not_Equal_To_HQL()
{
@@ -29,8 +41,12 @@
{
s.DisableFilter("onlyActive");
IFilter fltr = s.EnableFilter("onlyActive");
- fltr.SetParameter("activeFlag", 1);
+ if(Dialect is PostgreSQLDialect)
+ fltr.SetParameter("activeFlag", true);
+ else
+ fltr.SetParameter("activeFlag", 1);
+
// with HQL, Category.IsActive=true filter applied, result count=2
IQuery hqlQuery = s.CreateQuery("from Customer c where c.Category.Name = ?");
hqlQuery.SetParameter(0, "User"); // note using positional parameters because of NH-1490
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml 2009-02-08 23:48:01 UTC (rev 4079)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml 2009-02-09 00:14:43 UTC (rev 4080)
@@ -5,24 +5,24 @@
<generator class="native" />
</id>
<property name="Name" not-null="true" />
- <property name="IsActive" not-null="true" />
- <many-to-one name="Category" lazy="false" column="Category_Id" />
-
- <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ <property name="IsActive" not-null="true" />
+ <many-to-one name="Category" lazy="false" column="Category_Id" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
</class>
-
- <class name="Category" table="Category" mutable="true">
+
+ <class name="Category" table="Category" mutable="true">
<id name="Id" column="Id">
<generator class="native" />
</id>
- <property name="Name" not-null="true" />
- <property name="IsActive" not-null="true" />
-
- <filter name="onlyActive" condition=":activeFlag = IsActive" />
- </class>
-
- <filter-def name="onlyActive">
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <filter-def name="onlyActive">
<filter-param name="activeFlag" type="int"/>
</filter-def>
-
+
</hibernate-mapping>
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/MappingsFilterAsBoolean.hbm.xml (from rev 4079, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/MappingsFilterAsBoolean.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1293/MappingsFilterAsBoolean.hbm.xml 2009-02-09 00:14:43 UTC (rev 4080)
@@ -0,0 +1,28 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1293">
+ <class name="Customer" table="Customer">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+ <many-to-one name="Category" lazy="false" column="Category_Id" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <class name="Category" table="Category" mutable="true">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <filter-def name="onlyActive">
+ <filter-param name="activeFlag" type="boolean"/>
+ </filter-def>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-08 23:48:01 UTC (rev 4079)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-09 00:14:43 UTC (rev 4080)
@@ -1657,6 +1657,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1293\MappingsFilterAsBoolean.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\MySQL\MySQLEmployment.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\Oracle\Mappings.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\Oracle\StoredProcedures.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-02-09 00:22:51
|
Revision: 4081
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4081&view=rev
Author: darioquintana
Date: 2009-02-09 00:22:45 +0000 (Mon, 09 Feb 2009)
Log Message:
-----------
passing for PostgreSQL: the type for a System.Boolean is 'boolean' instead of 'int'
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/MappingsFilterAsBoolean.hbm.xml
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2009-02-09 00:14:43 UTC (rev 4080)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Fixture.cs 2009-02-09 00:22:45 UTC (rev 4081)
@@ -1,4 +1,5 @@
using System.Collections.Generic;
+using NHibernate.Dialect;
using NUnit.Framework;
using NUnit.Framework.SyntaxHelpers;
@@ -7,6 +8,17 @@
[TestFixture]
public class Fixture : BugTestCase
{
+ protected override System.Collections.IList Mappings
+ {
+ get
+ {
+ if (Dialect is PostgreSQLDialect)
+ return new[] { "NHSpecificTest.NH1490.MappingsFilterAsBoolean.hbm.xml" };
+
+ return base.Mappings;
+ }
+ }
+
[Test]
public void Can_Translate_Correctly_Without_Filter()
{
@@ -59,7 +71,11 @@
{
s.DisableFilter("onlyActive");
IFilter fltr = s.EnableFilter("onlyActive");
- fltr.SetParameter("activeFlag", 1);
+
+ if (Dialect is PostgreSQLDialect)
+ fltr.SetParameter("activeFlag", true);
+ else
+ fltr.SetParameter("activeFlag", 1);
// Customer is parametrized
IQuery query = s.CreateQuery("from Customer c where c.Name = :customerName");
@@ -97,7 +113,11 @@
{
s.DisableFilter("onlyActive");
IFilter fltr = s.EnableFilter("onlyActive");
- fltr.SetParameter("activeFlag", 1);
+ if (Dialect is PostgreSQLDialect)
+ fltr.SetParameter("activeFlag", true);
+ else
+ fltr.SetParameter("activeFlag", 1);
+
// related entity Customer.Category is parametrized
IQuery query = s.CreateQuery("from Customer c where c.Category.Name = :catName");
query.SetParameter("catName", "User");
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/MappingsFilterAsBoolean.hbm.xml (from rev 4079, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/MappingsFilterAsBoolean.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1490/MappingsFilterAsBoolean.hbm.xml 2009-02-09 00:22:45 UTC (rev 4081)
@@ -0,0 +1,30 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1490">
+
+ <class name="Customer" table="Customer">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+ <many-to-one name="Category" lazy="false" column="Category_Id" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <class name="Category" table="Category" mutable="true">
+ <id name="Id" column="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" not-null="true" />
+ <property name="IsActive" not-null="true" />
+
+ <filter name="onlyActive" condition=":activeFlag = IsActive" />
+ </class>
+
+ <filter-def name="onlyActive">
+ <filter-param name="activeFlag" type="boolean"/>
+ </filter-def>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-09 00:14:43 UTC (rev 4080)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-09 00:22:45 UTC (rev 4081)
@@ -1657,6 +1657,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1490\MappingsFilterAsBoolean.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1293\MappingsFilterAsBoolean.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\MySQL\MySQLEmployment.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\Oracle\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <aye...@us...> - 2009-02-12 07:05:37
|
Revision: 4083
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4083&view=rev
Author: ayenderahien
Date: 2009-02-12 07:05:27 +0000 (Thu, 12 Feb 2009)
Log Message:
-----------
Adding passing tests - evict behavior
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting
___________________________________________________________________
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs (from rev 4082, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1001/Employee.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs 2009-02-12 07:05:27 UTC (rev 4083)
@@ -0,0 +1,33 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.Evicting
+{
+ public class Employee
+ {
+ private int id;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ private string firstName;
+
+ public string FirstName
+ {
+ get { return firstName; }
+ set { firstName = value; }
+ }
+
+ private string lastName;
+
+ public string LastName
+ {
+ get { return lastName; }
+ set { lastName = value; }
+ }
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Employee.cs
___________________________________________________________________
Added: svn:keywords
+ Id HeadUrl
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs (from rev 4082, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1001/Fixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs 2009-02-12 07:05:27 UTC (rev 4083)
@@ -0,0 +1,108 @@
+using NHibernate.Cfg;
+using NUnit.Framework;
+using NHibernate.Stat;
+
+namespace NHibernate.Test.NHSpecificTest.Evicting
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ public override string BugNumber
+ {
+ get { return "Evicting"; }
+ }
+
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+ using (var session = sessions.OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ session.Save(new Employee
+ {
+ Id = 1,
+ FirstName = "a",
+ LastName = "b"
+ });
+ tx.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (var session = sessions.OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ session.Delete(session.Load<Employee>(1));
+
+ tx.Commit();
+ }
+ base.OnTearDown();
+ }
+
+
+ [Test]
+ public void Can_evict_entity_from_session()
+ {
+ using (var session = sessions.OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ var employee = session.Load<Employee>(1);
+ Assert.IsTrue(session.Contains(employee));
+
+ session.Evict(employee);
+
+ Assert.IsFalse(session.Contains(employee));
+
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void Can_evict_non_persistent_object()
+ {
+
+ using (var session = sessions.OpenSession())
+ using (var tx = session.BeginTransaction())
+ {
+ var employee = new Employee();
+ Assert.IsFalse(session.Contains(employee));
+
+ session.Evict(employee);
+
+ Assert.IsFalse(session.Contains(employee));
+
+ tx.Commit();
+ }
+ }
+
+ [Test]
+ public void Can_evict_when_trying_to_evict_entity_from_another_session()
+ {
+
+ using (var session1 = sessions.OpenSession())
+ using (var tx1 = session1.BeginTransaction())
+ {
+
+ using (var session2 = sessions.OpenSession())
+ using (var tx2 = session2.BeginTransaction())
+ {
+ var employee = session2.Load<Employee>(1);
+ Assert.IsFalse(session1.Contains(employee));
+ Assert.IsTrue(session2.Contains(employee));
+
+ session1.Evict(employee);
+
+ Assert.IsFalse(session1.Contains(employee));
+
+ Assert.IsTrue(session2.Contains(employee));
+
+ tx2.Commit();
+ }
+
+ tx1.Commit();
+ }
+ }
+
+ }
+}
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Fixture.cs
___________________________________________________________________
Added: svn:keywords
+ Id HeadUrl
Added: svn:mergeinfo
+
Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml (from rev 4082, trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1001/Mappings.hbm.xml)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml 2009-02-12 07:05:27 UTC (rev 4083)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.Evicting"
+ assembly="NHibernate.Test">
+
+
+ <class name="Employee" table="EMPLOYEES" lazy="false">
+ <id name="Id" column="EMPLOYEE_ID" type="Int32">
+ <generator class="assigned" />
+ </id>
+
+ <property name="FirstName" column="FIRST_NAME" type="String" />
+ <property name="LastName" column="LAST_NAME" type="String" />
+
+ </class>
+</hibernate-mapping>
Property changes on: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/Evicting/Mappings.hbm.xml
___________________________________________________________________
Added: svn:mergeinfo
+
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-09 20:01:34 UTC (rev 4082)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-02-12 07:05:27 UTC (rev 4083)
@@ -395,6 +395,8 @@
<Compile Include="NHSpecificTest\Dates\DateTime2Fixture.cs" />
<Compile Include="NHSpecificTest\Dates\DateTimeAssert.cs" />
<Compile Include="NHSpecificTest\EntityModeToTuplizerPerf\Fixture.cs" />
+ <Compile Include="NHSpecificTest\Evicting\Employee.cs" />
+ <Compile Include="NHSpecificTest\Evicting\Fixture.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\VendorCatalog.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\Fixture.cs" />
<Compile Include="NHSpecificTest\FileStreamSql2008\Convert.cs" />
@@ -1657,6 +1659,7 @@
<EmbeddedResource Include="Cascade\JobBatch.hbm.xml" />
<EmbeddedResource Include="Deletetransient\Person.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\Evicting\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1490\MappingsFilterAsBoolean.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1293\MappingsFilterAsBoolean.hbm.xml" />
<EmbeddedResource Include="SqlTest\Custom\MySQL\MySQLEmployment.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|