You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2009-10-18 20:51:12
|
Revision: 4791 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4791&view=rev Author: fabiomaulo Date: 2009-10-18 20:51:03 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Minor (cleaned to be back ported) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/DummyEntity.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,24 +1,10 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NHibernate.Test.NHSpecificTest.NH1969 +namespace NHibernate.Test.NHSpecificTest.NH1969 { - /// <summary> - /// Author : Stephane Verlet - /// </summary> - public class DummyEntity - { - - private int _id; - - - public int Id - { - get { return _id; } - set { _id = value; } - } - - } -} + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class DummyEntity + { + public int Id { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/EntityWithTypeProperty.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,35 +1,12 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace NHibernate.Test.NHSpecificTest.NH1969 +namespace NHibernate.Test.NHSpecificTest.NH1969 { - /// <summary> - /// Author : Stephane Verlet - /// </summary> - public class EntityWithTypeProperty - { + /// <summary> + /// Author : Stephane Verlet + /// </summary> + public class EntityWithTypeProperty + { + public int Id { get; set; } - private int _id; - private System.Type _typeValue; - - public EntityWithTypeProperty() - { - _id = 0; - } - - public int Id - { - get { return _id; } - set { _id = value; } - } - - public System.Type TypeValue - { - get { return _typeValue; } - set { _typeValue = value; } - } - - } -} + public System.Type TypeValue { get; set; } + } +} \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Fixture.cs 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,91 +1,79 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Collections.Generic; +using System.IO; +using NHibernate.Criterion; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1969 { - using Criterion; - /// <summary> /// Author : Stephane Verlet /// </summary> [TestFixture] public class Fixture : BugTestCase { - protected override void OnSetUp() { using (ISession s = OpenSession()) - using (ITransaction tx = s.BeginTransaction()) { + using (ITransaction tx = s.BeginTransaction()) + { + var entity = new EntityWithTypeProperty {Id = 1, TypeValue = typeof (File)}; + s.Save(entity); - EntityWithTypeProperty entity = new EntityWithTypeProperty(); - entity.Id = 1; - entity.TypeValue = typeof(System.IO.File); //A random not mapped type - s.Save(entity); + entity = new EntityWithTypeProperty {Id = 2, TypeValue = typeof (DummyEntity)}; + s.Save(entity); - entity = new EntityWithTypeProperty(); - entity.Id = 2; - entity.TypeValue = typeof(DummyEntity); // A mapped entity - s.Save(entity); - - tx.Commit(); + tx.Commit(); + } } - } protected override void OnTearDown() { - using (ISession session = this.OpenSession()) - using (ITransaction tx = session.BeginTransaction()) + using (ISession session = OpenSession()) { - string hql = "from System.Object"; - session.Delete(hql); - tx.Commit(); + using (ITransaction tx = session.BeginTransaction()) + { + session.CreateQuery("delete from DummyEntity").ExecuteUpdate(); + session.CreateQuery("delete from EntityWithTypeProperty").ExecuteUpdate(); + tx.Commit(); + } } } - [Test,Ignore] + [Test, Ignore] public void TestMappedTypeCriteria() { using (ISession s = OpenSession()) { - ICriteria criteria = s.CreateCriteria(typeof(EntityWithTypeProperty)); - criteria.Add(Restrictions.Eq("TypeValue", typeof(DummyEntity))); + ICriteria criteria = s.CreateCriteria(typeof (EntityWithTypeProperty)); + criteria.Add(Restrictions.Eq("TypeValue", typeof (DummyEntity))); IList<EntityWithTypeProperty> results = criteria.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(2, results[0].Id); } } - [Test] public void TestMappedTypeHQL() { using (ISession s = OpenSession()) { - IQuery q = s.CreateQuery("select t from EntityWithTypeProperty as t where t.TypeValue = :type"); - q.SetParameter("type", typeof(DummyEntity)); + q.SetParameter("type", typeof (DummyEntity)); IList<EntityWithTypeProperty> results = q.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(2, results[0].Id); - } } - - - [Test] public void TestNonMappedTypeCriteria() { using (ISession s = OpenSession()) { - ICriteria criteria = s.CreateCriteria(typeof(EntityWithTypeProperty)); - criteria.Add(Restrictions.Eq("TypeValue", typeof(System.IO.File))); + ICriteria criteria = s.CreateCriteria(typeof (EntityWithTypeProperty)); + criteria.Add(Restrictions.Eq("TypeValue", typeof (File))); IList<EntityWithTypeProperty> results = criteria.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results[0].Id); @@ -97,15 +85,12 @@ { using (ISession s = OpenSession()) { - IQuery q = s.CreateQuery("select t from EntityWithTypeProperty as t where t.TypeValue = :type"); - q.SetParameter("type", typeof(System.IO.File)); + q.SetParameter("type", typeof (File)); IList<EntityWithTypeProperty> results = q.List<EntityWithTypeProperty>(); Assert.AreEqual(1, results.Count); Assert.AreEqual(1, results[0].Id); - } } - } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1969/Mappings.hbm.xml 2009-10-18 20:51:03 UTC (rev 4791) @@ -1,25 +1,21 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" default-lazy="false"> - <class - name="NHibernate.Test.NHSpecificTest.NH1969.EntityWithTypeProperty, NHibernate.Test" - table="EntityWithTypeProperty"> - <id name="Id" column="id"> - <generator class="assigned" /> - </id> +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1969" + assembly="NHibernate.Test" + default-lazy="false"> + + <class name="EntityWithTypeProperty"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> - <property name="TypeValue" column="typeValue" /> - </class> + <property name="TypeValue" column="typeValue" /> + </class> - <class - name="NHibernate.Test.NHSpecificTest.NH1969.DummyEntity, NHibernate.Test" - table="DummyEntity"> + <class name="DummyEntity"> + <id name="Id" column="id"> + <generator class="assigned" /> + </id> + </class> - <id name="Id" column="id"> - <generator class="assigned" /> - </id> - - - </class> - - </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: <fab...@us...> - 2009-10-18 20:37:58
|
Revision: 4790 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4790&view=rev Author: fabiomaulo Date: 2009-10-18 20:37:46 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4789 (subtask NH-1368) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml Removed Paths: ------------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 20:37:46 UTC (rev 4790) @@ -1,10 +1,11 @@ +using System.Collections; using System.Collections.Generic; +using Iesi.Collections.Generic; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1356 { - [TestFixture] - public class Fixture : BugTestCase + public abstract class Fixture : BugTestCase { [Test] public void CanLoadWithGenericCompositeElement() @@ -13,9 +14,7 @@ { using (ITransaction tx = session.BeginTransaction()) { - Person person = new Person(); - person.Name = "Bob"; - person.Addresses = new List<Address>(); + var person = new Person {Name = "Bob", Addresses = NewCollection()}; person.Addresses.Add(new Address("123 Main St.", "Anytown", "LA", "12345")); person.Addresses.Add(new Address("456 Main St.", "Anytown", "LA", "12345")); @@ -25,7 +24,7 @@ } using (ISession session = OpenSession()) { - Person person = session.CreateQuery("from Person").UniqueResult<Person>(); + var person = session.CreateQuery("from Person").UniqueResult<Person>(); Assert.IsNotNull(person); Assert.IsNotNull(person.Addresses); @@ -40,5 +39,49 @@ } } } + + protected abstract ICollection<Address> NewCollection(); } + + [TestFixture] + public class FixtureWithList : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsList.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithBag : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsBag.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithSet : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsSet.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new HashedSet<Address>(); + } + } } \ No newline at end of file Deleted: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> - <class name="Person" lazy="false"> - <id name="Id"> - <generator class="native" /> - </id> - <property name="Name" /> - - <list name="Addresses" table="Addresses" lazy="false"> - <key column="PersonId" /> - <index column="Position" /> - - <composite-element class="Address"> - <property name="Street" access="field.camelcase" /> - <property name="City" access="field.camelcase" /> - <property name="State" access="field.camelcase" /> - <property name="PostalCode" access="field.camelcase" /> - </composite-element> - </list> - </class> -</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <bag name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </bag> + </class> +</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <list name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + <index column="Position" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </list> + </class> +</hibernate-mapping> Copied: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (from rev 4789, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml) =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml 2009-10-18 20:37:46 UTC (rev 4790) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <set name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </set> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 20:37:46 UTC (rev 4790) @@ -4,8 +4,7 @@ { public class Person { - private IList<Address> addressBag; - private IList<Address> addresses; + private ICollection<Address> addresses; private int id; private string name; @@ -21,17 +20,11 @@ set { name = value; } } - public IList<Address> Addresses + public ICollection<Address> Addresses { get { return addresses; } set { addresses = value; } } - - public IList<Address> AddressBag - { - get { return addressBag; } - set { addressBag = value; } - } } public struct Address Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 20:30:38 UTC (rev 4789) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 20:37:46 UTC (rev 4790) @@ -1985,9 +1985,6 @@ <EmbeddedResource Include="NHSpecificTest\NH693\SpaceTableName.hbm.xml" /> </ItemGroup> <ItemGroup> - <EmbeddedResource Include="NHSpecificTest\NH1356\Mappings.hbm.xml" /> - </ItemGroup> - <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH1362\Mappings.hbm.xml" /> </ItemGroup> <ItemGroup> @@ -2046,6 +2043,9 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsBag.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsList.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsSet.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1785\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\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-10-18 20:30:50
|
Revision: 4789 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4789&view=rev Author: fabiomaulo Date: 2009-10-18 20:30:38 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Check for subtask NH-1368 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml Removed Paths: ------------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 19:18:02 UTC (rev 4788) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Fixture.cs 2009-10-18 20:30:38 UTC (rev 4789) @@ -1,10 +1,11 @@ +using System.Collections; using System.Collections.Generic; +using Iesi.Collections.Generic; using NUnit.Framework; namespace NHibernate.Test.NHSpecificTest.NH1356 { - [TestFixture] - public class Fixture : BugTestCase + public abstract class Fixture : BugTestCase { [Test] public void CanLoadWithGenericCompositeElement() @@ -13,9 +14,7 @@ { using (ITransaction tx = session.BeginTransaction()) { - Person person = new Person(); - person.Name = "Bob"; - person.Addresses = new List<Address>(); + var person = new Person {Name = "Bob", Addresses = NewCollection()}; person.Addresses.Add(new Address("123 Main St.", "Anytown", "LA", "12345")); person.Addresses.Add(new Address("456 Main St.", "Anytown", "LA", "12345")); @@ -25,7 +24,7 @@ } using (ISession session = OpenSession()) { - Person person = session.CreateQuery("from Person").UniqueResult<Person>(); + var person = session.CreateQuery("from Person").UniqueResult<Person>(); Assert.IsNotNull(person); Assert.IsNotNull(person.Addresses); @@ -40,5 +39,49 @@ } } } + + protected abstract ICollection<Address> NewCollection(); } + + [TestFixture] + public class FixtureWithList : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsList.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithBag : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsBag.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new List<Address>(); + } + } + + [TestFixture] + public class FixtureWithSet : Fixture + { + protected override IList Mappings + { + get { return new[] {"NHSpecificTest." + BugNumber + ".MappingsSet.hbm.xml"}; } + } + + protected override ICollection<Address> NewCollection() + { + return new HashedSet<Address>(); + } + } } \ No newline at end of file Deleted: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 19:18:02 UTC (rev 4788) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) @@ -1,21 +0,0 @@ -<?xml version="1.0" encoding="utf-8" ?> -<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> - <class name="Person" lazy="false"> - <id name="Id"> - <generator class="native" /> - </id> - <property name="Name" /> - - <list name="Addresses" table="Addresses" lazy="false"> - <key column="PersonId" /> - <index column="Position" /> - - <composite-element class="Address"> - <property name="Street" access="field.camelcase" /> - <property name="City" access="field.camelcase" /> - <property name="State" access="field.camelcase" /> - <property name="PostalCode" access="field.camelcase" /> - </composite-element> - </list> - </class> -</hibernate-mapping> Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (from rev 4772, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsBag.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <bag name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </bag> + </class> +</hibernate-mapping> Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (from rev 4772, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsList.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <list name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + <index column="Position" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </list> + </class> +</hibernate-mapping> Copied: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (from rev 4772, branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Mappings.hbm.xml) =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/MappingsSet.hbm.xml 2009-10-18 20:30:38 UTC (rev 4789) @@ -0,0 +1,20 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" namespace="NHibernate.Test.NHSpecificTest.NH1356"> + <class name="Person" lazy="false"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + + <set name="Addresses" table="Addresses" lazy="false" generic="true"> + <key column="PersonId" /> + + <composite-element class="Address"> + <property name="Street" access="field.camelcase" /> + <property name="City" access="field.camelcase" /> + <property name="State" access="field.camelcase" /> + <property name="PostalCode" access="field.camelcase" /> + </composite-element> + </set> + </class> +</hibernate-mapping> Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 19:18:02 UTC (rev 4788) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1356/Model.cs 2009-10-18 20:30:38 UTC (rev 4789) @@ -4,8 +4,7 @@ { public class Person { - private IList<Address> addressBag; - private IList<Address> addresses; + private ICollection<Address> addresses; private int id; private string name; @@ -21,17 +20,11 @@ set { name = value; } } - public IList<Address> Addresses + public ICollection<Address> Addresses { get { return addresses; } set { addresses = value; } } - - public IList<Address> AddressBag - { - get { return addressBag; } - set { addressBag = value; } - } } public struct Address Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 19:18:02 UTC (rev 4788) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 20:30:38 UTC (rev 4789) @@ -1952,7 +1952,7 @@ <EmbeddedResource Include="NHSpecificTest\NH693\SpaceTableName.hbm.xml" /> </ItemGroup> <ItemGroup> - <EmbeddedResource Include="NHSpecificTest\NH1356\Mappings.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsList.hbm.xml" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="NHSpecificTest\NH1362\Mappings.hbm.xml" /> @@ -2011,6 +2011,8 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsBag.hbm.xml" /> + <EmbeddedResource Include="NHSpecificTest\NH1356\MappingsSet.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1785\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\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-10-18 19:18:09
|
Revision: 4788 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4788&view=rev Author: fabiomaulo Date: 2009-10-18 19:18:02 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fixed NH-1858 with 'Not supported exception.' Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-10-18 19:16:19 UTC (rev 4787) +++ trunk/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-10-18 19:18:02 UTC (rev 4788) @@ -352,7 +352,7 @@ { return 6; } - return 0; + throw new NotSupportedException("The query should start with 'SELECT' or 'SELECT DISTINCT'"); } private bool NeedsLockHint(LockMode lockMode) Modified: trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2009-10-18 19:16:19 UTC (rev 4787) +++ trunk/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2009-10-18 19:18:02 UTC (rev 4788) @@ -1,3 +1,4 @@ +using System; using NHibernate.Dialect; using NHibernate.Mapping; using NHibernate.SqlCommand; @@ -184,5 +185,12 @@ System.Console.WriteLine(ifExistsDropConstraint); Assert.AreEqual(expected, ifExistsDropConstraint); } + + [Test] + public void GetLimitStringWithSqlComments() + { + var d = new MsSql2005Dialect(); + Assert.Throws<NotSupportedException>(()=> d.GetLimitString(new SqlString(" /* criteria query */ SELECT p from lcdtm"), 0, 2)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 19:16:31
|
Revision: 4787 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4787&view=rev Author: fabiomaulo Date: 2009-10-18 19:16:19 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fixed NH-1858 with 'Not supported exception.' Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs branches/2.1.x/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-10-18 18:34:12 UTC (rev 4786) +++ branches/2.1.x/nhibernate/src/NHibernate/Dialect/MsSql2000Dialect.cs 2009-10-18 19:16:19 UTC (rev 4787) @@ -352,7 +352,7 @@ { return 6; } - return 0; + throw new NotSupportedException("The query should start with 'SELECT' or 'SELECT DISTINCT'"); } private bool NeedsLockHint(LockMode lockMode) Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2009-10-18 18:34:12 UTC (rev 4786) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/DialectTest/MsSql2005DialectFixture.cs 2009-10-18 19:16:19 UTC (rev 4787) @@ -1,3 +1,4 @@ +using System; using NHibernate.Dialect; using NHibernate.Mapping; using NHibernate.SqlCommand; @@ -184,5 +185,12 @@ System.Console.WriteLine(ifExistsDropConstraint); Assert.AreEqual(expected, ifExistsDropConstraint); } + + [Test] + public void GetLimitStringWithSqlComments() + { + var d = new MsSql2005Dialect(); + Assert.Throws<NotSupportedException>(()=> d.GetLimitString(new SqlString(" /* criteria query */ SELECT p from lcdtm"), 0, 2)); + } } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 18:34:21
|
Revision: 4786 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4786&view=rev Author: fabiomaulo Date: 2009-10-18 18:34:12 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1525 Modified Paths: -------------- trunk/nhibernate/doc/reference/modules/query_sql.xml Modified: trunk/nhibernate/doc/reference/modules/query_sql.xml =================================================================== --- trunk/nhibernate/doc/reference/modules/query_sql.xml 2009-10-18 18:33:28 UTC (rev 4785) +++ trunk/nhibernate/doc/reference/modules/query_sql.xml 2009-10-18 18:34:12 UTC (rev 4786) @@ -330,7 +330,11 @@ The above query will return a list of <literal>CatDTO</literal> which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding properties or fields. </para> - </sect2> + <para> + IMPORTANT: The custom <literal>IResultTransformer</literal> should override <literal>Equals</literal> and <literal>GetHashCode</literal>, + otherwise the query translation won't be cached. This also will result in memory leak. + </para> + </sect2> <sect2> <title>Handling inheritance</title> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 18:33:38
|
Revision: 4785 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4785&view=rev Author: fabiomaulo Date: 2009-10-18 18:33:28 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1525 Modified Paths: -------------- branches/2.1.x/nhibernate/doc/reference/modules/query_sql.xml Modified: branches/2.1.x/nhibernate/doc/reference/modules/query_sql.xml =================================================================== --- branches/2.1.x/nhibernate/doc/reference/modules/query_sql.xml 2009-10-18 18:10:42 UTC (rev 4784) +++ branches/2.1.x/nhibernate/doc/reference/modules/query_sql.xml 2009-10-18 18:33:28 UTC (rev 4785) @@ -330,7 +330,11 @@ The above query will return a list of <literal>CatDTO</literal> which has been instantiated and injected the values of NAME and BIRTHNAME into its corresponding properties or fields. </para> - </sect2> + <para> + IMPORTANT: The custom <literal>IResultTransformer</literal> should override <literal>Equals</literal> and <literal>GetHashCode</literal>, + otherwise the query translation won't be cached. This also will result in memory leak. + </para> + </sect2> <sect2> <title>Handling inheritance</title> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 18:10:50
|
Revision: 4784 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4784&view=rev Author: fabiomaulo Date: 2009-10-18 18:10:42 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4783 (fix NH-1785) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 18:08:11 UTC (rev 4783) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 18:10:42 UTC (rev 4784) @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Iesi.Collections.Generic; using log4net; @@ -58,22 +57,21 @@ userAliases = ArrayHelper.ToStringArray(userAliasList); } - protected override void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + protected override void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) { - // NH different behavior (NH-1760) - WalkCompositeComponentIdTree(); - base.InitAll(whereString, orderByString, lockMode); + // NH different behavior (NH-1476, NH-1760, NH-1785) + base.WalkEntityTree(persister, alias, path, currentDepth); + WalkCompositeComponentIdTree(persister, alias, path); } - private void WalkCompositeComponentIdTree() + private void WalkCompositeComponentIdTree(IOuterJoinLoadable persister, string alias, string path) { - IType type = Persister.IdentifierType; - string propertyName = Persister.IdentifierPropertyName; + IType type = persister.IdentifierType; + string propertyName = persister.IdentifierPropertyName; if (type != null && type.IsComponentType && !(type is EmbeddedComponentType)) { - ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(Alias, Persister, Factory); - WalkComponentTree((IAbstractComponentType) type, 0, Alias, SubPath(string.Empty, propertyName), 0, - associationTypeSQLInfo); + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(alias, persister, Factory); + WalkComponentTree((IAbstractComponentType)type, 0, alias, SubPath(path, propertyName), 0, associationTypeSQLInfo); } } Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 18:08:11 UTC (rev 4783) +++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 18:10:42 UTC (rev 4784) @@ -237,7 +237,7 @@ /// For an entity class, add to a list of associations to be fetched /// by outerjoin /// </summary> - private void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) + protected virtual void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) { int n = persister.CountSubclassProperties(); for (int i = 0; i < n; i++) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs 2009-10-18 18:10:42 UTC (rev 4784) @@ -0,0 +1,59 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1785 +{ + public class Entity1 + { + public virtual Guid Id { get; set; } + public virtual ISet<Entity2> Entities2 { get; set; } + } + + public class Entity2Id + { + public virtual Entity1 Entity1 { get; set; } + public virtual Entity3 Entity3 { get; set; } + + public bool Equals(Entity2Id other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.Entity1, Entity1) && Equals(other.Entity3, Entity3); + } + + public override bool Equals(object obj) + { + return Equals(obj as Entity2Id); + } + + public override int GetHashCode() + { + unchecked + { + return ((Entity1 != null ? Entity1.GetHashCode() : 0) * 397) ^ (Entity3 != null ? Entity3.GetHashCode() : 0); + } + } + } + + public class Entity2 + { + public virtual Entity2Id Id { get; set; } + } + + public class Entity3 + { + public virtual Guid Id { get; set; } + public virtual Entity4 Entity4 { get; set; } + } + + public class Entity4 + { + public virtual Guid Id { get; set; } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs 2009-10-18 18:10:42 UTC (rev 4784) @@ -0,0 +1,43 @@ +using System; +using NHibernate.Criterion; +using NHibernate.SqlCommand; +using NUnit.Framework; +using System.Text.RegularExpressions; + +namespace NHibernate.Test.NHSpecificTest.NH1785 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Bug() + { + using (var session = OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof (Entity1)); + criteria.CreateAlias("Entities2", "ent2", JoinType.InnerJoin); + criteria.CreateAlias("ent2.Id.Entity3", "ent3", JoinType.InnerJoin); + criteria.CreateAlias("ent3.Entity4", "ent4", JoinType.InnerJoin); + criteria.Add(Restrictions.Eq("ent4.Id", Guid.NewGuid())); + Assert.DoesNotThrow(() => criteria.List<Entity1>()); + } + } + + [Test] + public void ShouldNotContainJoinWhereNotRequired() + { + using (var session = OpenSession()) + { + using (var ls = new SqlLogSpy()) + { + ICriteria criteria = session.CreateCriteria(typeof(Entity1)); + criteria.CreateAlias("Entities2", "ent2", JoinType.InnerJoin); + criteria.List<Entity1>(); + var sql = ls.GetWholeLog(); + var rx = new Regex(@"\bjoin\b"); + Assert.That(rx.Matches(sql).Count, Is.EqualTo(1)); + } + } + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml 2009-10-18 18:10:42 UTC (rev 4784) @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1785"> + + <class name="Entity1" table="Entity1"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + <set name="Entities2" lazy="true" inverse="true" table="Entity2"> + <key column="id"> + </key> + <one-to-many class="Entity2"/> + </set> + </class> + + <class name="Entity2" table="Entity2"> + <composite-id class="Entity2Id" name="Id"> + <key-many-to-one name="Entity1" class="Entity1" column="id1" /> + <key-many-to-one name="Entity3" class="Entity3" column="id3" /> + </composite-id> + </class> + + <class name="Entity3" table="Entity3"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + <many-to-one name="Entity4" class="Entity4" column="entity4_id" /> + </class> + + <class name="Entity4" table="Entity4"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 18:08:11 UTC (rev 4783) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 18:10:42 UTC (rev 4784) @@ -397,6 +397,8 @@ <Compile Include="NHSpecificTest\Futures\FutureQueryOverFixture.cs" /> <Compile Include="NHSpecificTest\NH1255\Domain.cs" /> <Compile Include="NHSpecificTest\NH1255\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1785\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1785\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1895\DomainClasses.cs" /> <Compile Include="NHSpecificTest\NH1895\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1922\Fixture.cs" /> @@ -2044,6 +2046,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1785\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1985\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-10-18 18:08:22
|
Revision: 4783 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4783&view=rev Author: fabiomaulo Date: 2009-10-18 18:08:11 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1785 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 16:13:35 UTC (rev 4782) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 18:08:11 UTC (rev 4783) @@ -1,4 +1,3 @@ -using System; using System.Collections.Generic; using Iesi.Collections.Generic; using log4net; @@ -58,22 +57,21 @@ userAliases = ArrayHelper.ToStringArray(userAliasList); } - protected override void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + protected override void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) { - // NH different behavior (NH-1760) - WalkCompositeComponentIdTree(); - base.InitAll(whereString, orderByString, lockMode); + // NH different behavior (NH-1476, NH-1760, NH-1785) + base.WalkEntityTree(persister, alias, path, currentDepth); + WalkCompositeComponentIdTree(persister, alias, path); } - private void WalkCompositeComponentIdTree() + private void WalkCompositeComponentIdTree(IOuterJoinLoadable persister, string alias, string path) { - IType type = Persister.IdentifierType; - string propertyName = Persister.IdentifierPropertyName; + IType type = persister.IdentifierType; + string propertyName = persister.IdentifierPropertyName; if (type != null && type.IsComponentType && !(type is EmbeddedComponentType)) { - ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(Alias, Persister, Factory); - WalkComponentTree((IAbstractComponentType) type, 0, Alias, SubPath(string.Empty, propertyName), 0, - associationTypeSQLInfo); + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(alias, persister, Factory); + WalkComponentTree((IAbstractComponentType)type, 0, alias, SubPath(path, propertyName), 0, associationTypeSQLInfo); } } Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 16:13:35 UTC (rev 4782) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 18:08:11 UTC (rev 4783) @@ -237,7 +237,7 @@ /// For an entity class, add to a list of associations to be fetched /// by outerjoin /// </summary> - private void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) + protected virtual void WalkEntityTree(IOuterJoinLoadable persister, string alias, string path, int currentDepth) { int n = persister.CountSubclassProperties(); for (int i = 0; i < n; i++) Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Domain.cs 2009-10-18 18:08:11 UTC (rev 4783) @@ -0,0 +1,59 @@ +using System; +using Iesi.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1785 +{ + public class Entity1 + { + public virtual Guid Id { get; set; } + public virtual ISet<Entity2> Entities2 { get; set; } + } + + public class Entity2Id + { + public virtual Entity1 Entity1 { get; set; } + public virtual Entity3 Entity3 { get; set; } + + public bool Equals(Entity2Id other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.Entity1, Entity1) && Equals(other.Entity3, Entity3); + } + + public override bool Equals(object obj) + { + return Equals(obj as Entity2Id); + } + + public override int GetHashCode() + { + unchecked + { + return ((Entity1 != null ? Entity1.GetHashCode() : 0) * 397) ^ (Entity3 != null ? Entity3.GetHashCode() : 0); + } + } + } + + public class Entity2 + { + public virtual Entity2Id Id { get; set; } + } + + public class Entity3 + { + public virtual Guid Id { get; set; } + public virtual Entity4 Entity4 { get; set; } + } + + public class Entity4 + { + public virtual Guid Id { get; set; } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Fixture.cs 2009-10-18 18:08:11 UTC (rev 4783) @@ -0,0 +1,43 @@ +using System; +using NHibernate.Criterion; +using NHibernate.SqlCommand; +using NUnit.Framework; +using System.Text.RegularExpressions; + +namespace NHibernate.Test.NHSpecificTest.NH1785 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Bug() + { + using (var session = OpenSession()) + { + ICriteria criteria = session.CreateCriteria(typeof (Entity1)); + criteria.CreateAlias("Entities2", "ent2", JoinType.InnerJoin); + criteria.CreateAlias("ent2.Id.Entity3", "ent3", JoinType.InnerJoin); + criteria.CreateAlias("ent3.Entity4", "ent4", JoinType.InnerJoin); + criteria.Add(Restrictions.Eq("ent4.Id", Guid.NewGuid())); + Assert.DoesNotThrow(() => criteria.List<Entity1>()); + } + } + + [Test] + public void ShouldNotContainJoinWhereNotRequired() + { + using (var session = OpenSession()) + { + using (var ls = new SqlLogSpy()) + { + ICriteria criteria = session.CreateCriteria(typeof(Entity1)); + criteria.CreateAlias("Entities2", "ent2", JoinType.InnerJoin); + criteria.List<Entity1>(); + var sql = ls.GetWholeLog(); + var rx = new Regex(@"\bjoin\b"); + Assert.That(rx.Matches(sql).Count, Is.EqualTo(1)); + } + } + } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1785/Mappings.hbm.xml 2009-10-18 18:08:11 UTC (rev 4783) @@ -0,0 +1,36 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1785"> + + <class name="Entity1" table="Entity1"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + <set name="Entities2" lazy="true" inverse="true" table="Entity2"> + <key column="id"> + </key> + <one-to-many class="Entity2"/> + </set> + </class> + + <class name="Entity2" table="Entity2"> + <composite-id class="Entity2Id" name="Id"> + <key-many-to-one name="Entity1" class="Entity1" column="id1" /> + <key-many-to-one name="Entity3" class="Entity3" column="id3" /> + </composite-id> + </class> + + <class name="Entity3" table="Entity3"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + <many-to-one name="Entity4" class="Entity4" column="entity4_id" /> + </class> + + <class name="Entity4" table="Entity4"> + <id name="Id" type="Guid" column="id"> + <generator class="guid" /> + </id> + </class> +</hibernate-mapping> \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 16:13:35 UTC (rev 4782) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-18 18:08:11 UTC (rev 4783) @@ -370,6 +370,8 @@ <Compile Include="NHSpecificTest\NH1025\Model.cs" /> <Compile Include="NHSpecificTest\NH1255\Domain.cs" /> <Compile Include="NHSpecificTest\NH1255\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1785\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1785\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1895\DomainClasses.cs" /> <Compile Include="NHSpecificTest\NH1895\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1905\Fixture.cs" /> @@ -2009,6 +2011,7 @@ <EmbeddedResource Include="DriverTest\MultiTypeEntity.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1785\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1025\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-10-18 16:13:41
|
Revision: 4782 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4782&view=rev Author: fabiomaulo Date: 2009-10-18 16:13:35 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4781 (fix NH-1980) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs Modified: trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:11:42 UTC (rev 4781) +++ trunk/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:13:35 UTC (rev 4782) @@ -108,7 +108,7 @@ { throw new HibernateByteCodeException(type.FullName + " does not implement " + typeof(ICollectionTypeFactory).FullName); } - if (collectionTypeFactory != null) + if (collectionTypeFactory != null && !collectionTypeFactoryClass.Equals(type)) { throw new InvalidOperationException("CollectionTypeFactory in use, can't change it."); } Modified: trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:11:42 UTC (rev 4781) +++ trunk/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:13:35 UTC (rev 4782) @@ -123,7 +123,7 @@ var bcp = new BytecodeProviderImpl(); ctf = bcp.CollectionTypeFactory; // initialize the instance // try to set it - Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(Type.DefaultCollectionTypeFactory))); + Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(CustomCollectionTypeFactory))); } private class CustomCollectionTypeFactory : Type.DefaultCollectionTypeFactory @@ -153,5 +153,15 @@ cfg.AddResource("NHibernate.Test.Bytecode.Lightweight.ProductLine.hbm.xml", GetType().Assembly); Assert.That(Environment.BytecodeProvider.CollectionTypeFactory, Is.TypeOf<CustomCollectionTypeFactory>()); } + + [Test] + [Explicit("The BytecodeProvider is static and can't be different in the same application.")] + public void ShouldNotThrownAnExceptionWithTheSameTypeOfCollectionTypeFactory() + { + ICollectionTypeFactory ctf; + var bcp = new BytecodeProviderImpl(); + ctf = bcp.CollectionTypeFactory; // initialize the instance + Assert.DoesNotThrow(() => bcp.SetCollectionTypeFactoryClass(typeof (Type.DefaultCollectionTypeFactory))); + } } } \ 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-10-18 16:11:50
|
Revision: 4781 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4781&view=rev Author: fabiomaulo Date: 2009-10-18 16:11:42 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1980 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 15:59:11 UTC (rev 4780) +++ branches/2.1.x/nhibernate/src/NHibernate/Bytecode/AbstractBytecodeProvider.cs 2009-10-18 16:11:42 UTC (rev 4781) @@ -108,7 +108,7 @@ { throw new HibernateByteCodeException(type.FullName + " does not implement " + typeof(ICollectionTypeFactory).FullName); } - if (collectionTypeFactory != null) + if (collectionTypeFactory != null && !collectionTypeFactoryClass.Equals(type)) { throw new InvalidOperationException("CollectionTypeFactory in use, can't change it."); } Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 15:59:11 UTC (rev 4780) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/Bytecode/Lightweight/BytecodeProviderFixture.cs 2009-10-18 16:11:42 UTC (rev 4781) @@ -123,7 +123,7 @@ var bcp = new BytecodeProviderImpl(); ctf = bcp.CollectionTypeFactory; // initialize the instance // try to set it - Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(Type.DefaultCollectionTypeFactory))); + Assert.Throws<InvalidOperationException>(() => bcp.SetCollectionTypeFactoryClass(typeof(CustomCollectionTypeFactory))); } private class CustomCollectionTypeFactory : Type.DefaultCollectionTypeFactory @@ -153,5 +153,15 @@ cfg.AddResource("NHibernate.Test.Bytecode.Lightweight.ProductLine.hbm.xml", GetType().Assembly); Assert.That(Environment.BytecodeProvider.CollectionTypeFactory, Is.TypeOf<CustomCollectionTypeFactory>()); } + + [Test] + [Explicit("The BytecodeProvider is static and can't be different in the same application.")] + public void ShouldNotThrownAnExceptionWithTheSameTypeOfCollectionTypeFactory() + { + ICollectionTypeFactory ctf; + var bcp = new BytecodeProviderImpl(); + ctf = bcp.CollectionTypeFactory; // initialize the instance + Assert.DoesNotThrow(() => bcp.SetCollectionTypeFactoryClass(typeof (Type.DefaultCollectionTypeFactory))); + } } } \ 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-10-18 15:59:19
|
Revision: 4780 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4780&view=rev Author: fabiomaulo Date: 2009-10-18 15:59:11 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4779 (refactoring fix NH-1936) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs trunk/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs trunk/nhibernate/src/NHibernate/Event/PostInsertEvent.cs trunk/nhibernate/src/NHibernate/Event/PostLoadEvent.cs trunk/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs trunk/nhibernate/src/NHibernate/Event/PreLoadEvent.cs trunk/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs trunk/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs trunk/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs trunk/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs Modified: trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -6,7 +6,7 @@ /// Defines a base class for Session generated events. /// </summary> [Serializable] - public class AbstractEvent + public class AbstractEvent : IDatabaseEventArgs { /// <summary> /// Constructs an event from the given event session. Added: trunk/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -0,0 +1,36 @@ +using System; +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + /// <summary> + /// Represents an operation we performed against the database. + /// </summary> + [Serializable] + public class AbstractPostDatabaseOperationEvent : AbstractEvent, IPostDatabaseOperationEventArgs + { + /// <summary> Constructs an event containing the pertinent information. </summary> + /// <param name="source">The session from which the event originated. </param> + /// <param name="entity">The entity to be invloved in the database operation. </param> + /// <param name="id">The entity id to be invloved in the database operation. </param> + /// <param name="persister">The entity's persister. </param> + protected AbstractPostDatabaseOperationEvent(IEventSource source, object entity, object id, IEntityPersister persister) + : base(source) + { + Entity = entity; + Id = id; + Persister = persister; + } + + /// <summary> The entity involved in the database operation. </summary> + public object Entity { get; private set; } + + /// <summary> The id to be used in the database operation. </summary> + public object Id { get; private set; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + public IEntityPersister Persister { get; private set; } + } +} Modified: trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -8,7 +8,7 @@ /// Represents an operation we are about to perform against the database. /// </summary> [Serializable] - public abstract class AbstractPreDatabaseOperationEvent : AbstractEvent + public abstract class AbstractPreDatabaseOperationEvent : AbstractEvent, IPreDatabaseOperationEventArgs { /// <summary> Constructs an event containing the pertinent information. </summary> /// <param name="source">The session from which the event originated. </param> Added: trunk/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -0,0 +1,11 @@ +namespace NHibernate.Event +{ + public interface IDatabaseEventArgs + { + /// <summary> + /// Returns the session event source for this event. + /// This is the underlying session from which this event was generated. + /// </summary> + IEventSource Session { get; } + } +} Added: trunk/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -0,0 +1,21 @@ +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + /// <summary> + /// Represents an operation we performed against the database. + /// </summary> + public interface IPostDatabaseOperationEventArgs : IDatabaseEventArgs + { + /// <summary> The entity involved in the database operation. </summary> + object Entity { get; } + + /// <summary> The id to be used in the database operation. </summary> + object Id { get; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + IEntityPersister Persister { get; } + } +} Added: trunk/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs (rev 0) +++ trunk/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -0,0 +1,18 @@ +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + public interface IPreDatabaseOperationEventArgs : IDatabaseEventArgs + { + /// <summary> The entity involved in the database operation. </summary> + object Entity { get; } + + /// <summary> The id to be used in the database operation. </summary> + object Id { get; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + IEntityPersister Persister { get; } + } +} Modified: trunk/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -7,40 +7,14 @@ /// Occurs after deleting an item from the datastore /// </summary> [Serializable] - public class PostDeleteEvent : AbstractEvent + public class PostDeleteEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly IEntityPersister persister; - private readonly object[] deletedState; - public PostDeleteEvent(object entity, object id, object[] deletedState, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.persister = persister; - this.deletedState = deletedState; + DeletedState = deletedState; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public IEntityPersister Persister - { - get { return persister; } - } - - public object[] DeletedState - { - get { return deletedState; } - } + public object[] DeletedState { get; private set; } } } Modified: trunk/nhibernate/src/NHibernate/Event/PostInsertEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PostInsertEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/PostInsertEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using NHibernate.Persister.Entity; namespace NHibernate.Event @@ -9,40 +7,14 @@ /// Occurs after inserting an item in the datastore /// </summary> [Serializable] - public class PostInsertEvent : AbstractEvent + public class PostInsertEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly IEntityPersister persister; - public PostInsertEvent(object entity, object id, object[] state, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity,id,persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.persister = persister; + State = state; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public IEntityPersister Persister - { - get { return persister; } - } + public object[] State { get; private set; } } } Modified: trunk/nhibernate/src/NHibernate/Event/PostLoadEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PostLoadEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/PostLoadEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -7,7 +7,7 @@ /// Occurs after an an entity instance is fully loaded. /// </summary> [Serializable] - public class PostLoadEvent : AbstractEvent + public class PostLoadEvent : AbstractEvent, IPostDatabaseOperationEventArgs { private object entity; private object id; Modified: trunk/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using NHibernate.Persister.Entity; namespace NHibernate.Event @@ -9,47 +7,17 @@ /// Occurs after the datastore is updated /// </summary> [Serializable] - public class PostUpdateEvent : AbstractEvent + public class PostUpdateEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly object[] oldState; - private readonly IEntityPersister persister; - public PostUpdateEvent(object entity, object id, object[] state, object[] oldState, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.oldState = oldState; - this.persister = persister; + State = state; + OldState = oldState; } - public object Entity - { - get { return entity; } - } + public object[] State { get; private set; } - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public object[] OldState - { - get { return oldState; } - } - - public IEntityPersister Persister - { - get { return persister; } - } + public object[] OldState { get; private set; } } } Modified: trunk/nhibernate/src/NHibernate/Event/PreLoadEvent.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/PreLoadEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/Event/PreLoadEvent.cs 2009-10-18 15:59:11 UTC (rev 4780) @@ -7,7 +7,7 @@ /// Called before injecting property values into a newly loaded entity instance. /// </summary> [Serializable] - public class PreLoadEvent : AbstractEvent + public class PreLoadEvent : AbstractEvent, IPreDatabaseOperationEventArgs { private object entity; private object[] state; Modified: trunk/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-10-18 15:53:31 UTC (rev 4779) +++ trunk/nhibernate/src/NHibernate/NHibernate.csproj 2009-10-18 15:59:11 UTC (rev 4780) @@ -525,8 +525,12 @@ <Compile Include="Driver\IfxDriver.cs" /> <Compile Include="Driver\OracleLiteDataClientDriver.cs" /> <Compile Include="EntityModeEqualityComparer.cs" /> + <Compile Include="Event\AbstractPostDatabaseOperationEvent.cs" /> <Compile Include="Event\AbstractPreDatabaseOperationEvent.cs" /> + <Compile Include="Event\IDatabaseEventArgs.cs" /> <Compile Include="Event\IDestructible.cs" /> + <Compile Include="Event\IPostDatabaseOperationEventArgs.cs" /> + <Compile Include="Event\IPreDatabaseOperationEventArgs.cs" /> <Compile Include="Exceptions\AdoExceptionContextInfo.cs" /> <Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" /> <Compile Include="Exceptions\SqlStateExtracter.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 15:53:39
|
Revision: 4779 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4779&view=rev Author: fabiomaulo Date: 2009-10-18 15:53:31 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Refactoring to Fix NH-1936 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/PostInsertEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/PostLoadEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/PreLoadEvent.cs branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj Added Paths: ----------- branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs branches/2.1.x/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs branches/2.1.x/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs branches/2.1.x/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -6,7 +6,7 @@ /// Defines a base class for Session generated events. /// </summary> [Serializable] - public class AbstractEvent + public class AbstractEvent : IDatabaseEventArgs { /// <summary> /// Constructs an event from the given event session. Added: branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPostDatabaseOperationEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -0,0 +1,36 @@ +using System; +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + /// <summary> + /// Represents an operation we performed against the database. + /// </summary> + [Serializable] + public class AbstractPostDatabaseOperationEvent : AbstractEvent, IPostDatabaseOperationEventArgs + { + /// <summary> Constructs an event containing the pertinent information. </summary> + /// <param name="source">The session from which the event originated. </param> + /// <param name="entity">The entity to be invloved in the database operation. </param> + /// <param name="id">The entity id to be invloved in the database operation. </param> + /// <param name="persister">The entity's persister. </param> + protected AbstractPostDatabaseOperationEvent(IEventSource source, object entity, object id, IEntityPersister persister) + : base(source) + { + Entity = entity; + Id = id; + Persister = persister; + } + + /// <summary> The entity involved in the database operation. </summary> + public object Entity { get; private set; } + + /// <summary> The id to be used in the database operation. </summary> + public object Id { get; private set; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + public IEntityPersister Persister { get; private set; } + } +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/AbstractPreDatabaseOperationEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -8,7 +8,7 @@ /// Represents an operation we are about to perform against the database. /// </summary> [Serializable] - public abstract class AbstractPreDatabaseOperationEvent : AbstractEvent + public abstract class AbstractPreDatabaseOperationEvent : AbstractEvent, IPreDatabaseOperationEventArgs { /// <summary> Constructs an event containing the pertinent information. </summary> /// <param name="source">The session from which the event originated. </param> Added: branches/2.1.x/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/IDatabaseEventArgs.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -0,0 +1,11 @@ +namespace NHibernate.Event +{ + public interface IDatabaseEventArgs + { + /// <summary> + /// Returns the session event source for this event. + /// This is the underlying session from which this event was generated. + /// </summary> + IEventSource Session { get; } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/IPostDatabaseOperationEventArgs.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -0,0 +1,21 @@ +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + /// <summary> + /// Represents an operation we performed against the database. + /// </summary> + public interface IPostDatabaseOperationEventArgs : IDatabaseEventArgs + { + /// <summary> The entity involved in the database operation. </summary> + object Entity { get; } + + /// <summary> The id to be used in the database operation. </summary> + object Id { get; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + IEntityPersister Persister { get; } + } +} \ No newline at end of file Added: branches/2.1.x/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs (rev 0) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/IPreDatabaseOperationEventArgs.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -0,0 +1,18 @@ +using NHibernate.Persister.Entity; + +namespace NHibernate.Event +{ + public interface IPreDatabaseOperationEventArgs : IDatabaseEventArgs + { + /// <summary> The entity involved in the database operation. </summary> + object Entity { get; } + + /// <summary> The id to be used in the database operation. </summary> + object Id { get; } + + /// <summary> + /// The persister for the <see cref="Entity"/>. + /// </summary> + IEntityPersister Persister { get; } + } +} \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/PostDeleteEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -7,40 +7,14 @@ /// Occurs after deleting an item from the datastore /// </summary> [Serializable] - public class PostDeleteEvent : AbstractEvent + public class PostDeleteEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly IEntityPersister persister; - private readonly object[] deletedState; - public PostDeleteEvent(object entity, object id, object[] deletedState, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.persister = persister; - this.deletedState = deletedState; + DeletedState = deletedState; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public IEntityPersister Persister - { - get { return persister; } - } - - public object[] DeletedState - { - get { return deletedState; } - } + public object[] DeletedState { get; private set; } } } Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/PostInsertEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/PostInsertEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/PostInsertEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using NHibernate.Persister.Entity; namespace NHibernate.Event @@ -9,40 +7,14 @@ /// Occurs after inserting an item in the datastore /// </summary> [Serializable] - public class PostInsertEvent : AbstractEvent + public class PostInsertEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly IEntityPersister persister; - public PostInsertEvent(object entity, object id, object[] state, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity,id,persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.persister = persister; + State = state; } - public object Entity - { - get { return entity; } - } - - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public IEntityPersister Persister - { - get { return persister; } - } + public object[] State { get; private set; } } } Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/PostLoadEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/PostLoadEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/PostLoadEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -7,7 +7,7 @@ /// Occurs after an an entity instance is fully loaded. /// </summary> [Serializable] - public class PostLoadEvent : AbstractEvent + public class PostLoadEvent : AbstractEvent, IPostDatabaseOperationEventArgs { private object entity; private object id; Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/PostUpdateEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Text; using NHibernate.Persister.Entity; namespace NHibernate.Event @@ -9,47 +7,17 @@ /// Occurs after the datastore is updated /// </summary> [Serializable] - public class PostUpdateEvent : AbstractEvent + public class PostUpdateEvent : AbstractPostDatabaseOperationEvent { - private readonly object entity; - private readonly object id; - private readonly object[] state; - private readonly object[] oldState; - private readonly IEntityPersister persister; - public PostUpdateEvent(object entity, object id, object[] state, object[] oldState, IEntityPersister persister, IEventSource source) - : base(source) + : base(source, entity, id, persister) { - this.entity = entity; - this.id = id; - this.state = state; - this.oldState = oldState; - this.persister = persister; + State = state; + OldState = oldState; } - public object Entity - { - get { return entity; } - } + public object[] State { get; private set; } - public object Id - { - get { return id; } - } - - public object[] State - { - get { return state; } - } - - public object[] OldState - { - get { return oldState; } - } - - public IEntityPersister Persister - { - get { return persister; } - } + public object[] OldState { get; private set; } } } Modified: branches/2.1.x/nhibernate/src/NHibernate/Event/PreLoadEvent.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Event/PreLoadEvent.cs 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/Event/PreLoadEvent.cs 2009-10-18 15:53:31 UTC (rev 4779) @@ -7,7 +7,7 @@ /// Called before injecting property values into a newly loaded entity instance. /// </summary> [Serializable] - public class PreLoadEvent : AbstractEvent + public class PreLoadEvent : AbstractEvent, IPreDatabaseOperationEventArgs { private object entity; private object[] state; Modified: branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-10-18 14:50:49 UTC (rev 4778) +++ branches/2.1.x/nhibernate/src/NHibernate/NHibernate.csproj 2009-10-18 15:53:31 UTC (rev 4779) @@ -480,8 +480,12 @@ <Compile Include="Driver\IfxDriver.cs" /> <Compile Include="Driver\OracleLiteDataClientDriver.cs" /> <Compile Include="EntityModeEqualityComparer.cs" /> + <Compile Include="Event\AbstractPostDatabaseOperationEvent.cs" /> <Compile Include="Event\AbstractPreDatabaseOperationEvent.cs" /> <Compile Include="Event\IDestructible.cs" /> + <Compile Include="Event\IDatabaseEventArgs.cs" /> + <Compile Include="Event\IPostDatabaseOperationEventArgs.cs" /> + <Compile Include="Event\IPreDatabaseOperationEventArgs.cs" /> <Compile Include="Exceptions\AdoExceptionContextInfo.cs" /> <Compile Include="Exceptions\ReflectionBasedSqlStateExtracter.cs" /> <Compile Include="Exceptions\SqlStateExtracter.cs" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 14:50:58
|
Revision: 4778 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4778&view=rev Author: fabiomaulo Date: 2009-10-18 14:50:49 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4777 (fix NH-1912) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs Modified: trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-10-18 14:48:19 UTC (rev 4777) +++ trunk/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-10-18 14:50:49 UTC (rev 4778) @@ -1,3 +1,4 @@ +using System.Data; using NHibernate.SqlCommand; namespace NHibernate.Dialect @@ -4,6 +5,12 @@ { public class MySQL5Dialect : MySQLDialect { + public MySQL5Dialect() + { + RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)"); + RegisterColumnType(DbType.Decimal, 19, "DECIMAL($p, $s)"); + } + //Reference 5.x //Numeric: //http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html @@ -58,14 +65,14 @@ } } - public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) - { - return insertString.Append(";" + IdentitySelectString); + public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) + { + return insertString.Append(";" + IdentitySelectString); } public override bool SupportsInsertSelectIdentity { get { return true; } - } + } } } \ 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-10-18 14:48:36
|
Revision: 4777 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4777&view=rev Author: fabiomaulo Date: 2009-10-18 14:48:19 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1912 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-10-18 14:37:25 UTC (rev 4776) +++ branches/2.1.x/nhibernate/src/NHibernate/Dialect/MySQL5Dialect.cs 2009-10-18 14:48:19 UTC (rev 4777) @@ -1,3 +1,4 @@ +using System.Data; using NHibernate.SqlCommand; namespace NHibernate.Dialect @@ -4,6 +5,12 @@ { public class MySQL5Dialect : MySQLDialect { + public MySQL5Dialect() + { + RegisterColumnType(DbType.Decimal, "DECIMAL(19,5)"); + RegisterColumnType(DbType.Decimal, 19, "DECIMAL($p, $s)"); + } + //Reference 5.x //Numeric: //http://dev.mysql.com/doc/refman/5.0/en/numeric-type-overview.html @@ -58,12 +65,12 @@ } } - public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) - { - return insertString.Append(";" + IdentitySelectString); - } - - public override bool SupportsInsertSelectIdentity + public override SqlString AppendIdentitySelectToInsert (NHibernate.SqlCommand.SqlString insertString) + { + return insertString.Append(";" + IdentitySelectString); + } + + public override bool SupportsInsertSelectIdentity { get { return true; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 14:37:31
|
Revision: 4776 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4776&view=rev Author: fabiomaulo Date: 2009-10-18 14:37:25 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Forgotten meta regeneration fixing NH-1255 (r4766) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-10-18 14:36:34 UTC (rev 4775) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-10-18 14:37:25 UTC (rev 4776) @@ -1967,6 +1967,15 @@ /// <remarks/> [System.Xml.Serialization.XmlIgnoreAttribute()] public bool lazySpecified; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("not-found")] + [System.ComponentModel.DefaultValueAttribute(HbmNotFoundMode.Exception)] + public HbmNotFoundMode notfound; + + public HbmKeyManyToOne() { + this.notfound = HbmNotFoundMode.Exception; + } } /// <remarks/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 14:36:42
|
Revision: 4775 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4775&view=rev Author: fabiomaulo Date: 2009-10-18 14:36:34 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Forgotten meta regeneration fixing NH-1255 (r4766) Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-10-18 13:39:50 UTC (rev 4774) +++ branches/2.1.x/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-10-18 14:36:34 UTC (rev 4775) @@ -1967,6 +1967,15 @@ /// <remarks/> [System.Xml.Serialization.XmlIgnoreAttribute()] public bool lazySpecified; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("not-found")] + [System.ComponentModel.DefaultValueAttribute(HbmNotFoundMode.Exception)] + public HbmNotFoundMode notfound; + + public HbmKeyManyToOne() { + this.notfound = HbmNotFoundMode.Exception; + } } /// <remarks/> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-18 13:40:02
|
Revision: 4774 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4774&view=rev Author: fabiomaulo Date: 2009-10-18 13:39:50 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merge r4773 (fix NH-1760) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/JoinHelper.cs trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs Modified: trunk/nhibernate/src/NHibernate/Engine/JoinHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/JoinHelper.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Engine/JoinHelper.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -1,4 +1,3 @@ -using System; using NHibernate.Persister.Entity; using NHibernate.Type; using NHibernate.Util; @@ -11,118 +10,150 @@ { } - /// <summary> - /// Get the aliased columns of the owning entity which are to - /// be used in the join - /// </summary> - public static string[] GetAliasedLHSColumnNames( - IAssociationType type, - string alias, - int property, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public static ILhsAssociationTypeSqlInfo GetLhsSqlInfo(string alias, int property, + IOuterJoinLoadable lhsPersister, IMapping mapping) { - return GetAliasedLHSColumnNames(type, alias, property, 0, lhsPersister, mapping); + return new PropertiesLhsAssociationTypeSqlInfo(alias, property, lhsPersister, mapping); } + public static ILhsAssociationTypeSqlInfo GetIdLhsSqlInfo(string alias, IOuterJoinLoadable lhsPersister, IMapping mapping) + { + return new IdPropertiesLhsAssociationTypeSqlInfo(alias, lhsPersister, mapping); + } + /// <summary> - /// Get the columns of the owning entity which are to + /// Get the columns of the associated table which are to /// be used in the join /// </summary> - public static string[] GetLHSColumnNames( - IAssociationType type, - int property, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public static string[] GetRHSColumnNames(IAssociationType type, ISessionFactoryImplementor factory) { - return GetLHSColumnNames(type, property, 0, lhsPersister, mapping); + string uniqueKeyPropertyName = type.RHSUniqueKeyPropertyName; + IJoinable joinable = type.GetAssociatedJoinable(factory); + if (uniqueKeyPropertyName == null) + { + return joinable.KeyColumnNames; + } + else + { + return ((IOuterJoinLoadable)joinable).GetPropertyColumnNames(uniqueKeyPropertyName); + } } + } + public interface ILhsAssociationTypeSqlInfo + { /// <summary> /// Get the aliased columns of the owning entity which are to /// be used in the join /// </summary> - public static string[] GetAliasedLHSColumnNames( - IAssociationType type, - string alias, - int property, - int begin, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + string[] GetAliasedColumnNames(IAssociationType type, int begin); + + /// <summary> + /// Get the columns of the owning entity which are to + /// be used in the join + /// </summary> + string[] GetColumnNames(IAssociationType type, int begin); + + string GetTableName(IAssociationType type); + } + + public abstract class AbstractLhsAssociationTypeSqlInfo : ILhsAssociationTypeSqlInfo + { + protected AbstractLhsAssociationTypeSqlInfo(string @alias, IOuterJoinLoadable persister, IMapping mapping) { + Alias = alias; + Persister = persister; + Mapping = mapping; + } + + public string Alias { get; private set; } + + public IOuterJoinLoadable Persister { get; private set; } + + public IMapping Mapping { get; private set; } + + #region Implementation of ILhsAssociationTypeSqlInfo + + + public string[] GetAliasedColumnNames(IAssociationType type, int begin) + { if (type.UseLHSPrimaryKey) { - return StringHelper.Qualify(alias, lhsPersister.IdentifierColumnNames); + return StringHelper.Qualify(Alias, Persister.IdentifierColumnNames); } else { string propertyName = type.LHSPropertyName; if (propertyName == null) { - return ArrayHelper.Slice( - lhsPersister.ToColumns(alias, property), - begin, - type.GetColumnSpan(mapping) - ); + return ArrayHelper.Slice(GetAliasedColumns(), begin, type.GetColumnSpan(Mapping)); } else { - return ((IPropertyMapping) lhsPersister).ToColumns(alias, propertyName); //bad cast + return ((IPropertyMapping)Persister).ToColumns(Alias, propertyName); //bad cast } } } - /// <summary> - /// Get the columns of the owning entity which are to - /// be used in the join - /// </summary> - public static string[] GetLHSColumnNames( - IAssociationType type, - int property, - int begin, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public string[] GetColumnNames(IAssociationType type, int begin) { if (type.UseLHSPrimaryKey) { - //return lhsPersister.getSubclassPropertyColumnNames(property); - return lhsPersister.IdentifierColumnNames; + return Persister.IdentifierColumnNames; } else { string propertyName = type.LHSPropertyName; if (propertyName == null) { - //slice, to get the columns for this component - //property - return ArrayHelper.Slice( - lhsPersister.GetSubclassPropertyColumnNames(property), - begin, - type.GetColumnSpan(mapping) - ); + //slice, to get the columns for this component property + return ArrayHelper.Slice(GetColumns(), begin, type.GetColumnSpan(Mapping)); } else { //property-refs for associations defined on a //component are not supported, so no need to slice - return lhsPersister.GetPropertyColumnNames(propertyName); + return Persister.GetPropertyColumnNames(propertyName); } } } - public static string GetLHSTableName( - IAssociationType type, - int property, - IOuterJoinLoadable lhsPersister - ) + protected abstract string[] GetAliasedColumns(); + protected abstract string[] GetColumns(); + + public abstract string GetTableName(IAssociationType type); + + #endregion + } + + public class PropertiesLhsAssociationTypeSqlInfo : AbstractLhsAssociationTypeSqlInfo + { + private readonly int propertyIdx; + + public PropertiesLhsAssociationTypeSqlInfo(string alias, + int propertyIdx, IOuterJoinLoadable persister, IMapping mapping) + : base(alias, persister, mapping) { + this.propertyIdx = propertyIdx; + } + + #region Overrides of AbstractLhsAssociationTypeSqlInfo + + protected override string[] GetAliasedColumns() + { + return Persister.ToColumns(Alias, propertyIdx); + } + + protected override string[] GetColumns() + { + return Persister.GetSubclassPropertyColumnNames(propertyIdx); + } + + public override string GetTableName(IAssociationType type) + { if (type.UseLHSPrimaryKey) { - return lhsPersister.TableName; + return Persister.TableName; } else { @@ -132,12 +163,12 @@ //if there is no property-ref, assume the join //is to the subclass table (ie. the table of the //subclass that the association belongs to) - return lhsPersister.GetSubclassPropertyTableName(property); + return Persister.GetSubclassPropertyTableName(propertyIdx); } else { //handle a property-ref - string propertyRefTable = lhsPersister.GetPropertyTableName(propertyName); + string propertyRefTable = Persister.GetPropertyTableName(propertyName); if (propertyRefTable == null) { //it is possible that the tree-walking in OuterJoinLoader can get to @@ -147,29 +178,38 @@ //assumes that the property-ref refers to a property of the subclass //table that the association belongs to (a reasonable guess) //TODO: fix this, add: IOuterJoinLoadable.getSubclassPropertyTableName(string propertyName) - propertyRefTable = lhsPersister.GetSubclassPropertyTableName(property); + propertyRefTable = Persister.GetSubclassPropertyTableName(propertyIdx); } return propertyRefTable; } } } - /// <summary> - /// Get the columns of the associated table which are to - /// be used in the join - /// </summary> - public static string[] GetRHSColumnNames(IAssociationType type, ISessionFactoryImplementor factory) + #endregion + } + + public class IdPropertiesLhsAssociationTypeSqlInfo : AbstractLhsAssociationTypeSqlInfo + { + public IdPropertiesLhsAssociationTypeSqlInfo(string alias, IOuterJoinLoadable persister, IMapping mapping) : base(alias, persister, mapping) {} + + #region Overrides of AbstractLhsAssociationTypeSqlInfo + + protected override string[] GetAliasedColumns() { - string uniqueKeyPropertyName = type.RHSUniqueKeyPropertyName; - IJoinable joinable = type.GetAssociatedJoinable(factory); - if (uniqueKeyPropertyName == null) - { - return joinable.KeyColumnNames; - } - else - { - return ((IOuterJoinLoadable) joinable).GetPropertyColumnNames(uniqueKeyPropertyName); - } + return Persister.ToIdentifierColumns(Alias); } + + protected override string[] GetColumns() + { + return Persister.IdentifierColumnNames; + } + + public override string GetTableName(IAssociationType type) + { + return Persister.TableName; + } + + #endregion } + } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -28,7 +28,7 @@ alias = rootSqlAlias; } - protected void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + protected virtual void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) { WalkEntityTree(persister, Alias); IList<OuterJoinableAssociation> allAssociations = new List<OuterJoinableAssociation>(associations); @@ -99,7 +99,7 @@ public abstract string Comment { get; } - protected ILoadable Persister + protected IOuterJoinLoadable Persister { get { return persister; } } Modified: trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Iesi.Collections.Generic; using log4net; @@ -57,6 +58,25 @@ userAliases = ArrayHelper.ToStringArray(userAliasList); } + protected override void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + { + // NH different behavior (NH-1760) + WalkCompositeComponentIdTree(); + base.InitAll(whereString, orderByString, lockMode); + } + + private void WalkCompositeComponentIdTree() + { + IType type = Persister.IdentifierType; + string propertyName = Persister.IdentifierPropertyName; + if (type != null && type.IsComponentType && !(type is EmbeddedComponentType)) + { + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(Alias, Persister, Factory); + WalkComponentTree((IAbstractComponentType) type, 0, Alias, SubPath(string.Empty, propertyName), 0, + associationTypeSQLInfo); + } + } + public IType[] ResultTypes { get { return resultTypes; } Modified: trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Iesi.Collections.Generic; using NHibernate.Collection; using NHibernate.Engine; @@ -218,20 +217,18 @@ } } - private void WalkEntityAssociationTree(IAssociationType associationType, IOuterJoinLoadable persister, int propertyNumber, - string alias, string path, bool nullable, int currentDepth) + private void WalkEntityAssociationTree(IAssociationType associationType, IOuterJoinLoadable persister, + int propertyNumber, string alias, string path, bool nullable, int currentDepth, + ILhsAssociationTypeSqlInfo associationTypeSQLInfo) { - string[] aliasedLhsColumns = - JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, persister, Factory); + string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, 0); + string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, 0); + string lhsTable = associationTypeSQLInfo.GetTableName(associationType); - string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, persister, Factory); - string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister); - string subpath = SubPath(path, persister.GetSubclassPropertyName(propertyNumber)); - JoinType joinType = - GetJoinType(associationType, persister.GetFetchMode(propertyNumber), subpath, lhsTable, lhsColumns, nullable, - currentDepth, persister.GetCascadeStyle(propertyNumber)); + JoinType joinType = GetJoinType(associationType, persister.GetFetchMode(propertyNumber), subpath, lhsTable, + lhsColumns, nullable, currentDepth, persister.GetCascadeStyle(propertyNumber)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } @@ -246,15 +243,16 @@ for (int i = 0; i < n; i++) { IType type = persister.GetSubclassPropertyType(i); + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetLhsSqlInfo(alias, i, persister, Factory); if (type.IsAssociationType) { - WalkEntityAssociationTree((IAssociationType)type, persister, i, alias, path, - persister.IsSubclassPropertyNullable(i), currentDepth); + WalkEntityAssociationTree((IAssociationType) type, persister, i, alias, path, + persister.IsSubclassPropertyNullable(i), currentDepth, associationTypeSQLInfo); } else if (type.IsComponentType) { - WalkComponentTree((IAbstractComponentType)type, i, 0, persister, alias, - SubPath(path, persister.GetSubclassPropertyName(i)), currentDepth); + WalkComponentTree((IAbstractComponentType) type, 0, alias, SubPath(path, persister.GetSubclassPropertyName(i)), + currentDepth, associationTypeSQLInfo); } } } @@ -262,8 +260,8 @@ /// <summary> /// For a component, add to a list of associations to be fetched by outerjoin /// </summary> - private void WalkComponentTree(IAbstractComponentType componentType, int propertyNumber, int begin, - IOuterJoinLoadable persister, string alias, string path, int currentDepth) + protected void WalkComponentTree(IAbstractComponentType componentType, int begin, string alias, string path, + int currentDepth, ILhsAssociationTypeSqlInfo associationTypeSQLInfo) { IType[] types = componentType.Subtypes; string[] propertyNames = componentType.PropertyNames; @@ -271,19 +269,18 @@ { if (types[i].IsAssociationType) { - IAssociationType associationType = (IAssociationType)types[i]; - string[] aliasedLhsColumns = - JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, begin, persister, Factory); + var associationType = (IAssociationType) types[i]; - string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, begin, persister, Factory); - string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister); + string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, begin); + string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, begin); + string lhsTable = associationTypeSQLInfo.GetTableName(associationType); string subpath = SubPath(path, propertyNames[i]); bool[] propertyNullability = componentType.PropertyNullability; - JoinType joinType = - GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, - propertyNullability == null || propertyNullability[i], currentDepth, componentType.GetCascadeStyle(i)); + JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, + propertyNullability == null || propertyNullability[i], currentDepth, + componentType.GetCascadeStyle(i)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } @@ -291,7 +288,7 @@ { string subpath = SubPath(path, propertyNames[i]); - WalkComponentTree((IAbstractComponentType)types[i], propertyNumber, begin, persister, alias, subpath, currentDepth); + WalkComponentTree((IAbstractComponentType) types[i], begin, alias, subpath, currentDepth, associationTypeSQLInfo); } begin += types[i].GetColumnSpan(Factory); } @@ -339,12 +336,9 @@ /// <summary> /// Extend the path by the given property name /// </summary> - private static string SubPath(string path, string property) + protected static string SubPath(string path, string property) { - if (path == null || path.Length == 0) - return property; - else - return StringHelper.Qualify(path, property); + return string.IsNullOrEmpty(path) ? property : StringHelper.Qualify(path, property); } /// <summary> Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -1852,6 +1852,18 @@ return result; } + public string[] ToIdentifierColumns(string name) + { + string alias = GenerateTableAlias(name, 0); + string[] cols = IdentifierColumnNames; + var result = new string[cols.Length]; + for (int j = 0; j < cols.Length; j++) + { + result[j] = StringHelper.Qualify(alias, cols[j]); + } + return result; + } + private int GetSubclassPropertyIndex(string propertyName) { return Array.IndexOf(subclassPropertyNameClosure, propertyName); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -108,5 +108,10 @@ /// Get the table name for the given property path /// </summary> string GetPropertyTableName(string propertyName); + + /// <summary> + /// Return the alised identifier column names + /// </summary> + string[] ToIdentifierColumns(string alias); } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -4,22 +4,22 @@ { public class Customer { - public Int32 Id { get; set; } - public String Name { get; set; } + public virtual Int32 Id { get; set; } + public virtual String Name { get; set; } } public class TestClass { - public TestClassId Id { get; set; } - public String Value { get; set; } + public virtual TestClassId Id { get; set; } + public virtual String Value { get; set; } } public class TestClassId { - public Customer Customer { get; set; } - public Int32 SomeInt { get; set; } + public virtual Customer Customer { get; set; } + public virtual Int32 SomeInt { get; set; } - public bool Equals(TestClassId other) + public virtual bool Equals(TestClassId other) { if (ReferenceEquals(null, other)) { Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml 2009-10-18 13:39:50 UTC (rev 4774) @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" - namespace="NHibernate.Test.NHSpecificTest.NH1760" - default-lazy="false"> + namespace="NHibernate.Test.NHSpecificTest.NH1760"> <class name="Customer"> <id name="Id"> Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs 2009-10-18 13:19:08 UTC (rev 4773) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs 2009-10-18 13:39:50 UTC (rev 4774) @@ -14,7 +14,7 @@ { var customer = new Customer {Name = "Alkampfer"}; session.Save(customer); - var testClass = new TestClass {Id = new TestClassId{Customer = customer, SomeInt = 42}, Value = "TESTVALUE"}; + var testClass = new TestClass { Id = new TestClassId { Customer = customer, SomeInt = 42 }, Value = "TESTVALUE" }; session.Save(testClass); tx.Commit(); } @@ -25,13 +25,13 @@ using (ISession session = OpenSession()) using (var tx = session.BeginTransaction()) { - session.CreateQuery("from TestClass").ExecuteUpdate(); - session.CreateQuery("from Customer").ExecuteUpdate(); + session.CreateQuery("delete from TestClass").ExecuteUpdate(); + session.CreateQuery("delete from Customer").ExecuteUpdate(); tx.Commit(); } } - [Test, Ignore("Not fixed yet.")] + [Test] public void CanUseCriteria() { FillDb(); @@ -40,7 +40,7 @@ using (ISession session = OpenSession()) { IList<TestClass> retvalue = - session.CreateQuery("Select tc from TestClass tc where tc.Id.Customer.Name = :name").SetString("name", "Alkampfer") + session.CreateQuery("Select tc from TestClass tc join tc.Id.Customer cu where cu.Name = :name").SetString("name", "Alkampfer") .List<TestClass>(); hqlCount = retvalue.Count; } @@ -53,10 +53,31 @@ IList<TestClass> retvalue = c.List<TestClass>(); criteriaCount = retvalue.Count; } - Assert.That(hqlCount == criteriaCount); - Assert.That(hqlCount, Is.EqualTo(1)); + Assert.That(criteriaCount, Is.EqualTo(1)); + Assert.That(criteriaCount, Is.EqualTo(hqlCount)); Cleanup(); } + + [Test] + public void TheJoinShouldBeOptional() + { + FillDb(); + int criteriaCount; + + using (ISession session = OpenSession()) + { + using (var ls = new SqlLogSpy()) + { + ICriteria c = session.CreateCriteria(typeof(TestClass)); + IList<TestClass> retvalue = c.List<TestClass>(); + Assert.That(ls.GetWholeLog(), Text.DoesNotContain("join")); + criteriaCount = retvalue.Count; + } + } + Assert.That(criteriaCount, Is.EqualTo(1)); + + Cleanup(); + } } } \ 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-10-18 13:19:19
|
Revision: 4773 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4773&view=rev Author: fabiomaulo Date: 2009-10-18 13:19:08 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Fix NH-1760 & NH-1476 Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Engine/JoinHelper.cs branches/2.1.x/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Engine/JoinHelper.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Engine/JoinHelper.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Engine/JoinHelper.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -1,4 +1,3 @@ -using System; using NHibernate.Persister.Entity; using NHibernate.Type; using NHibernate.Util; @@ -11,118 +10,150 @@ { } - /// <summary> - /// Get the aliased columns of the owning entity which are to - /// be used in the join - /// </summary> - public static string[] GetAliasedLHSColumnNames( - IAssociationType type, - string alias, - int property, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public static ILhsAssociationTypeSqlInfo GetLhsSqlInfo(string alias, int property, + IOuterJoinLoadable lhsPersister, IMapping mapping) { - return GetAliasedLHSColumnNames(type, alias, property, 0, lhsPersister, mapping); + return new PropertiesLhsAssociationTypeSqlInfo(alias, property, lhsPersister, mapping); } + public static ILhsAssociationTypeSqlInfo GetIdLhsSqlInfo(string alias, IOuterJoinLoadable lhsPersister, IMapping mapping) + { + return new IdPropertiesLhsAssociationTypeSqlInfo(alias, lhsPersister, mapping); + } + /// <summary> - /// Get the columns of the owning entity which are to + /// Get the columns of the associated table which are to /// be used in the join /// </summary> - public static string[] GetLHSColumnNames( - IAssociationType type, - int property, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public static string[] GetRHSColumnNames(IAssociationType type, ISessionFactoryImplementor factory) { - return GetLHSColumnNames(type, property, 0, lhsPersister, mapping); + string uniqueKeyPropertyName = type.RHSUniqueKeyPropertyName; + IJoinable joinable = type.GetAssociatedJoinable(factory); + if (uniqueKeyPropertyName == null) + { + return joinable.KeyColumnNames; + } + else + { + return ((IOuterJoinLoadable)joinable).GetPropertyColumnNames(uniqueKeyPropertyName); + } } + } + public interface ILhsAssociationTypeSqlInfo + { /// <summary> /// Get the aliased columns of the owning entity which are to /// be used in the join /// </summary> - public static string[] GetAliasedLHSColumnNames( - IAssociationType type, - string alias, - int property, - int begin, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + string[] GetAliasedColumnNames(IAssociationType type, int begin); + + /// <summary> + /// Get the columns of the owning entity which are to + /// be used in the join + /// </summary> + string[] GetColumnNames(IAssociationType type, int begin); + + string GetTableName(IAssociationType type); + } + + public abstract class AbstractLhsAssociationTypeSqlInfo : ILhsAssociationTypeSqlInfo + { + protected AbstractLhsAssociationTypeSqlInfo(string @alias, IOuterJoinLoadable persister, IMapping mapping) { + Alias = alias; + Persister = persister; + Mapping = mapping; + } + + public string Alias { get; private set; } + + public IOuterJoinLoadable Persister { get; private set; } + + public IMapping Mapping { get; private set; } + + #region Implementation of ILhsAssociationTypeSqlInfo + + + public string[] GetAliasedColumnNames(IAssociationType type, int begin) + { if (type.UseLHSPrimaryKey) { - return StringHelper.Qualify(alias, lhsPersister.IdentifierColumnNames); + return StringHelper.Qualify(Alias, Persister.IdentifierColumnNames); } else { string propertyName = type.LHSPropertyName; if (propertyName == null) { - return ArrayHelper.Slice( - lhsPersister.ToColumns(alias, property), - begin, - type.GetColumnSpan(mapping) - ); + return ArrayHelper.Slice(GetAliasedColumns(), begin, type.GetColumnSpan(Mapping)); } else { - return ((IPropertyMapping) lhsPersister).ToColumns(alias, propertyName); //bad cast + return ((IPropertyMapping)Persister).ToColumns(Alias, propertyName); //bad cast } } } - /// <summary> - /// Get the columns of the owning entity which are to - /// be used in the join - /// </summary> - public static string[] GetLHSColumnNames( - IAssociationType type, - int property, - int begin, - IOuterJoinLoadable lhsPersister, - IMapping mapping - ) + public string[] GetColumnNames(IAssociationType type, int begin) { if (type.UseLHSPrimaryKey) { - //return lhsPersister.getSubclassPropertyColumnNames(property); - return lhsPersister.IdentifierColumnNames; + return Persister.IdentifierColumnNames; } else { string propertyName = type.LHSPropertyName; if (propertyName == null) { - //slice, to get the columns for this component - //property - return ArrayHelper.Slice( - lhsPersister.GetSubclassPropertyColumnNames(property), - begin, - type.GetColumnSpan(mapping) - ); + //slice, to get the columns for this component property + return ArrayHelper.Slice(GetColumns(), begin, type.GetColumnSpan(Mapping)); } else { //property-refs for associations defined on a //component are not supported, so no need to slice - return lhsPersister.GetPropertyColumnNames(propertyName); + return Persister.GetPropertyColumnNames(propertyName); } } } - public static string GetLHSTableName( - IAssociationType type, - int property, - IOuterJoinLoadable lhsPersister - ) + protected abstract string[] GetAliasedColumns(); + protected abstract string[] GetColumns(); + + public abstract string GetTableName(IAssociationType type); + + #endregion + } + + public class PropertiesLhsAssociationTypeSqlInfo : AbstractLhsAssociationTypeSqlInfo + { + private readonly int propertyIdx; + + public PropertiesLhsAssociationTypeSqlInfo(string alias, + int propertyIdx, IOuterJoinLoadable persister, IMapping mapping) + : base(alias, persister, mapping) { + this.propertyIdx = propertyIdx; + } + + #region Overrides of AbstractLhsAssociationTypeSqlInfo + + protected override string[] GetAliasedColumns() + { + return Persister.ToColumns(Alias, propertyIdx); + } + + protected override string[] GetColumns() + { + return Persister.GetSubclassPropertyColumnNames(propertyIdx); + } + + public override string GetTableName(IAssociationType type) + { if (type.UseLHSPrimaryKey) { - return lhsPersister.TableName; + return Persister.TableName; } else { @@ -132,12 +163,12 @@ //if there is no property-ref, assume the join //is to the subclass table (ie. the table of the //subclass that the association belongs to) - return lhsPersister.GetSubclassPropertyTableName(property); + return Persister.GetSubclassPropertyTableName(propertyIdx); } else { //handle a property-ref - string propertyRefTable = lhsPersister.GetPropertyTableName(propertyName); + string propertyRefTable = Persister.GetPropertyTableName(propertyName); if (propertyRefTable == null) { //it is possible that the tree-walking in OuterJoinLoader can get to @@ -147,29 +178,38 @@ //assumes that the property-ref refers to a property of the subclass //table that the association belongs to (a reasonable guess) //TODO: fix this, add: IOuterJoinLoadable.getSubclassPropertyTableName(string propertyName) - propertyRefTable = lhsPersister.GetSubclassPropertyTableName(property); + propertyRefTable = Persister.GetSubclassPropertyTableName(propertyIdx); } return propertyRefTable; } } } - /// <summary> - /// Get the columns of the associated table which are to - /// be used in the join - /// </summary> - public static string[] GetRHSColumnNames(IAssociationType type, ISessionFactoryImplementor factory) + #endregion + } + + public class IdPropertiesLhsAssociationTypeSqlInfo : AbstractLhsAssociationTypeSqlInfo + { + public IdPropertiesLhsAssociationTypeSqlInfo(string alias, IOuterJoinLoadable persister, IMapping mapping) : base(alias, persister, mapping) {} + + #region Overrides of AbstractLhsAssociationTypeSqlInfo + + protected override string[] GetAliasedColumns() { - string uniqueKeyPropertyName = type.RHSUniqueKeyPropertyName; - IJoinable joinable = type.GetAssociatedJoinable(factory); - if (uniqueKeyPropertyName == null) - { - return joinable.KeyColumnNames; - } - else - { - return ((IOuterJoinLoadable) joinable).GetPropertyColumnNames(uniqueKeyPropertyName); - } + return Persister.ToIdentifierColumns(Alias); } + + protected override string[] GetColumns() + { + return Persister.IdentifierColumnNames; + } + + public override string GetTableName(IAssociationType type) + { + return Persister.TableName; + } + + #endregion } + } \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/AbstractEntityJoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -28,7 +28,7 @@ alias = rootSqlAlias; } - protected void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + protected virtual void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) { WalkEntityTree(persister, Alias); IList<OuterJoinableAssociation> allAssociations = new List<OuterJoinableAssociation>(associations); @@ -99,7 +99,7 @@ public abstract string Comment { get; } - protected ILoadable Persister + protected IOuterJoinLoadable Persister { get { return persister; } } Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/Criteria/CriteriaJoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -1,3 +1,4 @@ +using System; using System.Collections.Generic; using Iesi.Collections.Generic; using log4net; @@ -57,6 +58,25 @@ userAliases = ArrayHelper.ToStringArray(userAliasList); } + protected override void InitAll(SqlString whereString, SqlString orderByString, LockMode lockMode) + { + // NH different behavior (NH-1760) + WalkCompositeComponentIdTree(); + base.InitAll(whereString, orderByString, lockMode); + } + + private void WalkCompositeComponentIdTree() + { + IType type = Persister.IdentifierType; + string propertyName = Persister.IdentifierPropertyName; + if (type != null && type.IsComponentType && !(type is EmbeddedComponentType)) + { + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetIdLhsSqlInfo(Alias, Persister, Factory); + WalkComponentTree((IAbstractComponentType) type, 0, Alias, SubPath(string.Empty, propertyName), 0, + associationTypeSQLInfo); + } + } + public IType[] ResultTypes { get { return resultTypes; } Modified: branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Loader/JoinWalker.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Text; using Iesi.Collections.Generic; using NHibernate.Collection; using NHibernate.Engine; @@ -218,20 +217,18 @@ } } - private void WalkEntityAssociationTree(IAssociationType associationType, IOuterJoinLoadable persister, int propertyNumber, - string alias, string path, bool nullable, int currentDepth) + private void WalkEntityAssociationTree(IAssociationType associationType, IOuterJoinLoadable persister, + int propertyNumber, string alias, string path, bool nullable, int currentDepth, + ILhsAssociationTypeSqlInfo associationTypeSQLInfo) { - string[] aliasedLhsColumns = - JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, persister, Factory); + string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, 0); + string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, 0); + string lhsTable = associationTypeSQLInfo.GetTableName(associationType); - string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, persister, Factory); - string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister); - string subpath = SubPath(path, persister.GetSubclassPropertyName(propertyNumber)); - JoinType joinType = - GetJoinType(associationType, persister.GetFetchMode(propertyNumber), subpath, lhsTable, lhsColumns, nullable, - currentDepth, persister.GetCascadeStyle(propertyNumber)); + JoinType joinType = GetJoinType(associationType, persister.GetFetchMode(propertyNumber), subpath, lhsTable, + lhsColumns, nullable, currentDepth, persister.GetCascadeStyle(propertyNumber)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } @@ -246,15 +243,16 @@ for (int i = 0; i < n; i++) { IType type = persister.GetSubclassPropertyType(i); + ILhsAssociationTypeSqlInfo associationTypeSQLInfo = JoinHelper.GetLhsSqlInfo(alias, i, persister, Factory); if (type.IsAssociationType) { - WalkEntityAssociationTree((IAssociationType)type, persister, i, alias, path, - persister.IsSubclassPropertyNullable(i), currentDepth); + WalkEntityAssociationTree((IAssociationType) type, persister, i, alias, path, + persister.IsSubclassPropertyNullable(i), currentDepth, associationTypeSQLInfo); } else if (type.IsComponentType) { - WalkComponentTree((IAbstractComponentType)type, i, 0, persister, alias, - SubPath(path, persister.GetSubclassPropertyName(i)), currentDepth); + WalkComponentTree((IAbstractComponentType) type, 0, alias, SubPath(path, persister.GetSubclassPropertyName(i)), + currentDepth, associationTypeSQLInfo); } } } @@ -262,8 +260,8 @@ /// <summary> /// For a component, add to a list of associations to be fetched by outerjoin /// </summary> - private void WalkComponentTree(IAbstractComponentType componentType, int propertyNumber, int begin, - IOuterJoinLoadable persister, string alias, string path, int currentDepth) + protected void WalkComponentTree(IAbstractComponentType componentType, int begin, string alias, string path, + int currentDepth, ILhsAssociationTypeSqlInfo associationTypeSQLInfo) { IType[] types = componentType.Subtypes; string[] propertyNames = componentType.PropertyNames; @@ -271,19 +269,18 @@ { if (types[i].IsAssociationType) { - IAssociationType associationType = (IAssociationType)types[i]; - string[] aliasedLhsColumns = - JoinHelper.GetAliasedLHSColumnNames(associationType, alias, propertyNumber, begin, persister, Factory); + var associationType = (IAssociationType) types[i]; - string[] lhsColumns = JoinHelper.GetLHSColumnNames(associationType, propertyNumber, begin, persister, Factory); - string lhsTable = JoinHelper.GetLHSTableName(associationType, propertyNumber, persister); + string[] aliasedLhsColumns = associationTypeSQLInfo.GetAliasedColumnNames(associationType, begin); + string[] lhsColumns = associationTypeSQLInfo.GetColumnNames(associationType, begin); + string lhsTable = associationTypeSQLInfo.GetTableName(associationType); string subpath = SubPath(path, propertyNames[i]); bool[] propertyNullability = componentType.PropertyNullability; - JoinType joinType = - GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, - propertyNullability == null || propertyNullability[i], currentDepth, componentType.GetCascadeStyle(i)); + JoinType joinType = GetJoinType(associationType, componentType.GetFetchMode(i), subpath, lhsTable, lhsColumns, + propertyNullability == null || propertyNullability[i], currentDepth, + componentType.GetCascadeStyle(i)); AddAssociationToJoinTreeIfNecessary(associationType, aliasedLhsColumns, alias, subpath, currentDepth, joinType); } @@ -291,7 +288,7 @@ { string subpath = SubPath(path, propertyNames[i]); - WalkComponentTree((IAbstractComponentType)types[i], propertyNumber, begin, persister, alias, subpath, currentDepth); + WalkComponentTree((IAbstractComponentType) types[i], begin, alias, subpath, currentDepth, associationTypeSQLInfo); } begin += types[i].GetColumnSpan(Factory); } @@ -339,12 +336,9 @@ /// <summary> /// Extend the path by the given property name /// </summary> - private static string SubPath(string path, string property) + protected static string SubPath(string path, string property) { - if (path == null || path.Length == 0) - return property; - else - return StringHelper.Qualify(path, property); + return string.IsNullOrEmpty(path) ? property : StringHelper.Qualify(path, property); } /// <summary> Modified: branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -1852,6 +1852,18 @@ return result; } + public string[] ToIdentifierColumns(string name) + { + string alias = GenerateTableAlias(name, 0); + string[] cols = IdentifierColumnNames; + var result = new string[cols.Length]; + for (int j = 0; j < cols.Length; j++) + { + result[j] = StringHelper.Qualify(alias, cols[j]); + } + return result; + } + private int GetSubclassPropertyIndex(string propertyName) { return Array.IndexOf(subclassPropertyNameClosure, propertyName); Modified: branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/IOuterJoinLoadable.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -108,5 +108,10 @@ /// Get the table name for the given property path /// </summary> string GetPropertyTableName(string propertyName); + + /// <summary> + /// Return the alised identifier column names + /// </summary> + string[] ToIdentifierColumns(string alias); } } \ No newline at end of file Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/DomainClass.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -4,22 +4,22 @@ { public class Customer { - public Int32 Id { get; set; } - public String Name { get; set; } + public virtual Int32 Id { get; set; } + public virtual String Name { get; set; } } public class TestClass { - public TestClassId Id { get; set; } - public String Value { get; set; } + public virtual TestClassId Id { get; set; } + public virtual String Value { get; set; } } public class TestClassId { - public Customer Customer { get; set; } - public Int32 SomeInt { get; set; } + public virtual Customer Customer { get; set; } + public virtual Int32 SomeInt { get; set; } - public bool Equals(TestClassId other) + public virtual bool Equals(TestClassId other) { if (ReferenceEquals(null, other)) { Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/Mappings.hbm.xml 2009-10-18 13:19:08 UTC (rev 4773) @@ -1,7 +1,6 @@ <?xml version="1.0" encoding="utf-8" ?> <hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" - namespace="NHibernate.Test.NHSpecificTest.NH1760" - default-lazy="false"> + namespace="NHibernate.Test.NHSpecificTest.NH1760"> <class name="Customer"> <id name="Id"> Modified: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs 2009-10-18 01:21:02 UTC (rev 4772) +++ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1760/SampleTest.cs 2009-10-18 13:19:08 UTC (rev 4773) @@ -14,7 +14,7 @@ { var customer = new Customer {Name = "Alkampfer"}; session.Save(customer); - var testClass = new TestClass {Id = new TestClassId{Customer = customer, SomeInt = 42}, Value = "TESTVALUE"}; + var testClass = new TestClass { Id = new TestClassId { Customer = customer, SomeInt = 42 }, Value = "TESTVALUE" }; session.Save(testClass); tx.Commit(); } @@ -25,13 +25,13 @@ using (ISession session = OpenSession()) using (var tx = session.BeginTransaction()) { - session.CreateQuery("from TestClass").ExecuteUpdate(); - session.CreateQuery("from Customer").ExecuteUpdate(); + session.CreateQuery("delete from TestClass").ExecuteUpdate(); + session.CreateQuery("delete from Customer").ExecuteUpdate(); tx.Commit(); } } - [Test, Ignore("Not fixed yet.")] + [Test] public void CanUseCriteria() { FillDb(); @@ -40,7 +40,7 @@ using (ISession session = OpenSession()) { IList<TestClass> retvalue = - session.CreateQuery("Select tc from TestClass tc where tc.Id.Customer.Name = :name").SetString("name", "Alkampfer") + session.CreateQuery("Select tc from TestClass tc join tc.Id.Customer cu where cu.Name = :name").SetString("name", "Alkampfer") .List<TestClass>(); hqlCount = retvalue.Count; } @@ -53,10 +53,31 @@ IList<TestClass> retvalue = c.List<TestClass>(); criteriaCount = retvalue.Count; } - Assert.That(hqlCount == criteriaCount); - Assert.That(hqlCount, Is.EqualTo(1)); + Assert.That(criteriaCount, Is.EqualTo(1)); + Assert.That(criteriaCount, Is.EqualTo(hqlCount)); Cleanup(); } + + [Test] + public void TheJoinShouldBeOptional() + { + FillDb(); + int criteriaCount; + + using (ISession session = OpenSession()) + { + using (var ls = new SqlLogSpy()) + { + ICriteria c = session.CreateCriteria(typeof(TestClass)); + IList<TestClass> retvalue = c.List<TestClass>(); + Assert.That(ls.GetWholeLog(), Text.DoesNotContain("join")); + criteriaCount = retvalue.Count; + } + } + Assert.That(criteriaCount, Is.EqualTo(1)); + + Cleanup(); + } } } \ 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: <aye...@us...> - 2009-10-18 01:21:09
|
Revision: 4772 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4772&view=rev Author: ayenderahien Date: 2009-10-18 01:21:02 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Merging r4770 Making sure that child sessions share the same session id as their parent (allow correlation) Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-10-18 01:14:34 UTC (rev 4771) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-10-18 01:21:02 UTC (rev 4772) @@ -50,6 +50,12 @@ this.factory = factory; } + protected internal AbstractSessionImpl(ISessionFactoryImplementor factory, Guid sessionId) + : this(factory) + { + this.sessionId = sessionId; + } + #region ISessionImplementor Members public void Initialize() Modified: branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-10-18 01:14:34 UTC (rev 4771) +++ branches/2.1.x/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-10-18 01:21:02 UTC (rev 4772) @@ -240,7 +240,7 @@ /// <param name="parent">The parent Session</param> /// <param name="entityMode">The entity mode</param> private SessionImpl(SessionImpl parent, EntityMode entityMode) - : base(parent.Factory) + : base(parent.Factory, parent.SessionId) { using (new SessionIdLoggingContext(SessionId)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-10-18 01:14:44
|
Revision: 4771 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4771&view=rev Author: ayenderahien Date: 2009-10-18 01:14:34 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Just recording the previous merge Property Changed: ---------------- branches/2.1.x/nhibernate/ branches/2.1.x/nhibernate/src/NHibernate/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927/ branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928/ branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/ branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml Property changes on: branches/2.1.x/nhibernate ___________________________________________________________________ Added: svn:mergeinfo + /trunk:4770 /trunk/nhibernate:4768 Property changes on: branches/2.1.x/nhibernate/src/NHibernate ___________________________________________________________________ Added: svn:mergeinfo + /trunk/nhibernate/src:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/NHSpecificTest/NH1850/Customer.cs:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/NHSpecificTest/NH1850/Fixture.cs:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/NHSpecificTest/NH1850/Mappings.hbm.xml:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1927 ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/NHSpecificTest/NH1927:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1928 ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/NHSpecificTest/NH1928:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests ___________________________________________________________________ Modified: svn:mergeinfo - + /trunk/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests:4770 Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test/Tools/hbm2ddl/SchemaExportTests/WithColumnTag.hbm.xml ___________________________________________________________________ Deleted: svn:mergeinfo - This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-10-18 01:06:13
|
Revision: 4770 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4770&view=rev Author: ayenderahien Date: 2009-10-18 01:06:00 +0000 (Sun, 18 Oct 2009) Log Message: ----------- Making sure that child sessions share the same session id as their parent (allow correlation) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-10-17 23:44:14 UTC (rev 4769) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-10-18 01:06:00 UTC (rev 4770) @@ -50,6 +50,12 @@ this.factory = factory; } + protected internal AbstractSessionImpl(ISessionFactoryImplementor factory, Guid sessionId) + : this(factory) + { + this.sessionId = sessionId; + } + #region ISessionImplementor Members public void Initialize() Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-10-17 23:44:14 UTC (rev 4769) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-10-18 01:06:00 UTC (rev 4770) @@ -242,7 +242,7 @@ /// <param name="parent">The parent Session</param> /// <param name="entityMode">The entity mode</param> private SessionImpl(SessionImpl parent, EntityMode entityMode) - : base(parent.Factory) + : base(parent.Factory, parent.SessionId) { using (new SessionIdLoggingContext(SessionId)) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-10-17 23:44:26
|
Revision: 4769 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4769&view=rev Author: ayenderahien Date: 2009-10-17 23:44:14 +0000 (Sat, 17 Oct 2009) Log Message: ----------- Merging r4768 from trunk Adding current session id for actions that are performed outside of the session but belong the the session. Modified Paths: -------------- branches/2.1.x/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs branches/2.1.x/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs branches/2.1.x/nhibernate/src/NHibernate/Type/DbTimestampType.cs Property Changed: ---------------- branches/2.1.x/nhibernate/src/ branches/2.1.x/nhibernate/src/NHibernate.Test/ Property changes on: branches/2.1.x/nhibernate/src ___________________________________________________________________ Modified: svn:mergeinfo - /trunk/nhibernate/src:4657 + /trunk/nhibernate/src:4657,4768 Modified: branches/2.1.x/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs 2009-10-17 23:34:20 UTC (rev 4768) +++ branches/2.1.x/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs 2009-10-17 23:44:14 UTC (rev 4769) @@ -2,6 +2,7 @@ using System.Data.Common; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Impl; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -48,6 +49,7 @@ } SqlString selectSQL = SelectSQL; + using (new SessionIdLoggingContext(session.SessionId)) try { //fetch the generated id in a separate query Modified: branches/2.1.x/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-10-17 23:34:20 UTC (rev 4768) +++ branches/2.1.x/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-10-17 23:44:14 UTC (rev 4769) @@ -1504,6 +1504,7 @@ public int GetSize(object key, ISessionImplementor session) { + using(new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sqlSelectSizeString, KeyType.SqlTypes(factory)); @@ -1540,6 +1541,7 @@ private bool Exists(object key, object indexOrElement, IType indexOrElementType, SqlString sql, ISessionImplementor session) { + using(new SessionIdLoggingContext(session.SessionId)) try { List<SqlType> sqlTl = new List<SqlType>(KeyType.SqlTypes(factory)); @@ -1579,6 +1581,7 @@ public virtual object GetElementByIndex(object key, object index, ISessionImplementor session, object owner) { + using(new SessionIdLoggingContext(session.SessionId)) try { List<SqlType> sqlTl = new List<SqlType>(KeyType.SqlTypes(factory)); Modified: branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-17 23:34:20 UTC (rev 4768) +++ branches/2.1.x/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-17 23:44:14 UTC (rev 4769) @@ -1230,6 +1230,7 @@ log.Debug("initializing lazy properties from datastore"); + using (new SessionIdLoggingContext(session.SessionId)) try { object result = null; @@ -1406,6 +1407,7 @@ log.Debug("Getting current persistent state for: " + MessageHelper.InfoString(this, id, Factory)); } + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, SQLSnapshotSelectString, IdentifierType.SqlTypes(factory)); @@ -1661,7 +1663,7 @@ { log.Debug("Getting version: " + MessageHelper.InfoString(this, id, Factory)); } - + using(new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareQueryCommand(CommandType.Text, VersionSelectString, IdentifierType.SqlTypes(Factory)); @@ -2415,6 +2417,7 @@ IDbCommand sequentialSelect = null; IDataReader sequentialResultSet = null; bool sequentialSelectEmpty = false; + using (new SessionIdLoggingContext(session.SessionId)) try { if (hasDeferred) @@ -3917,6 +3920,7 @@ { session.Batcher.ExecuteBatch(); //force immediate execution of the insert + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand cmd = @@ -4007,6 +4011,7 @@ /////////////////////////////////////////////////////////////////////// object[] snapshot = new object[naturalIdPropertyCount]; + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, IdentifierType.SqlTypes(factory)); Modified: branches/2.1.x/nhibernate/src/NHibernate/Type/DbTimestampType.cs =================================================================== --- branches/2.1.x/nhibernate/src/NHibernate/Type/DbTimestampType.cs 2009-10-17 23:34:20 UTC (rev 4768) +++ branches/2.1.x/nhibernate/src/NHibernate/Type/DbTimestampType.cs 2009-10-17 23:44:14 UTC (rev 4769) @@ -4,6 +4,7 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Impl; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -58,6 +59,7 @@ var tsSelect = new SqlString(timestampSelectString); IDbCommand ps = null; IDataReader rs = null; + using (new SessionIdLoggingContext(session.SessionId)) try { ps = session.Batcher.PrepareCommand(CommandType.Text, tsSelect, EmptyParams); Property changes on: branches/2.1.x/nhibernate/src/NHibernate.Test ___________________________________________________________________ Modified: svn:ignore - bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml + bin obj .#* *.user *.xsx AssemblyInfo.cs hibernate.cfg.xml Debug Release *.aps *.eto [Bb]in [Dd]ebug [Rr]elease *resharper* *.xml Summary.xslt This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <aye...@us...> - 2009-10-17 23:34:40
|
Revision: 4768 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4768&view=rev Author: ayenderahien Date: 2009-10-17 23:34:20 +0000 (Sat, 17 Oct 2009) Log Message: ----------- Adding current session id for actions that are performed outside of the session but belong the the session. Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs Property Changed: ---------------- trunk/ Property changes on: trunk ___________________________________________________________________ Modified: svn:mergeinfo - /branches/2.1.x:4505-4508 + /branches/2.1.x:4505-4508,4510-4513,4537-4538 Modified: trunk/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs 2009-10-16 20:21:57 UTC (rev 4767) +++ trunk/nhibernate/src/NHibernate/Id/Insert/AbstractSelectingDelegate.cs 2009-10-17 23:34:20 UTC (rev 4768) @@ -2,6 +2,7 @@ using System.Data.Common; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Impl; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -48,6 +49,7 @@ } SqlString selectSQL = SelectSQL; + using (new SessionIdLoggingContext(session.SessionId)) try { //fetch the generated id in a separate query Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-10-16 20:21:57 UTC (rev 4767) +++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2009-10-17 23:34:20 UTC (rev 4768) @@ -1504,6 +1504,7 @@ public int GetSize(object key, ISessionImplementor session) { + using(new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, sqlSelectSizeString, KeyType.SqlTypes(factory)); @@ -1540,6 +1541,7 @@ private bool Exists(object key, object indexOrElement, IType indexOrElementType, SqlString sql, ISessionImplementor session) { + using(new SessionIdLoggingContext(session.SessionId)) try { List<SqlType> sqlTl = new List<SqlType>(KeyType.SqlTypes(factory)); @@ -1579,6 +1581,7 @@ public virtual object GetElementByIndex(object key, object index, ISessionImplementor session, object owner) { + using(new SessionIdLoggingContext(session.SessionId)) try { List<SqlType> sqlTl = new List<SqlType>(KeyType.SqlTypes(factory)); Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-16 20:21:57 UTC (rev 4767) +++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-10-17 23:34:20 UTC (rev 4768) @@ -1230,6 +1230,7 @@ log.Debug("initializing lazy properties from datastore"); + using (new SessionIdLoggingContext(session.SessionId)) try { object result = null; @@ -1406,6 +1407,7 @@ log.Debug("Getting current persistent state for: " + MessageHelper.InfoString(this, id, Factory)); } + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareCommand(CommandType.Text, SQLSnapshotSelectString, IdentifierType.SqlTypes(factory)); @@ -1661,7 +1663,7 @@ { log.Debug("Getting version: " + MessageHelper.InfoString(this, id, Factory)); } - + using(new SessionIdLoggingContext(session.SessionId)) try { IDbCommand st = session.Batcher.PrepareQueryCommand(CommandType.Text, VersionSelectString, IdentifierType.SqlTypes(Factory)); @@ -2415,6 +2417,7 @@ IDbCommand sequentialSelect = null; IDataReader sequentialResultSet = null; bool sequentialSelectEmpty = false; + using (new SessionIdLoggingContext(session.SessionId)) try { if (hasDeferred) @@ -3917,6 +3920,7 @@ { session.Batcher.ExecuteBatch(); //force immediate execution of the insert + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand cmd = @@ -4007,6 +4011,7 @@ /////////////////////////////////////////////////////////////////////// object[] snapshot = new object[naturalIdPropertyCount]; + using (new SessionIdLoggingContext(session.SessionId)) try { IDbCommand ps = session.Batcher.PrepareCommand(CommandType.Text, sql, IdentifierType.SqlTypes(factory)); Modified: trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs 2009-10-16 20:21:57 UTC (rev 4767) +++ trunk/nhibernate/src/NHibernate/Type/DbTimestampType.cs 2009-10-17 23:34:20 UTC (rev 4768) @@ -4,6 +4,7 @@ using log4net; using NHibernate.Engine; using NHibernate.Exceptions; +using NHibernate.Impl; using NHibernate.SqlCommand; using NHibernate.SqlTypes; @@ -58,6 +59,7 @@ var tsSelect = new SqlString(timestampSelectString); IDbCommand ps = null; IDataReader rs = null; + using (new SessionIdLoggingContext(session.SessionId)) try { ps = session.Batcher.PrepareCommand(CommandType.Text, tsSelect, EmptyParams); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-10-16 20:22:09
|
Revision: 4767 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4767&view=rev Author: fabiomaulo Date: 2009-10-16 20:21:57 +0000 (Fri, 16 Oct 2009) Log Message: ----------- Merge r4766 (re-fix NH-1255) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-10-16 20:18:56 UTC (rev 4766) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-10-16 20:21:57 UTC (rev 4767) @@ -743,6 +743,7 @@ <xs:attribute name="foreign-key" type="xs:string" /> <xs:attribute name="lazy" type="restrictedLaziness"> </xs:attribute> + <xs:attribute name="not-found" default="exception" type="notFoundMode"/> </xs:complexType> </xs:element> <xs:element name="key-property"> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Domain.cs 2009-10-16 20:21:57 UTC (rev 4767) @@ -0,0 +1,65 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1255 +{ + public class Customer + { + public int Id { get; set; } + public string Name { get; set; } + } + + public class CustomerValue + { + public CustomerValueId Id { get; set; } + public decimal Value { get; set; } + } + + public class CustomerValueId : IEquatable<CustomerValueId> + { + private int? requestedHashCode; + public Customer Customer { get; set; } + public int CustomKey { get; set; } + + public bool Equals(CustomerValueId other) + { + if (ReferenceEquals(null, other)) + { + return false; + } + if (ReferenceEquals(this, other)) + { + return true; + } + return Equals(other.Customer, Customer) && other.CustomKey == CustomKey; + } + + public override bool Equals(object obj) + { + if (ReferenceEquals(null, obj)) + { + return false; + } + if (ReferenceEquals(this, obj)) + { + return true; + } + if (obj.GetType() != typeof (CustomerValueId)) + { + return false; + } + return Equals((CustomerValueId) obj); + } + + public override int GetHashCode() + { + if (!requestedHashCode.HasValue) + { + unchecked + { + requestedHashCode = ((Customer != null ? Customer.GetHashCode() : base.GetHashCode()) * 397) ^ CustomKey; + } + } + return requestedHashCode.Value; + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Fixture.cs 2009-10-16 20:21:57 UTC (rev 4767) @@ -0,0 +1,19 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1255 +{ + [TestFixture] + public class Fixture + { + [Test] + public void CanLoadMappingWithNotNullIgnore() + { + var cfg = new Configuration(); + if (TestConfigurationHelper.hibernateConfigFile != null) + cfg.Configure(TestConfigurationHelper.hibernateConfigFile); + Assert.DoesNotThrow( + () => cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1255.Mappings.hbm.xml", typeof (Customer).Assembly)); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1255/Mappings.hbm.xml 2009-10-16 20:21:57 UTC (rev 4767) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1255" + default-lazy="false"> + + <class name="Customer"> + <id name="Id"> + <generator class="native" /> + </id> + <property name="Name" /> + </class> + + <class name="CustomerValue" > + <composite-id name="Id" class="CustomerValueId"> + <key-many-to-one class="Customer" name="Customer" not-found="ignore" /> + <key-property name="CustomKey" /> + </composite-id> + <property name="Value" /> + </class> + +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-16 20:18:56 UTC (rev 4766) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-10-16 20:21:57 UTC (rev 4767) @@ -395,6 +395,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> <Compile Include="NHSpecificTest\Futures\FutureQueryOverFixture.cs" /> + <Compile Include="NHSpecificTest\NH1255\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1255\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1895\DomainClasses.cs" /> <Compile Include="NHSpecificTest\NH1895\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1922\Fixture.cs" /> @@ -2042,6 +2044,7 @@ <EmbeddedResource Include="CfgTest\Loquacious\EntityToCache.hbm.xml" /> <EmbeddedResource Include="DriverTest\SqlServerCeEntity.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1255\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1895\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1985\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1990\Mappings.hbm.xml" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |