|
From: <fab...@us...> - 2009-05-14 16:26:51
|
Revision: 4303
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4303&view=rev
Author: fabiomaulo
Date: 2009-05-14 16:26:47 +0000 (Thu, 14 May 2009)
Log Message:
-----------
Test for NH-1776 not fixed yet.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Category.cs 2009-05-14 16:26:47 UTC (rev 4303)
@@ -0,0 +1,9 @@
+namespace NHibernate.Test.NHSpecificTest.NH1776
+{
+ public class Category
+ {
+ public virtual int Id { get; set; }
+ public virtual string Code { get; set; }
+ public virtual bool Deleted { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/FilterQueryTwiceFixture.cs 2009-05-14 16:26:47 UTC (rev 4303)
@@ -0,0 +1,52 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1776
+{
+ [TestFixture, Ignore("Not fixed yet.")]
+ public class FilterQueryTwiceFixture : BugTestCase
+ {
+ [Test]
+ [Description("Can Query using Session's filter Twice")]
+ public void Bug()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ var c = new Category {Code = "2600", Deleted = false};
+ s.SaveOrUpdate(c);
+ tx.Commit();
+ }
+ }
+
+ // exec queries, twice, different session
+ ExecQuery();
+ ExecQuery();
+
+ // cleanup
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.EnableFilter("state").SetParameter("deleted", false);
+ s.Delete("from Category");
+ tx.Commit();
+ }
+ }
+ }
+
+ private void ExecQuery()
+ {
+ using (ISession s = OpenSession())
+ {
+ s.EnableFilter("state").SetParameter("deleted", false);
+
+ IList<Category> result =
+ s.CreateQuery("from Category where Code = :code").SetParameter("code", "2600").List<Category>();
+
+ Assert.That(result.Count > 0);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1776/Mappings.hbm.xml 2009-05-14 16:26:47 UTC (rev 4303)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1776"
+ assembly="NHibernate.Test">
+
+ <class name="Category">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Code"/>
+ <property name="Deleted"/>
+ <filter name="state" condition=":deleted = Deleted"/>
+ </class>
+
+ <filter-def name="state" condition=":deleted = Deleted">
+ <filter-param name="deleted" type="Boolean"/>
+ </filter-def>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 14:52:56 UTC (rev 4302)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 16:26:47 UTC (rev 4303)
@@ -383,6 +383,8 @@
<Compile Include="NHSpecificTest\NH1760\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1773\Domain.cs" />
<Compile Include="NHSpecificTest\NH1773\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1776\Category.cs" />
+ <Compile Include="NHSpecificTest\NH1776\FilterQueryTwiceFixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1775,6 +1777,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1760\Mappings.hbm.xml" />
<EmbeddedResource Include="MappingTest\Wicked.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-05-14 21:35:15
|
Revision: 4306
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4306&view=rev
Author: fabiomaulo
Date: 2009-05-14 21:35:00 +0000 (Thu, 14 May 2009)
Log Message:
-----------
The user said that is a valid test... it not fail on trunk.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Mappings.hbm.xml 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1574">
+
+ <class name="SpecializedTeamStorage"
+ table="TeamStorage"
+ discriminator-value="-1963354017">
+ <id name="Id" type="Int32" column="TeamStorageID">
+ <generator class="hilo">
+ <param name="table">HiLoGenerator</param>
+ <param name="column">NextValue</param>
+ <param name="max_lo">100</param>
+ </generator>
+ </id>
+ <property name="Name" column="Name" type="String" length="450" />
+ <property name="EloRanking" column="EloRanking" type="Int32" />
+ <property name="MaxElo" column="MaxElo" type="Int32" />
+ <property name="MinElo" column="MinElo" type="Int32" />
+ <property name="CreationDate" column="CreationDate" type="DateTime" />
+ <property name="NumberPlayedBattles" column="NumberPlayedBattles" type="Int32" />
+ <property name="LadderActive" column="LadderActive" type="Boolean" />
+ <property name="LadderPosition" column="LadderPosition" type="Int32" />
+ <property name="IsInBattle" column="IsInBattle" type="Int32" />
+ <property name="RestUntil" column="RestUntil" type="Int32" />
+ <property name="StoppedUntil" column="StoppedUntil" type="Int32" />
+ <bag name="Principals" inverse="true" lazy="true">
+ <key column="TeamID" />
+ <one-to-many class="SpecializedPrincipal" />
+ </bag>
+ </class>
+
+ <class name="SpecializedPrincipal"
+ table="Principal"
+ discriminator-value="-2035371692">
+ <id name="Id" type="Int32" column="PrincipalID">
+ <generator class="hilo">
+ <param name="table">HiLoGenerator</param>
+ <param name="column">NextValue</param>
+ <param name="max_lo">100</param>
+ </generator>
+ </id>
+ <property name="IsBot" column="IsBot" type="Boolean" />
+ <property name="MyStatsId" column="MyStatsId" type="Int32" />
+ <property name="EloRanking" column="EloRanking" type="Int32" />
+ <property name="ReceiveMail" column="ReceiveMail" type="Boolean" />
+ <property name="Credits" column="Credits" type="Int32" />
+ <property name="LadderActive" column="LadderActive" type="Boolean" />
+ <property name="LadderPosition" column="LadderPosition" type="Int32" />
+ <property name="IsInBattle" column="IsInBattle" type="Int32" />
+ <property name="RestUntil" column="RestUntil" type="Int32" />
+ <property name="StoppedUntil" column="StoppedUntil" type="Int32" />
+ <property name="AvailableVacationTicks" column="AvailableVacationTicks" type="Int32" />
+ <property name="VacationStartTick" column="VacationStartTick" type="Int32" />
+ <property name="VacationEndtick" column="VacationEndtick" type="Int32" />
+ <property name="AutoStartVacations" column="AutoStartVacations" type="Boolean" />
+
+ <many-to-one name="Team" column="TeamID" not-null="false" />
+
+ <property name="Name" column="Name" type="String" length="200" />
+ <property name="Password" column="Password" type="String" length="50" />
+ <property name="Email" column="Email" type="String" length="200" />
+ <property name="Ip" column="Ip" type="String" length="15" />
+ <property name="RegistDate" column="RegistDate" type="DateTime" />
+ <property name="LastLogin" column="LastLogin" type="DateTime" />
+ <property name="Approved" column="Approved" type="Boolean" />
+ <property name="IsOnline" column="IsOnline" type="Boolean" />
+ <property name="Locked" column="Locked" type="Boolean" />
+ <property name="Locale" column="Locale" type="String" length="6" />
+ <property name="ConfirmationCode" column="ConfirmationCode" type="String" length="100" />
+ <property name="RawRoles" column="RawRoles" type="String" length="250" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Principal.cs 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,283 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1574
+{
+ public class Principal
+ {
+ private bool approved;
+ private bool autoStartVacations;
+ private int availableVacationTicks;
+ private string confirmationCode;
+ private int credits;
+ private int eloRanking;
+ private string email;
+ private string ip;
+ private bool isBot;
+ private int isInBattle;
+ private bool isOnline;
+ private bool ladderActive;
+ private int ladderPosition;
+ private DateTime lastLogin = DateTime.Now;
+ private string locale;
+ private bool locked;
+ private int myStatsId;
+ private string name;
+ private string password;
+ private string rawRoles;
+ private bool receiveMail;
+ private DateTime registDate = DateTime.Now;
+ private int restUntil;
+ private int stoppedUntil;
+ private int vacationEndtick;
+ private int vacationStartTick;
+
+ private int id;
+ private SpecializedTeamStorage team;
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's IsBot
+ /// </summary>
+ public virtual bool IsBot
+ {
+ set { isBot = value; }
+ get { return isBot; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's MyStatsId
+ /// </summary>
+ public virtual int MyStatsId
+ {
+ set { myStatsId = value; }
+ get { return myStatsId; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's EloRanking
+ /// </summary>
+ public virtual int EloRanking
+ {
+ set { eloRanking = value; }
+ get { return eloRanking; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's ReceiveMail
+ /// </summary>
+ public virtual bool ReceiveMail
+ {
+ set { receiveMail = value; }
+ get { return receiveMail; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Credits
+ /// </summary>
+ public virtual int Credits
+ {
+ set { credits = value; }
+ get { return credits; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's LadderActive
+ /// </summary>
+ public virtual bool LadderActive
+ {
+ set { ladderActive = value; }
+ get { return ladderActive; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's LadderPosition
+ /// </summary>
+ public virtual int LadderPosition
+ {
+ set { ladderPosition = value; }
+ get { return ladderPosition; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's IsInBattle
+ /// </summary>
+ public virtual int IsInBattle
+ {
+ set { isInBattle = value; }
+ get { return isInBattle; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's RestUntil
+ /// </summary>
+ public virtual int RestUntil
+ {
+ set { restUntil = value; }
+ get { return restUntil; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's StoppedUntil
+ /// </summary>
+ public virtual int StoppedUntil
+ {
+ set { stoppedUntil = value; }
+ get { return stoppedUntil; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's AvailableVacationTicks
+ /// </summary>
+ public virtual int AvailableVacationTicks
+ {
+ set { availableVacationTicks = value; }
+ get { return availableVacationTicks; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's VacationStartTick
+ /// </summary>
+ public virtual int VacationStartTick
+ {
+ set { vacationStartTick = value; }
+ get { return vacationStartTick; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's VacationEndtick
+ /// </summary>
+ public virtual int VacationEndtick
+ {
+ set { vacationEndtick = value; }
+ get { return vacationEndtick; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's AutoStartVacations
+ /// </summary>
+ public virtual bool AutoStartVacations
+ {
+ set { autoStartVacations = value; }
+ get { return autoStartVacations; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Name
+ /// </summary>
+ public virtual string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Password
+ /// </summary>
+ public virtual string Password
+ {
+ set { password = value; }
+ get { return password; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Email
+ /// </summary>
+ public virtual string Email
+ {
+ set { email = value; }
+ get { return email; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Ip
+ /// </summary>
+ public virtual string Ip
+ {
+ set { ip = value; }
+ get { return ip; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's RegistDate
+ /// </summary>
+ public virtual DateTime RegistDate
+ {
+ set { registDate = value; }
+ get { return registDate; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's LastLogin
+ /// </summary>
+ public virtual DateTime LastLogin
+ {
+ set { lastLogin = value; }
+ get { return lastLogin; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Approved
+ /// </summary>
+ public virtual bool Approved
+ {
+ set { approved = value; }
+ get { return approved; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's IsOnline
+ /// </summary>
+ public virtual bool IsOnline
+ {
+ set { isOnline = value; }
+ get { return isOnline; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Locked
+ /// </summary>
+ public virtual bool Locked
+ {
+ set { locked = value; }
+ get { return locked; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's Locale
+ /// </summary>
+ public virtual string Locale
+ {
+ set { locale = value; }
+ get { return locale; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's ConfirmationCode
+ /// </summary>
+ public virtual string ConfirmationCode
+ {
+ set { confirmationCode = value; }
+ get { return confirmationCode; }
+ }
+
+ /// <summary>
+ /// Gets the Principal's RawRoles
+ /// </summary>
+ public virtual string RawRoles
+ {
+ set { rawRoles = value; }
+ get { return rawRoles; }
+ }
+
+ public virtual SpecializedTeamStorage Team
+ {
+ get { return team; }
+ set { team = value; }
+ }
+ } ;
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedPrincipal.cs 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,4 @@
+namespace NHibernate.Test.NHSpecificTest.NH1574
+{
+ public class SpecializedPrincipal : Principal {} ;
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/SpecializedTeaml.cs 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,4 @@
+namespace NHibernate.Test.NHSpecificTest.NH1574
+{
+ public class SpecializedTeamStorage : TeamStorage {} ;
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/StatelessTest.cs 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,46 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1574
+{
+ [TestFixture]
+ public class StatelessTest : BugTestCase
+ {
+ [Test]
+ public void StatelessManyToOne()
+ {
+ using (ISession session = OpenSession())
+ {
+ var principal = new SpecializedPrincipal();
+ var team = new SpecializedTeamStorage();
+ principal.Team = team;
+ session.SaveOrUpdate(team);
+ session.SaveOrUpdate(principal);
+ session.Flush();
+ }
+
+ using (IStatelessSession session = sessions.OpenStatelessSession())
+ {
+ IQuery query = session.CreateQuery("from SpecializedPrincipal p");
+ IList<Principal> principals = query.List<Principal>();
+ Assert.AreEqual(1, principals.Count);
+
+ ITransaction trans = session.BeginTransaction();
+ foreach (var principal in principals)
+ {
+ principal.Name = "Buu";
+ session.Update(principal);
+ }
+ trans.Commit();
+ }
+
+ // cleanup
+ using (ISession session = OpenSession())
+ {
+ session.Delete("from SpecializedTeamStorage");
+ session.Delete("from SpecializedPrincipal");
+ session.Flush();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1574/Team.cs 2009-05-14 21:35:00 UTC (rev 4306)
@@ -0,0 +1,134 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1574
+{
+ public class TeamStorage
+ {
+ private DateTime creationDate = DateTime.Now;
+ private int eloRanking;
+ private int isInBattle;
+ private bool ladderActive;
+ private int ladderPosition;
+ private int maxElo;
+ private int minElo;
+ private string name;
+ private int numberPlayedBattles;
+ private int restUntil;
+ private int stoppedUntil;
+
+ private int id;
+ private IList<Principal> principals;
+
+ /// <summary>
+ /// Gets the TeamStorage's Name
+ /// </summary>
+ public virtual string Name
+ {
+ set { name = value; }
+ get { return name; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's EloRanking
+ /// </summary>
+ public virtual int EloRanking
+ {
+ set { eloRanking = value; }
+ get { return eloRanking; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's MaxElo
+ /// </summary>
+ public virtual int MaxElo
+ {
+ set { maxElo = value; }
+ get { return maxElo; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's MinElo
+ /// </summary>
+ public virtual int MinElo
+ {
+ set { minElo = value; }
+ get { return minElo; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's CreationDate
+ /// </summary>
+ public virtual DateTime CreationDate
+ {
+ set { creationDate = value; }
+ get { return creationDate; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's NumberPlayedBattles
+ /// </summary>
+ public virtual int NumberPlayedBattles
+ {
+ set { numberPlayedBattles = value; }
+ get { return numberPlayedBattles; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's LadderActive
+ /// </summary>
+ public virtual bool LadderActive
+ {
+ set { ladderActive = value; }
+ get { return ladderActive; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's LadderPosition
+ /// </summary>
+ public virtual int LadderPosition
+ {
+ set { ladderPosition = value; }
+ get { return ladderPosition; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's IsInBattle
+ /// </summary>
+ public virtual int IsInBattle
+ {
+ set { isInBattle = value; }
+ get { return isInBattle; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's RestUntil
+ /// </summary>
+ public virtual int RestUntil
+ {
+ set { restUntil = value; }
+ get { return restUntil; }
+ }
+
+ /// <summary>
+ /// Gets the TeamStorage's StoppedUntil
+ /// </summary>
+ public virtual int StoppedUntil
+ {
+ set { stoppedUntil = value; }
+ get { return stoppedUntil; }
+ }
+
+ public virtual IList<Principal> Principals
+ {
+ get { return principals; }
+ set { principals = value; }
+ }
+
+ public virtual int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+ } ;
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:10:28 UTC (rev 4305)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:35:00 UTC (rev 4306)
@@ -329,6 +329,11 @@
<Compile Include="HQL\BaseFunctionFixture.cs" />
<Compile Include="MappingTest\NonReflectiveBinderFixture.cs" />
<Compile Include="MappingTest\Wicked.cs" />
+ <Compile Include="NHSpecificTest\NH1574\Principal.cs" />
+ <Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" />
+ <Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" />
+ <Compile Include="NHSpecificTest\NH1574\StatelessTest.cs" />
+ <Compile Include="NHSpecificTest\NH1574\Team.cs" />
<Compile Include="NHSpecificTest\Dates\TimeFixture.cs" />
<Compile Include="NHSpecificTest\DtcFailures\DtcFailuresFixture.cs" />
<Compile Include="NHSpecificTest\DtcFailures\Person.cs" />
@@ -1777,6 +1782,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1773\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1760\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-05-15 01:14:14
|
Revision: 4308
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4308&view=rev
Author: fabiomaulo
Date: 2009-05-15 01:14:05 +0000 (Fri, 15 May 2009)
Log Message:
-----------
Starting some improv. for <element> enums
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs 2009-05-15 01:14:05 UTC (rev 4308)
@@ -0,0 +1,48 @@
+using System.Collections;
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.ElementsEnums
+{
+ [TestFixture]
+ public class IntEnumsBagFixture : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] { "NHSpecificTest.ElementsEnums.SimpleWithEnums.hbm.xml" }; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ [Description("Should load the list of enums (NH-1772)")]
+ public void LoadEnums()
+ {
+ object savedId;
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ savedId = s.Save(new SimpleWithEnums { Things = new List<Something> { Something.B, Something.C, Something.D, Something.E } });
+ s.Transaction.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ var swe = s.Get<SimpleWithEnums>(savedId);
+ Assert.That(swe.Things, Is.EqualTo(new[] {Something.B, Something.C, Something.D, Something.E}));
+ s.Transaction.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.Delete("from SimpleWithEnums");
+ s.Transaction.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/SimpleWithEnums.hbm.xml 2009-05-15 01:14:05 UTC (rev 4308)
@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.ElementsEnums">
+
+ <class name="SimpleWithEnums">
+ <id type="int">
+ <generator class="native"/>
+ </id>
+
+ <property name="Something"/>
+ <bag name="Things">
+ <key column="bid"/>
+ <element type="NHibernate.Test.NHSpecificTest.ElementsEnums.Something, NHibernate.Test" column="enumvalue"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/Something.cs 2009-05-15 01:14:05 UTC (rev 4308)
@@ -0,0 +1,15 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.ElementsEnums
+{
+ public enum Something
+ {
+ A,B,C,D,E,F
+ }
+
+ public class SimpleWithEnums
+ {
+ public virtual Something Something { get; set; }
+ public virtual IList<Something> Things { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-14 21:38:50 UTC (rev 4307)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 01:14:05 UTC (rev 4308)
@@ -329,6 +329,8 @@
<Compile Include="HQL\BaseFunctionFixture.cs" />
<Compile Include="MappingTest\NonReflectiveBinderFixture.cs" />
<Compile Include="MappingTest\Wicked.cs" />
+ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" />
+ <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
<Compile Include="NHSpecificTest\NH1574\Principal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" />
@@ -1782,6 +1784,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnums.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1776\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1773\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-05-15 04:38:12
|
Revision: 4310
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4310&view=rev
Author: fabiomaulo
Date: 2009-05-15 04:38:07 +0000 (Fri, 15 May 2009)
Log Message:
-----------
Test NH1338 (if it was real, was fixed in some moment)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Fixture.cs 2009-05-15 04:38:07 UTC (rev 4310)
@@ -0,0 +1,129 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1388
+{
+ public class Student
+ {
+ private int _id;
+ private readonly IDictionary<Subject, Major> _majors = new Dictionary<Subject, Major>();
+
+ public virtual int Id
+ {
+ get { return _id; }
+ }
+
+ public virtual IDictionary<Subject, Major> Majors
+ {
+ get { return _majors; }
+ }
+ }
+
+ public class Subject
+ {
+ public int Id { get; set; }
+
+ public string Title { get; set; }
+ }
+
+ public class Major
+ {
+ public string Note { get; set; }
+ }
+
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ [Test]
+ public void BagTest()
+ {
+ int studentId = 1;
+
+ // Set major.
+ using (ISession session = OpenSession())
+ {
+ ITransaction t = session.BeginTransaction();
+ var student = new Student();
+ var subject1 = new Subject {Id = 1};
+ var subject2 = new Subject {Id = 2};
+
+ // Create major objects.
+ var major1 = new Major {Note = ""};
+
+ var major2 = new Major {Note = ""};
+
+ // Set major objects.
+ student.Majors[subject1] = major1;
+ student.Majors[subject2] = major2;
+
+ session.Save(subject1);
+ session.Save(subject2);
+ session.Save(student);
+
+ session.Flush();
+ t.Commit();
+ }
+ // Remove major for subject 2.
+ using (ISession session = OpenSession())
+ {
+ ITransaction t = session.BeginTransaction();
+ var student = session.Get<Student>(studentId);
+ var subject2 = session.Get<Subject>(2);
+
+ // Remove major.
+ student.Majors.Remove(subject2);
+
+ session.Flush();
+ t.Commit();
+ }
+
+ // Get major for subject 2.
+ using (ISession session = OpenSession())
+ {
+ ITransaction t = session.BeginTransaction();
+ var student = session.Get<Student>(studentId);
+ var subject2 = session.Get<Subject>(2);
+
+ Assert.IsNotNull(subject2);
+
+ // Major for subject 2 should have been removed.
+ Assert.IsFalse(student.Majors.ContainsKey(subject2));
+
+ t.Commit();
+ }
+
+ // Remove all - NHibernate will now succeed in removing all.
+ using (ISession session = OpenSession())
+ {
+ ITransaction t = session.BeginTransaction();
+ var student = session.Get<Student>(studentId);
+ student.Majors.Clear();
+ session.Flush();
+ t.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ // clean up the database
+ using (ISession session = OpenSession())
+ {
+ session.BeginTransaction();
+ foreach (var student in session.CreateCriteria(typeof (Student)).List<Student>())
+ {
+ session.Delete(student);
+ }
+ foreach (var subject in session.CreateCriteria(typeof (Subject)).List<Subject>())
+ {
+ session.Delete(subject);
+ }
+ session.Transaction.Commit();
+ }
+ }
+
+ protected override string CacheConcurrencyStrategy
+ {
+ get { return null; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1388/Mappings.hbm.xml 2009-05-15 04:38:07 UTC (rev 4310)
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping
+ xmlns="urn:nhibernate-mapping-2.2"
+ default-lazy="true"
+ default-cascade="save-update"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1388">
+
+ <class name="Student" table="STUDENT" lazy="false">
+
+ <id name="Id" column="STUDENT_ID" type="int" access="nosetter.camelcase-underscore">
+ <generator class="native" >
+ <param name="sequence">STUDENT_ID_SEQUENCE</param>
+ </generator>
+ </id>
+
+ <map name="Majors"
+ cascade="all"
+ inverse="false"
+ access="field.camelcase-underscore"
+ fetch="select"
+ lazy="true"
+ batch-size="100"
+ table="MAJOR">
+ <key column="STUDENT_ID" foreign-key="STUDENT_ID" />
+ <index-many-to-many column="SUBJECT_ID" class="Subject" />
+ <composite-element class="Major">
+ <property name="Note" column="NOTE" />
+ </composite-element>
+ </map>
+
+ </class>
+
+ <class name="Subject" table="SUBJECT" lazy="false">
+
+ <id name="Id" column="SUBJECT_ID" type="int">
+ <generator class="assigned" />
+ </id>
+
+ <property name="Title" column="TITLE" />
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 01:28:03 UTC (rev 4309)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 04:38:07 UTC (rev 4310)
@@ -331,6 +331,7 @@
<Compile Include="MappingTest\Wicked.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
+ <Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1574\Principal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedTeaml.cs" />
@@ -1784,6 +1785,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1388\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnums.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1574\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1776\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-05-15 18:47:57
|
Revision: 4317
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4317&view=rev
Author: fabiomaulo
Date: 2009-05-15 18:47:52 +0000 (Fri, 15 May 2009)
Log Message:
-----------
NH-1264 fixed in some moment in the past
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Name.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Fixture.cs 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,79 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1264
+{
+ [TestFixture]
+ public class Fixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"NHSpecificTest.NH1264.Passenger.hbm.xml", "NHSpecificTest.NH1264.Reservation.hbm.xml",}; }
+ }
+
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (ISession s = OpenSession())
+ {
+ s.Delete("from Reservation r");
+ s.Delete("from Passenger p");
+ s.Flush();
+ }
+ }
+
+ [Test]
+ public void EagerFetchAnomaly()
+ {
+ ISession s = OpenSession();
+ ITransaction t = s.BeginTransaction();
+
+ var mickey = new Passenger();
+ mickey.Name = new Name();
+ mickey.Name.First = "Mickey";
+ mickey.Name.Last = "Mouse";
+ mickey.FrequentFlyerNumber = "1234";
+ s.Save(mickey);
+
+ var reservation = new Reservation();
+ reservation.ConfirmationNumber = "11111111111111";
+ reservation.Passengers.Add(mickey);
+ mickey.Reservation = reservation;
+ s.Save(reservation);
+
+ t.Commit();
+ s.Close();
+
+ s = OpenSession();
+
+ DetachedCriteria dc = DetachedCriteria.For<Reservation>().SetFetchMode("Passengers", FetchMode.Eager);
+
+ dc.CreateCriteria("Passengers").Add(Property.ForName("FrequentFlyerNumber").Eq("1234"));
+
+ IList<Reservation> results = dc.GetExecutableCriteria(s).List<Reservation>();
+
+ s.Close();
+
+ Assert.AreEqual(1, results.Count);
+ foreach (var r in results)
+ {
+ Assert.AreEqual(1, r.Passengers.Count);
+ }
+
+ s = OpenSession();
+ t = s.BeginTransaction();
+
+ s.Delete(reservation);
+
+ t.Commit();
+ s.Close();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Name.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Name.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Name.cs 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,31 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1264
+{
+ public class Name
+ {
+ private string first;
+ private string last;
+ private string display;
+
+ public string First
+ {
+ get { return first; }
+ set { first = value; }
+ }
+
+ public string Last
+ {
+ get { return last; }
+ set { last = value; }
+ }
+
+ public string Display
+ {
+ get { return display ?? first + " " + last; }
+ set { display = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.cs 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,41 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1264
+{
+ public class Passenger
+ {
+ private int id;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ private Name name;
+
+ public Name Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ private string frequentFlyerNumber;
+
+ public string FrequentFlyerNumber
+ {
+ get { return frequentFlyerNumber; }
+ set { frequentFlyerNumber = value; }
+ }
+
+ private Reservation reservation;
+
+ public Reservation Reservation
+ {
+ get { return reservation; }
+ set { reservation = value; }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Passenger.hbm.xml 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1264"
+ default-lazy="false">
+
+ <class name="Passenger">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="FrequentFlyerNumber" />
+ <many-to-one name="Reservation" column="reservation_id" class="Reservation"/>
+ <component name="Name" class="Name">
+ <property name="First" />
+ <property name="Last" />
+ </component>
+ </class>
+
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.cs 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,44 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1264
+{
+ public class Reservation
+ {
+ private IList<Passenger> passengers;
+
+ private int id;
+
+ public int Id
+ {
+ get { return id; }
+ set { id = value; }
+ }
+
+ private string confirmationNumber;
+
+ public string ConfirmationNumber
+ {
+ get { return confirmationNumber; }
+ set { confirmationNumber = value; }
+ }
+
+ public IList<Passenger> Passengers
+ {
+ get
+ {
+ if (passengers == null)
+ {
+ passengers = new List<Passenger>();
+ }
+ return passengers;
+ }
+
+ private set
+ {
+ passengers = value;
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1264/Reservation.hbm.xml 2009-05-15 18:47:52 UTC (rev 4317)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1264"
+ default-lazy="false">
+
+ <class name="Reservation">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="ConfirmationNumber" />
+
+ <bag name="Passengers">
+ <key column="Reservation_id"/>
+ <one-to-many class="Passenger"/>
+ </bag>
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 16:38:45 UTC (rev 4316)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 18:47:52 UTC (rev 4317)
@@ -331,6 +331,10 @@
<Compile Include="MappingTest\Wicked.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
+ <Compile Include="NHSpecificTest\NH1264\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1264\Name.cs" />
+ <Compile Include="NHSpecificTest\NH1264\Passenger.cs" />
+ <Compile Include="NHSpecificTest\NH1264\Reservation.cs" />
<Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1574\Principal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" />
@@ -1787,6 +1791,8 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1264\Passenger.hbm.xml" />
+ <EmbeddedResource Include="NHSpecificTest\NH1264\Reservation.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1775\Member.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1388\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\ElementsEnums\SimpleWithEnums.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-05-15 20:39:19
|
Revision: 4319
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4319&view=rev
Author: fabiomaulo
Date: 2009-05-15 20:39:11 +0000 (Fri, 15 May 2009)
Log Message:
-----------
Fixed NH-1343 (by the new parser)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Product.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/ProductFixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Mappings.hbm.xml 2009-05-15 20:39:11 UTC (rev 4319)
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1343">
+
+ <class name="OrderLine">
+ <id name ="Id">
+ <generator class="native" />
+ </id>
+
+ <many-to-one name="Product" class="Product" column="ProductID" />
+
+ <property name="Description"/>
+ </class>
+
+ <class name="Product">
+ <id name ="Id">
+ <generator class="native" />
+ </id>
+ <property name="Description"/>
+ </class>
+
+ <query name="GetLinesForProduct">
+ from OrderLine ol
+ where Product = :product
+ </query>
+
+ <query name="GetLinesForProductWithAlias">
+ from OrderLine ol
+ where ol.Product = :product
+ </query>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/OrderLine.cs 2009-05-15 20:39:11 UTC (rev 4319)
@@ -0,0 +1,19 @@
+namespace NHibernate.Test.NHSpecificTest.NH1343
+{
+ public class OrderLine
+ {
+ protected OrderLine() {}
+
+ public OrderLine(string description, Product product)
+ {
+ Description = description;
+ Product = product;
+ }
+
+ public virtual int Id { get; private set; }
+
+ public virtual string Description { get; set; }
+
+ public virtual Product Product { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Product.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Product.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/Product.cs 2009-05-15 20:39:11 UTC (rev 4319)
@@ -0,0 +1,16 @@
+namespace NHibernate.Test.NHSpecificTest.NH1343
+{
+ public class Product
+ {
+ protected Product() {}
+
+ public Product(string description)
+ {
+ Description = description;
+ }
+
+ public virtual int Id { get; set; }
+
+ public virtual string Description { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/ProductFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/ProductFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1343/ProductFixture.cs 2009-05-15 20:39:11 UTC (rev 4319)
@@ -0,0 +1,57 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1343
+{
+ [TestFixture]
+ public class ProductFixture : BugTestCase
+ {
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Delete("from OrderLine");
+ session.Delete("from Product");
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void ProductQueryPassesParsingButFails()
+ {
+ Product product1 = new Product("product1");
+ OrderLine orderLine = new OrderLine("1", product1);
+
+ using (ISession session = OpenSession())
+ {
+ session.Save(product1);
+ session.Save(orderLine);
+ session.Flush();
+
+ IQuery query = session.GetNamedQuery("GetLinesForProduct");
+ query.SetParameter("product", product1);
+ IList<OrderLine> list = query.List<OrderLine>();
+ Assert.AreEqual(1, list.Count);
+ }
+ }
+
+ [Test]
+ public void ProductQueryPassesAndExecutesRightIfPuttingAlias()
+ {
+ Product product1 = new Product("product1");
+ OrderLine orderLine = new OrderLine("1", product1);
+
+ using (ISession session = OpenSession())
+ {
+ session.Save(product1);
+ session.Save(orderLine);
+ session.Flush();
+
+ IQuery query = session.GetNamedQuery("GetLinesForProductWithAlias");
+ query.SetParameter("product", product1);
+ IList<OrderLine> list = query.List<OrderLine>();
+ Assert.AreEqual(1, list.Count);
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 20:28:58 UTC (rev 4318)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 20:39:11 UTC (rev 4319)
@@ -335,6 +335,9 @@
<Compile Include="NHSpecificTest\NH1264\Name.cs" />
<Compile Include="NHSpecificTest\NH1264\Passenger.cs" />
<Compile Include="NHSpecificTest\NH1264\Reservation.cs" />
+ <Compile Include="NHSpecificTest\NH1343\OrderLine.cs" />
+ <Compile Include="NHSpecificTest\NH1343\Product.cs" />
+ <Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" />
<Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1574\Principal.cs" />
<Compile Include="NHSpecificTest\NH1574\SpecializedPrincipal.cs" />
@@ -1791,6 +1794,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1343\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1264\Passenger.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1264\Reservation.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1775\Member.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-05-15 20:55:19
|
Revision: 4320
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4320&view=rev
Author: fabiomaulo
Date: 2009-05-15 20:55:13 +0000 (Fri, 15 May 2009)
Log Message:
-----------
Preparing test to work with different mappings
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/AbstractIntEnumsBagFixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/AbstractIntEnumsBagFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/AbstractIntEnumsBagFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/AbstractIntEnumsBagFixture.cs 2009-05-15 20:55:13 UTC (rev 4320)
@@ -0,0 +1,41 @@
+using NUnit.Framework;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.ElementsEnums
+{
+ public abstract class AbstractIntEnumsBagFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ [Test]
+ [Description("Should load the list of enums (NH-1772)")]
+ public void LoadEnums()
+ {
+ object savedId;
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ savedId = s.Save(new SimpleWithEnums { Things = new List<Something> { Something.B, Something.C, Something.D, Something.E } });
+ s.Transaction.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ var swe = s.Get<SimpleWithEnums>(savedId);
+ Assert.That(swe.Things, Is.EqualTo(new[] { Something.B, Something.C, Something.D, Something.E }));
+ s.Transaction.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (s.BeginTransaction())
+ {
+ s.Delete("from SimpleWithEnums");
+ s.Transaction.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs 2009-05-15 20:39:11 UTC (rev 4319)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/ElementsEnums/IntEnumsBagFixture.cs 2009-05-15 20:55:13 UTC (rev 4320)
@@ -1,48 +1,14 @@
using System.Collections;
-using System.Collections.Generic;
using NUnit.Framework;
namespace NHibernate.Test.NHSpecificTest.ElementsEnums
{
[TestFixture]
- public class IntEnumsBagFixture : TestCase
+ public class IntEnumsBagFixture : AbstractIntEnumsBagFixture
{
protected override IList Mappings
{
get { return new[] { "NHSpecificTest.ElementsEnums.SimpleWithEnums.hbm.xml" }; }
}
-
- protected override string MappingsAssembly
- {
- get { return "NHibernate.Test"; }
- }
-
- [Test]
- [Description("Should load the list of enums (NH-1772)")]
- public void LoadEnums()
- {
- object savedId;
- using (ISession s = OpenSession())
- using (s.BeginTransaction())
- {
- savedId = s.Save(new SimpleWithEnums { Things = new List<Something> { Something.B, Something.C, Something.D, Something.E } });
- s.Transaction.Commit();
- }
-
- using (ISession s = OpenSession())
- using (s.BeginTransaction())
- {
- var swe = s.Get<SimpleWithEnums>(savedId);
- Assert.That(swe.Things, Is.EqualTo(new[] {Something.B, Something.C, Something.D, Something.E}));
- s.Transaction.Commit();
- }
-
- using (ISession s = OpenSession())
- using (s.BeginTransaction())
- {
- s.Delete("from SimpleWithEnums");
- s.Transaction.Commit();
- }
- }
}
}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 20:39:11 UTC (rev 4319)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-15 20:55:13 UTC (rev 4320)
@@ -329,6 +329,7 @@
<Compile Include="HQL\BaseFunctionFixture.cs" />
<Compile Include="MappingTest\NonReflectiveBinderFixture.cs" />
<Compile Include="MappingTest\Wicked.cs" />
+ <Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
<Compile Include="NHSpecificTest\NH1264\Fixture.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-05-17 20:36:10
|
Revision: 4334
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4334&view=rev
Author: tehlike
Date: 2009-05-17 20:36:05 +0000 (Sun, 17 May 2009)
Log Message:
-----------
Adding tests for NH-1159 proving it is not an issue.
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Contact.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/ContactTitle.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/HibernateInterceptor.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Contact.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Contact.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Contact.cs 2009-05-17 20:36:05 UTC (rev 4334)
@@ -0,0 +1,129 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1159
+{
+ [Serializable]
+ public partial class Contact
+ {
+
+ private bool isChanged;
+ private Int64 id;
+ private string forename;
+ private string surname;
+ private string preferredname;
+
+ public Contact()
+ {
+ this.id = 0;
+ this.forename = String.Empty;
+ this.surname = String.Empty;
+ this.preferredname = String.Empty;
+ }
+
+ public Contact(
+ string forename,
+ string surname)
+ : this()
+ {
+ this.forename = forename;
+ this.surname = surname;
+ this.preferredname = String.Empty;
+ }
+
+
+ #region Public Properties
+
+ public virtual Int64 Id
+ {
+ get { return id; }
+ set
+ {
+ isChanged |= (id != value);
+ id = value;
+ }
+
+ }
+
+ public virtual string Forename
+ {
+ get { return forename; }
+
+ set
+ {
+ if (value == null)
+ throw new ArgumentOutOfRangeException("Null value not allowed for Forename", value, "null");
+
+ if (value.Length > 50)
+ throw new ArgumentOutOfRangeException("Invalid value for Forename", value, value.ToString());
+
+ isChanged |= (forename != value); forename = value;
+ }
+ }
+
+ public virtual string Surname
+ {
+ get { return surname; }
+
+ set
+ {
+ if (value == null)
+ throw new ArgumentOutOfRangeException("Null value not allowed for Surname", value, "null");
+
+ if (value.Length > 50)
+ throw new ArgumentOutOfRangeException("Invalid value for Surname", value, value.ToString());
+
+ isChanged |= (surname != value); surname = value;
+ }
+ }
+
+ public virtual string PreferredName
+ {
+ get { return preferredname; }
+
+ set
+ {
+ if (value != null && value.Length > 50)
+ throw new ArgumentOutOfRangeException("Invalid value for PreferredName", value, value.ToString());
+
+ isChanged |= (preferredname != value); preferredname = value;
+ }
+ }
+
+ /// <summary>
+ /// Returns whether or not the object has changed it's values.
+ /// </summary>
+ public virtual bool IsChanged
+ {
+ get { return isChanged; }
+ }
+
+ #endregion
+
+ #region Equals And HashCode Overrides
+ /// <summary>
+ /// local implementation of Equals based on unique value members
+ /// </summary>
+ public override bool Equals(object obj)
+ {
+ if (this == obj) return true;
+ if ((obj == null) || (obj.GetType() != this.GetType())) return false;
+ Contact castObj = (Contact)obj;
+ return (castObj != null) &&
+ (this.id == castObj.Id);
+ }
+
+ /// <summary>
+ /// local implementation of GetHashCode based on unique value members
+ /// </summary>
+ public override int GetHashCode()
+ {
+
+ int hash = 57;
+ hash = 27 * hash * id.GetHashCode();
+ return hash;
+ }
+ #endregion
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/ContactTitle.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/ContactTitle.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/ContactTitle.cs 2009-05-17 20:36:05 UTC (rev 4334)
@@ -0,0 +1,135 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1159
+{
+ /// <summary>
+ /// Generated by MyGeneration using the NHibernate Object Mapping template
+ /// </summary>
+ [Serializable]
+ public partial class ContactTitle
+ {
+
+ #region Private Members
+ private bool isChanged;
+
+ private Int64 id;
+ private IList contactList;
+ private string descr;
+ #endregion
+
+ #region Default ( Empty ) Class Constuctor
+ /// <summary>
+ /// default constructor
+ /// </summary>
+ public ContactTitle()
+ {
+ id = 0;
+ contactList = new ArrayList();
+ descr = String.Empty;
+ }
+ #endregion // End of Default ( Empty ) Class Constuctor
+
+ #region Required Fields Only Constructor
+ /// <summary>
+ /// required (not null) fields only constructor
+ /// </summary>
+ public ContactTitle(
+ string descr)
+ : this()
+ {
+ this.descr = descr;
+ }
+ #endregion // End Required Fields Only Constructor
+
+ #region Public Properties
+
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual Int64 Id
+ {
+ get { return id; }
+ set
+ {
+ isChanged |= (id != value);
+ id = value;
+ }
+
+ }
+
+ public virtual IList ContactList
+ {
+ get
+ {
+ return contactList;
+ }
+ set
+ {
+ contactList = value;
+ }
+ }
+
+ /// <summary>
+ ///
+ /// </summary>
+ public virtual string Descr
+ {
+ get { return descr; }
+
+ set
+ {
+ if (value == null)
+ throw new ArgumentOutOfRangeException("Null value not allowed for Descr", value, "null");
+
+ if (value.Length > 50)
+ throw new ArgumentOutOfRangeException("Invalid value for Descr", value, value.ToString());
+
+ isChanged |= (descr != value); descr = value;
+ }
+ }
+
+ /// <summary>
+ /// Returns whether or not the object has changed it's values.
+ /// </summary>
+ public virtual bool IsChanged
+ {
+ get { return isChanged; }
+ }
+
+ #endregion
+
+ #region Equals And HashCode Overrides
+ /// <summary>
+ /// local implementation of Equals based on unique value members
+ /// </summary>
+ public override bool Equals(object obj)
+ {
+ if (this == obj) return true;
+ if ((obj == null) || (obj.GetType() != this.GetType())) return false;
+ ContactTitle castObj = (ContactTitle)obj;
+ return (castObj != null) &&
+ (this.id == castObj.Id);
+ }
+
+ /// <summary>
+ /// local implementation of GetHashCode based on unique value members
+ /// </summary>
+ public override int GetHashCode()
+ {
+
+ int hash = 57;
+ hash = 27 * hash * id.GetHashCode();
+ return hash;
+ }
+ #endregion
+
+ public override string ToString()
+ {
+ return id.ToString() + " " + descr;
+ }
+ }
+
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Fixture.cs 2009-05-17 20:36:05 UTC (rev 4334)
@@ -0,0 +1,128 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1159
+{
+ [TestFixture]
+ public class Fixture:BugTestCase
+ {
+
+ protected override void OnSetUp()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ Contact c=new Contact{Id=1,Forename ="David",Surname="Bates",PreferredName="Davey"};
+ session.Save(c);
+ tran.Commit();
+ }
+ HibernateInterceptor.CallCount = 0;
+
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = OpenSession())
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ session.Delete("from Contact");
+ tran.Commit();
+ }
+ }
+
+ [Test]
+ public void DoesNotFlushWithCriteriaWithCommit()
+ {
+ using (ISession session = OpenSession(new HibernateInterceptor()))
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ session.FlushMode = FlushMode.Commit;
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(0));
+ Contact contact = session.Get<Contact>((Int64)1);
+ contact.PreferredName = "Updated preferred name";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ contact.Forename = "Updated forename";
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ ICriteria query = session.CreateCriteria(typeof(ContactTitle));
+ query.Add(Expression.Eq("Id", (Int64)1));
+ query.UniqueResult<ContactTitle>();
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ contact.Surname = "Updated surname";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(2));
+
+ session.SaveOrUpdateCopy(contact);
+ }
+ }
+ [Test]
+ public void DoesNotFlushWithCriteriaWithNever()
+ {
+ using (ISession session = OpenSession(new HibernateInterceptor()))
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ session.FlushMode = FlushMode.Never;
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(0));
+ Contact contact = session.Get<Contact>((Int64)1);
+ contact.PreferredName = "Updated preferred name";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ contact.Forename = "Updated forename";
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ ICriteria query = session.CreateCriteria(typeof(ContactTitle));
+ query.Add(Expression.Eq("Id", (Int64)1));
+ query.UniqueResult<ContactTitle>();
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ contact.Surname = "Updated surname";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(2));
+
+ session.SaveOrUpdateCopy(contact);
+ }
+ }
+ [Test]
+ public void DoesNotFlushWithCriteriaWithAuto()
+ {
+ using (ISession session = OpenSession(new HibernateInterceptor()))
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ session.FlushMode = FlushMode.Auto;
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(0));
+
+ Contact contact = session.Get<Contact>((Int64)1);
+ contact.PreferredName = "Updated preferred name";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ contact.Forename = "Updated forename";
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(1));
+
+ ICriteria query = session.CreateCriteria(typeof(ContactTitle));
+ query.Add(Expression.Eq("Id", (Int64)1));
+ query.UniqueResult<ContactTitle>();
+
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(2));
+
+ contact.Surname = "Updated surname";
+ session.Flush();
+ Assert.That(HibernateInterceptor.CallCount, Is.EqualTo(3));
+
+ session.SaveOrUpdateCopy(contact);
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/HibernateInterceptor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/HibernateInterceptor.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/HibernateInterceptor.cs 2009-05-17 20:36:05 UTC (rev 4334)
@@ -0,0 +1,16 @@
+using System;
+using NHibernate.Type;
+
+namespace NHibernate.Test.NHSpecificTest.NH1159
+{
+ public class HibernateInterceptor : EmptyInterceptor
+ {
+ public static int CallCount = 0;
+ public override bool OnFlushDirty(object entity, object id, object[] currentState, object[] previousState, string[] propertyNames, IType[] types)
+ {
+ CallCount++;
+ return false;
+ }
+ }
+
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1159/Mappings.hbm.xml 2009-05-17 20:36:05 UTC (rev 4334)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1159">
+ <class name="Contact" table="Contact">
+ <id name="Id" column="id" type="Int64" unsaved-value="0">
+ <generator class="assigned"/>
+ </id>
+ <property column="forename" type="String" name="Forename" not-null="true" length="50" />
+ <property column="surname" type="String" name="Surname" not-null="true" length="50" />
+ <property column="preferredName" type="String" name="PreferredName" length="50" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-17 16:35:57 UTC (rev 4333)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-17 20:36:05 UTC (rev 4334)
@@ -336,6 +336,10 @@
<Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
<Compile Include="NHSpecificTest\NH1093\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1093\SimpleCached.cs" />
+ <Compile Include="NHSpecificTest\NH1159\Contact.cs" />
+ <Compile Include="NHSpecificTest\NH1159\ContactTitle.cs" />
+ <Compile Include="NHSpecificTest\NH1159\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1159\HibernateInterceptor.cs" />
<Compile Include="NHSpecificTest\NH1264\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1264\Name.cs" />
<Compile Include="NHSpecificTest\NH1264\Passenger.cs" />
@@ -1806,6 +1810,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1159\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1093\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1714\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1763\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-05-17 21:30:33
|
Revision: 4335
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4335&view=rev
Author: tehlike
Date: 2009-05-17 21:30:26 +0000 (Sun, 17 May 2009)
Log Message:
-----------
Adding tests for NH-1747 by Anne Epstein
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Classes.cs 2009-05-17 21:30:26 UTC (rev 4335)
@@ -0,0 +1,32 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1747
+{
+ public class Payment
+ {
+ private Int32 id;
+ public virtual Int32 Id { get { return id; } set { id = value; } }
+
+ private Decimal amount;
+ public virtual Decimal Amount { get { return amount; } set { amount = value; } }
+ private PaymentBatch paymentBatch;
+ public virtual PaymentBatch PaymentBatch { get { return paymentBatch; } set { paymentBatch = value; } }
+ }
+
+ public class PaymentBatch
+ {
+ private Int32 id;
+ public virtual Int32 Id { get { return id; } set { id = value; } }
+
+ private IList<Payment> payments = new List<Payment>();
+ public virtual IList<Payment> Payments { get { return payments; } }
+
+ public virtual void AddPayment(Payment p)
+ {
+ payments.Add(p);
+ p.PaymentBatch = this;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Fixture.cs 2009-05-17 21:30:26 UTC (rev 4335)
@@ -0,0 +1,49 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1747
+{
+ [TestFixture,Ignore]
+ public class JoinTraversalTest : BugTestCase
+ {
+
+ protected override void OnSetUp()
+ {
+ base.OnSetUp();
+ using (ISession session = OpenSession())
+ {
+ var payment = new Payment { Amount = 5m, Id = 1 };
+ var paymentBatch = new PaymentBatch { Id = 3 };
+ paymentBatch.AddPayment(payment);
+ session.Save(paymentBatch);
+ session.Save(payment);
+ session.Flush();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ base.OnTearDown();
+ using (ISession session = OpenSession())
+ {
+ var hql = "from System.Object";
+ session.Delete(hql);
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void TraversingBagToJoinChildElementShouldWork()
+ {
+ using (ISession session = OpenSession())
+ {
+ var paymentBatch = session.Get<PaymentBatch>(3);
+ Assert.AreEqual(1, paymentBatch.Payments.Count);
+
+ }
+ }
+ }
+
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1747/Mappings.hbm.xml 2009-05-17 21:30:26 UTC (rev 4335)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1747" default-access="field.camelcase">
+ <class name="Payment" table="PAYMENT">
+ <id name="Id" type="Int32" column="PAYMENT_ID">
+ <generator class="assigned"/>
+ </id>
+ <property name="Amount" column="AMOUNT"/>
+ <join table="CREDIT_PAYMENT">
+ <key column="PAYMENTID" />
+ <many-to-one name="PaymentBatch" column="PaymentBatchFK_ID"/>
+ </join>
+ </class>
+
+ <class name="PaymentBatch" table="PAYMENTBATCH">
+ <id name="Id" type="Int32" column="PAYMENTBATCH_ID">
+ <generator class="assigned"/>
+ </id>
+
+ <bag name="Payments" inverse="true">
+ <key column="PaymentBatchFK_ID" />
+ <one-to-many class="Payment"/>
+ </bag>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-17 20:36:05 UTC (rev 4334)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-17 21:30:26 UTC (rev 4335)
@@ -407,6 +407,8 @@
<Compile Include="NHSpecificTest\NH1741\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1742\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1742\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1747\Classes.cs" />
+ <Compile Include="NHSpecificTest\NH1747\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1760\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1760\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1763\DomainClass.cs" />
@@ -1810,6 +1812,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1747\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1159\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1093\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1714\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-05-18 05:31:21
|
Revision: 4336
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4336&view=rev
Author: fabiomaulo
Date: 2009-05-18 05:31:15 +0000 (Mon, 18 May 2009)
Log Message:
-----------
Test from H3.1 (not supported in .NET so far)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employee.cs
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employment.cs
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/LazyOneToOneTest.cs
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.cs
trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employee.cs 2009-05-18 05:31:15 UTC (rev 4336)
@@ -0,0 +1,26 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.LazyOneToOne
+{
+ public class Employee
+ {
+ protected Employee()
+ {
+ Employments = new List<Employment>();
+ }
+
+ public Employee(Person person)
+ : this()
+ {
+ Person = person;
+ PersonName = person.Name;
+ Person.Employee = this;
+ }
+
+ public virtual string PersonName { get; protected set; }
+
+ public virtual Person Person { get; protected set; }
+
+ public virtual ICollection<Employment> Employments { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employment.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employment.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Employment.cs 2009-05-18 05:31:15 UTC (rev 4336)
@@ -0,0 +1,50 @@
+using System;
+
+namespace NHibernate.Test.LazyOneToOne
+{
+ public class Employment
+ {
+ protected Employment() { }
+ public Employment(Employee e, String org)
+ {
+ PersonName = e.PersonName;
+ OrganizationName = org;
+ StartDate = DateTime.Today.AddDays(-1);
+ e.Employments.Add(this);
+ }
+
+ public virtual string PersonName { get; protected set; }
+
+ public virtual string OrganizationName { get; protected set; }
+
+ public virtual DateTime? StartDate { get; set; }
+
+ public virtual DateTime? EndDate { get; set; }
+
+ public override bool Equals(object obj)
+ {
+ return Equals(obj as Employment);
+ }
+
+ public virtual bool Equals(Employment other)
+ {
+ if (ReferenceEquals(null, other))
+ {
+ return false;
+ }
+ if (ReferenceEquals(this, other))
+ {
+ return true;
+ }
+ return Equals(other.PersonName, PersonName) && Equals(other.OrganizationName, OrganizationName);
+ }
+
+ public override int GetHashCode()
+ {
+ unchecked
+ {
+ return ((PersonName != null ? PersonName.GetHashCode() : 0) * 397) ^ (OrganizationName != null ? OrganizationName.GetHashCode() : 0);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/LazyOneToOneTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/LazyOneToOneTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/LazyOneToOneTest.cs 2009-05-18 05:31:15 UTC (rev 4336)
@@ -0,0 +1,85 @@
+using System;
+using System.Collections;
+using NHibernate.Intercept;
+using NUnit.Framework;
+using Environment = NHibernate.Cfg.Environment;
+
+namespace NHibernate.Test.LazyOneToOne
+{
+ [TestFixture, Ignore("Not supported.")]
+ public class LazyOneToOneTest : TestCase
+ {
+ protected override IList Mappings
+ {
+ get { return new[] {"LazyOneToOne.Person.hbm.xml"}; }
+ }
+
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override bool AppliesTo(Dialect.Dialect dialect)
+ {
+ // this test work only with Field interception (NH-1618)
+ return FieldInterceptionHelper.IsInstrumented( new Person() );
+ }
+ protected override void Configure(Cfg.Configuration configuration)
+ {
+ cfg.SetProperty(Environment.MaxFetchDepth, "2");
+ cfg.SetProperty(Environment.UseSecondLevelCache, "false");
+ }
+
+ protected override string CacheConcurrencyStrategy
+ {
+ get { return null; }
+ }
+
+ [Test]
+ public void Lazy()
+ {
+ ISession s = OpenSession();
+ ITransaction t = s.BeginTransaction();
+ var p = new Person {Name = "Gavin"};
+ var p2 = new Person {Name = "Emmanuel"};
+ var e = new Employee(p);
+ new Employment(e, "JBoss");
+ var old = new Employment(e, "IFA") {EndDate = DateTime.Today};
+ s.Persist(p);
+ s.Persist(p2);
+ t.Commit();
+ s.Close();
+
+ s = OpenSession();
+ t = s.BeginTransaction();
+ p = s.CreateQuery("from Person where name='Gavin'").UniqueResult<Person>();
+ //Assert.That(!NHibernateUtil.IsPropertyInitialized(p, "Employee"));
+
+ Assert.That(p.Employee.Person, Is.SameAs(p));
+ Assert.That(NHibernateUtil.IsInitialized(p.Employee.Employments));
+ Assert.That(p.Employee.Employments.Count, Is.EqualTo(1));
+
+ p2 = s.CreateQuery("from Person where name='Emmanuel'").UniqueResult<Person>();
+ Assert.That(p2.Employee, Is.Null);
+ t.Commit();
+ s.Close();
+
+ s = OpenSession();
+ t = s.BeginTransaction();
+ p = s.Get<Person>("Gavin");
+ //Assert.That(!NHibernateUtil.IsPropertyInitialized(p, "Employee"));
+
+ Assert.That(p.Employee.Person, Is.SameAs(p));
+ Assert.That(NHibernateUtil.IsInitialized(p.Employee.Employments));
+ Assert.That(p.Employee.Employments.Count, Is.EqualTo(1));
+
+ p2 = s.Get<Person>("Emmanuel");
+ Assert.That(p2.Employee, Is.Null);
+ s.Delete(p2);
+ s.Delete(old);
+ s.Delete(p);
+ t.Commit();
+ s.Close();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.cs 2009-05-18 05:31:15 UTC (rev 4336)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.LazyOneToOne
+{
+ public class Person
+ {
+ public virtual string Name { get; set; }
+ public virtual Employee Employee { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyOneToOne/Person.hbm.xml 2009-05-18 05:31:15 UTC (rev 4336)
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.LazyOneToOne">
+
+ <class name="Person">
+ <id name="Name"/>
+ <one-to-one name="Employee" lazy="no-proxy" cascade="persist,delete"/>
+ </class>
+
+ <class name="Employee">
+ <id name="PersonName"/>
+ <one-to-one name="Person" lazy="no-proxy"/>
+ <bag name="Employments" inverse="true" fetch="join" lazy="false"
+ where="EndDate is null"
+ cascade="persist,delete">
+ <key column="PersonName"/>
+ <one-to-many class="Employment"/>
+ </bag>
+ </class>
+
+ <class name="Employment">
+ <composite-id>
+ <key-property name="PersonName"/>
+ <key-property name="OrganizationName"/>
+ </composite-id>
+ <property name="StartDate" update="false"/>
+ <property name="EndDate"/>
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-17 21:30:26 UTC (rev 4335)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-18 05:31:15 UTC (rev 4336)
@@ -327,6 +327,10 @@
<Compile Include="HQL\Ast\WithClauseFixture.cs" />
<Compile Include="HQL\Ast\Zoo.cs" />
<Compile Include="HQL\BaseFunctionFixture.cs" />
+ <Compile Include="LazyOneToOne\Employee.cs" />
+ <Compile Include="LazyOneToOne\Employment.cs" />
+ <Compile Include="LazyOneToOne\LazyOneToOneTest.cs" />
+ <Compile Include="LazyOneToOne\Person.cs" />
<Compile Include="MappingTest\NonReflectiveBinderFixture.cs" />
<Compile Include="MappingTest\Wicked.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" />
@@ -1812,6 +1816,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="LazyOneToOne\Person.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1747\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1159\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1093\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <dar...@us...> - 2009-05-19 13:00:06
|
Revision: 4349
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4349&view=rev
Author: darioquintana
Date: 2009-05-19 12:59:37 +0000 (Tue, 19 May 2009)
Log Message:
-----------
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/LazyProperty/
trunk/nhibernate/src/NHibernate.Test/LazyProperty/Book.cs
trunk/nhibernate/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs
trunk/nhibernate/src/NHibernate.Test/LazyProperty/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/LazyProperty/Book.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyProperty/Book.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyProperty/Book.cs 2009-05-19 12:59:37 UTC (rev 4349)
@@ -0,0 +1,16 @@
+namespace NHibernate.Test.LazyProperty
+{
+ public class Book
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+
+ private string _aLotOfText;
+
+ public virtual string ALotOfText
+ {
+ get { return _aLotOfText; }
+ set { _aLotOfText = value; }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyProperty/LazyPropertyFixture.cs 2009-05-19 12:59:37 UTC (rev 4349)
@@ -0,0 +1,67 @@
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.LazyProperty
+{
+ [TestFixture]
+ public class LazyPropertyFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"LazyProperty.Mappings.hbm.xml"}; }
+ }
+
+ public void LoadData()
+ {
+ Book b = new Book
+ {
+ Name = "some name",
+ ALotOfText = "a lot of text ..."
+ };
+
+ using(var s = OpenSession())
+ using(var tx = s.BeginTransaction())
+ {
+ s.Persist(b);
+ tx.Commit();
+ }
+
+ }
+
+ public void CleanUp()
+ {
+ using (var s = OpenSession())
+ using (var tx = s.BeginTransaction())
+ {
+ Assert.That(s.CreateSQLQuery("delete from Book").ExecuteUpdate(), Is.EqualTo(1));
+ tx.Commit();
+ }
+ }
+
+ [Test,Ignore("Not supported yet, waiting for a field-interceptor provider, probably Linfu.")]
+ public void PropertyLoadedNotInitialized()
+ {
+ LoadData();
+
+ using(ISession s = OpenSession())
+ {
+ var book = s.Load<Book>(1);
+
+ Assert.False(NHibernateUtil.IsPropertyInitialized(book, "Id"));
+ Assert.False(NHibernateUtil.IsPropertyInitialized(book, "Name"));
+ Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"));
+ var name = book.Name;
+ Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Id"));
+ Assert.True(NHibernateUtil.IsPropertyInitialized(book, "Name"));
+ Assert.False(NHibernateUtil.IsPropertyInitialized(book, "ALotOfText"));
+ }
+
+ CleanUp();
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/LazyProperty/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/LazyProperty/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/LazyProperty/Mappings.hbm.xml 2009-05-19 12:59:37 UTC (rev 4349)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.LazyProperty">
+
+ <class name="Book">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name" />
+ <property name="ALotOfText" lazy="true" />
+ </class>
+
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-19 12:04:26 UTC (rev 4348)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-19 12:59:37 UTC (rev 4349)
@@ -332,6 +332,8 @@
<Compile Include="LazyOneToOne\Employment.cs" />
<Compile Include="LazyOneToOne\LazyOneToOneTest.cs" />
<Compile Include="LazyOneToOne\Person.cs" />
+ <Compile Include="LazyProperty\Book.cs" />
+ <Compile Include="LazyProperty\LazyPropertyFixture.cs" />
<Compile Include="MappingTest\NonReflectiveBinderFixture.cs" />
<Compile Include="MappingTest\Wicked.cs" />
<Compile Include="NHSpecificTest\ElementsEnums\AbstractIntEnumsBagFixture.cs" />
@@ -1819,6 +1821,7 @@
<EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" />
<EmbeddedResource Include="Ado\VerySimple.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="LazyProperty\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1783\Mappings.hbm.xml" />
<EmbeddedResource Include="LazyOneToOne\Person.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1747\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-05-31 20:53:13
|
Revision: 4394
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4394&view=rev
Author: fabiomaulo
Date: 2009-05-31 20:53:09 +0000 (Sun, 31 May 2009)
Log Message:
-----------
Test for NH-1796 (Can't Reproduce)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Entity.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Entity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Entity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Entity.cs 2009-05-31 20:53:09 UTC (rev 4394)
@@ -0,0 +1,11 @@
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH1796
+{
+ public class Entity
+ {
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual IDictionary DynProps { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Fixture.cs 2009-05-31 20:53:09 UTC (rev 4394)
@@ -0,0 +1,65 @@
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1796
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test]
+ public void Merge()
+ {
+ var entity = new Entity { Name = "Vinnie Luther" };
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(entity);
+ t.Commit();
+ }
+
+ entity.DynProps = new Dictionary<string, object>();
+ entity.DynProps["StrProp"] = "Modified";
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Merge(entity);
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from Entity").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+
+ [Test]
+ public void SaveOrUpdate()
+ {
+ var entity = new Entity { Name = "Vinnie Luther" };
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.SaveOrUpdate(entity);
+ t.Commit();
+ }
+
+ entity.DynProps = new Dictionary<string, object>();
+ entity.DynProps["StrProp"] = "Modified";
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.SaveOrUpdate(entity);
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from Entity").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1796/Mappings.hbm.xml 2009-05-31 20:53:09 UTC (rev 4394)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1796">
+
+ <class name="Entity">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Name"/>
+ <dynamic-component name="DynProps">
+ <property name="StrProp" type="string" />
+ <property name="ValueProp" type="int" />
+ </dynamic-component>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 18:38:56 UTC (rev 4393)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 20:53:09 UTC (rev 4394)
@@ -444,6 +444,8 @@
<Compile Include="NHSpecificTest\NH1792\Product.cs" />
<Compile Include="NHSpecificTest\NH1794\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1794\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1796\Entity.cs" />
+ <Compile Include="NHSpecificTest\NH1796\Fixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1838,6 +1840,7 @@
<EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" />
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1796\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1788\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1794\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-06-01 19:21:27
|
Revision: 4400
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4400&view=rev
Author: fabiomaulo
Date: 2009-06-01 19:21:19 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
Tests only as Examples to understand what happening with PostUpdate
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/
trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/AssertOldStatePostListener.cs
trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs
trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.cs
trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/AssertOldStatePostListener.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/AssertOldStatePostListener.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/AssertOldStatePostListener.cs 2009-06-01 19:21:19 UTC (rev 4400)
@@ -0,0 +1,27 @@
+using log4net;
+using NHibernate.Event;
+
+namespace NHibernate.Test.Events.PostEvents
+{
+ public delegate void AssertionAction(PostUpdateEvent @event);
+
+ public class AssertOldStatePostListener : IPostUpdateEventListener
+ {
+ private readonly AssertionAction assertionDelegate;
+
+ public AssertOldStatePostListener(AssertionAction assertionDelegate)
+ {
+ this.assertionDelegate = assertionDelegate;
+ }
+
+ public const string LogMessage = "PostUpdateEvent called.";
+
+ private static readonly ILog log = LogManager.GetLogger(typeof(AssertOldStatePostListener));
+
+ public void OnPostUpdate(PostUpdateEvent @event)
+ {
+ log.Debug(LogMessage);
+ assertionDelegate(@event);
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/PostUpdateFixture.cs 2009-06-01 19:21:19 UTC (rev 4400)
@@ -0,0 +1,219 @@
+using System.Collections;
+using System.Collections.Generic;
+using NHibernate.Event;
+using NHibernate.Impl;
+using NUnit.Framework;
+
+namespace NHibernate.Test.Events.PostEvents
+{
+ [TestFixture]
+ public class PostUpdateFixture : TestCase
+ {
+ protected override string MappingsAssembly
+ {
+ get { return "NHibernate.Test"; }
+ }
+
+ protected override IList Mappings
+ {
+ get { return new[] {"Events.PostEvents.SimpleEntity.hbm.xml"}; }
+ }
+
+ [Test]
+ public void ImplicitFlush()
+ {
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
+ {
+ new AssertOldStatePostListener(
+ eArgs =>
+ Assert.That(eArgs.OldState, Is.Not.Null))
+ };
+ FillDb();
+ using (var ls = new LogSpy(typeof (AssertOldStatePostListener)))
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ IList<SimpleEntity> l = s.CreateCriteria<SimpleEntity>().List<SimpleEntity>();
+ l[0].Description = "Modified";
+ tx.Commit();
+ }
+ }
+ Assert.That(ls.GetWholeLog(), Text.Contains(AssertOldStatePostListener.LogMessage));
+ }
+
+ DbCleanup();
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
+ }
+
+ [Test]
+ public void ExplicitUpdate()
+ {
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
+ {
+ new AssertOldStatePostListener(
+ eArgs =>
+ Assert.That(eArgs.OldState, Is.Not.Null))
+ };
+ FillDb();
+ using (var ls = new LogSpy(typeof (AssertOldStatePostListener)))
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ IList<SimpleEntity> l = s.CreateCriteria<SimpleEntity>().List<SimpleEntity>();
+ l[0].Description = "Modified";
+ s.Update(l[0]);
+ tx.Commit();
+ }
+ }
+ Assert.That(ls.GetWholeLog(), Text.Contains(AssertOldStatePostListener.LogMessage));
+ }
+
+ DbCleanup();
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
+ }
+
+ [Test]
+ public void WithDetachedObject()
+ {
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
+ {
+ new AssertOldStatePostListener(
+ eArgs =>
+ Assert.That(eArgs.OldState, Is.Not.Null))
+ };
+ FillDb();
+ SimpleEntity toModify;
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ IList<SimpleEntity> l = s.CreateCriteria<SimpleEntity>().List<SimpleEntity>();
+ toModify = l[0];
+ tx.Commit();
+ }
+ }
+ toModify.Description = "Modified";
+ using (var ls = new LogSpy(typeof (AssertOldStatePostListener)))
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Merge(toModify);
+ tx.Commit();
+ }
+ }
+ Assert.That(ls.GetWholeLog(), Text.Contains(AssertOldStatePostListener.LogMessage));
+ }
+
+ DbCleanup();
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
+ }
+
+ [Test]
+ public void UpdateDetachedObject()
+ {
+ // When the update is used directly as method to reattach a entity the OldState is null
+ // that mean that NH should not retrieve info from DB
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
+ {
+ new AssertOldStatePostListener(
+ eArgs =>
+ Assert.That(eArgs.OldState, Is.Null))
+ };
+ FillDb();
+ SimpleEntity toModify;
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ IList<SimpleEntity> l = s.CreateCriteria<SimpleEntity>().List<SimpleEntity>();
+ toModify = l[0];
+ tx.Commit();
+ }
+ }
+ toModify.Description = "Modified";
+ using (var ls = new LogSpy(typeof (AssertOldStatePostListener)))
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Update(toModify);
+ tx.Commit();
+ }
+ }
+ Assert.That(ls.GetWholeLog(), Text.Contains(AssertOldStatePostListener.LogMessage));
+ }
+
+ DbCleanup();
+ ((SessionFactoryImpl) sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
+ }
+
+ [Test]
+ public void UpdateDetachedObjectWithLock()
+ {
+ ((SessionFactoryImpl)sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[]
+ {
+ new AssertOldStatePostListener(
+ eArgs =>
+ Assert.That(eArgs.OldState, Is.Not.Null))
+ };
+ FillDb();
+ SimpleEntity toModify;
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ IList<SimpleEntity> l = s.CreateCriteria<SimpleEntity>().List<SimpleEntity>();
+ toModify = l[0];
+ tx.Commit();
+ }
+ }
+ using (var ls = new LogSpy(typeof(AssertOldStatePostListener)))
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Lock(toModify, LockMode.None);
+ toModify.Description = "Modified";
+ s.Update(toModify);
+ tx.Commit();
+ }
+ }
+ Assert.That(ls.GetWholeLog(), Text.Contains(AssertOldStatePostListener.LogMessage));
+ }
+
+ DbCleanup();
+ ((SessionFactoryImpl)sessions).EventListeners.PostUpdateEventListeners = new IPostUpdateEventListener[0];
+ }
+ private void DbCleanup()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from SimpleEntity").ExecuteUpdate();
+ tx.Commit();
+ }
+ }
+ }
+
+ private void FillDb()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(new SimpleEntity {Description = "Something"});
+ tx.Commit();
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.cs 2009-06-01 19:21:19 UTC (rev 4400)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.Events.PostEvents
+{
+ public class SimpleEntity
+ {
+ public virtual int Id { get; set; }
+ public virtual string Description { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/Events/PostEvents/SimpleEntity.hbm.xml 2009-06-01 19:21:19 UTC (rev 4400)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.Events.PostEvents">
+
+ <class name="SimpleEntity">
+ <id name="Id" type="int">
+ <generator class="hilo" />
+ </id>
+ <property name="Description"/>
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 18:18:23 UTC (rev 4399)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 19:21:19 UTC (rev 4400)
@@ -211,6 +211,9 @@
<Compile Include="Events\Collections\IParentWithCollection.cs" />
<Compile Include="Events\Collections\Values\ParentWithCollectionOfValues.cs" />
<Compile Include="Events\Collections\Values\ValuesBagCollectionEventFixture.cs" />
+ <Compile Include="Events\PostEvents\AssertOldStatePostListener.cs" />
+ <Compile Include="Events\PostEvents\PostUpdateFixture.cs" />
+ <Compile Include="Events\PostEvents\SimpleEntity.cs" />
<Compile Include="ExceptionsTest\PostgresExceptionConverterExample.cs" />
<Compile Include="ExceptionsTest\Group.cs" />
<Compile Include="ExceptionsTest\MSSQLExceptionConverterExample.cs" />
@@ -1847,6 +1850,7 @@
<EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" />
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="Events\PostEvents\SimpleEntity.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1789\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1801\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1796\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-06-01 19:59:02
|
Revision: 4401
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4401&view=rev
Author: fabiomaulo
Date: 2009-06-01 19:58:58 +0000 (Mon, 01 Jun 2009)
Log Message:
-----------
NH-1757 closed as 'Cannot Reproduce'
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/SimpleEntity.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Fixture.cs 2009-06-01 19:58:58 UTC (rev 4401)
@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1757
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test]
+ public void MayBeABug()
+ {
+ using (ISession s = OpenSession())
+ {
+ var query = s.CreateSQLQuery("SELECT SimpleEntity.*, 123 as field_not_in_entitytype FROM SimpleEntity")
+ .AddEntity(typeof(SimpleEntity))
+ .AddScalar("field_not_in_entitytype", NHibernateUtil.Int64);
+ IList<Object[]> result = query.List<Object[]>();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/Mappings.hbm.xml 2009-06-01 19:58:58 UTC (rev 4401)
@@ -0,0 +1,12 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1757">
+
+ <class name="SimpleEntity">
+ <id name="Id" type="int">
+ <generator class="hilo" />
+ </id>
+ <property name="Description"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/SimpleEntity.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/SimpleEntity.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1757/SimpleEntity.cs 2009-06-01 19:58:58 UTC (rev 4401)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.NHSpecificTest.NH1757
+{
+ public class SimpleEntity
+ {
+ public virtual int Id { get; set; }
+ public virtual string Description { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 19:21:19 UTC (rev 4400)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 19:58:58 UTC (rev 4401)
@@ -428,6 +428,8 @@
<Compile Include="NHSpecificTest\NH1747\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1756\Domain.cs" />
<Compile Include="NHSpecificTest\NH1756\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1757\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1757\SimpleEntity.cs" />
<Compile Include="NHSpecificTest\NH1760\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1760\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1763\DomainClass.cs" />
@@ -1850,6 +1852,7 @@
<EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" />
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" />
<EmbeddedResource Include="Events\PostEvents\SimpleEntity.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1789\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1801\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-06-03 04:22:52
|
Revision: 4403
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4403&view=rev
Author: fabiomaulo
Date: 2009-06-03 04:22:51 +0000 (Wed, 03 Jun 2009)
Log Message:
-----------
Example of tree
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/DomainClass.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/SampleTest.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/DomainClass.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/DomainClass.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/DomainClass.cs 2009-06-03 04:22:51 UTC (rev 4403)
@@ -0,0 +1,50 @@
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1531
+{
+ public class Parent
+ {
+ private readonly IList<Child> _children = new List<Child>();
+
+ public int Id { get; set; }
+
+ public IList<Child> Children
+ {
+ get { return _children; }
+ }
+
+ public void AddNewChild()
+ {
+ var c = new Child {Name = "New Child", Parent = this};
+ _children.Add(c);
+ }
+
+ public void DetachAllChildren()
+ {
+ foreach (var c in _children)
+ {
+ c.Parent = null;
+ }
+ _children.Clear();
+ }
+
+ public void AttachNewChild(Child c)
+ {
+ if (c.Parent != null)
+ {
+ c.Parent.Children.Remove(c);
+ }
+ c.Parent = this;
+ _children.Add(c);
+ }
+ }
+
+ public class Child
+ {
+ public int Id { get; set; }
+
+ public string Name { get; set; }
+
+ public Parent Parent { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/Mappings.hbm.xml 2009-06-03 04:22:51 UTC (rev 4403)
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1531"
+ default-lazy="false">
+
+ <class name="Parent">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ <bag name="Children" lazy="true" inverse="true" cascade="all" access="field.camelcase-underscore" >
+ <key column="ParentID" />
+ <one-to-many class="Child"/>
+ </bag>
+ </class>
+
+
+ <class name="Child">
+ <id name="Id">
+ <generator class="assigned" />
+ </id>
+ <property name="Name" column="Name" />
+ <many-to-one name="Parent" column="ParentID" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/SampleTest.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/SampleTest.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1531/SampleTest.cs 2009-06-03 04:22:51 UTC (rev 4403)
@@ -0,0 +1,80 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1531
+{
+ // This test is only an Example to show the wrong mapping in the original issue.
+
+ [TestFixture]
+ public class SampleTest : BugTestCase
+ {
+ private void FillDb()
+ {
+ using (ISession session = OpenSession())
+ {
+ var entity = new Parent {Id = 1};
+ entity.AddNewChild();
+ session.Save(entity);
+
+ var entity2 = new Parent {Id = 2};
+ session.Save(entity2);
+
+ session.Flush();
+ }
+ }
+
+ private void CleanDb()
+ {
+ using (ISession session = OpenSession())
+ {
+ session.Delete("from Parent");
+ session.Flush();
+ }
+ }
+
+ [Test]
+ public void ReparentingShouldNotFail()
+ {
+ FillDb();
+ using (ISession session = OpenSession())
+ {
+ var parent1 = session.Get<Parent>(1);
+ var parent2 = session.Get<Parent>(2);
+
+ Assert.AreEqual(1, parent1.Children.Count);
+ Assert.AreEqual(0, parent2.Children.Count);
+
+ Child p1Child = parent1.Children[0];
+
+ Assert.IsNotNull(p1Child);
+
+ parent1.DetachAllChildren();
+ parent2.AttachNewChild(p1Child);
+
+ session.SaveOrUpdate(parent1);
+ session.SaveOrUpdate(parent2);
+
+ // NHibernate.ObjectDeletedException :
+ // deleted object would be re-saved by cascade (remove deleted object from associations)[NHibernate.Test.NHSpecificTest.NH1531.Child#0]
+
+ session.Flush();
+ }
+
+ using (ISession session = OpenSession())
+ {
+ // should exist only one child
+ var l = session.CreateQuery("from Child").List();
+ Assert.That(l.Count, Is.EqualTo(1));
+ }
+ CleanDb();
+ }
+
+ [Test]
+ public void DeleteParentDeleteChildInCascade()
+ {
+ FillDb();
+ CleanDb();
+
+ // The TestCase is checking the empty db
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-02 23:09:13 UTC (rev 4402)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 04:22:51 UTC (rev 4403)
@@ -364,6 +364,8 @@
<Compile Include="NHSpecificTest\NH1343\Product.cs" />
<Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" />
<Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1531\DomainClass.cs" />
+ <Compile Include="NHSpecificTest\NH1531\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1553\MsSQL\Person.cs" />
<Compile Include="NHSpecificTest\NH1553\MsSQL\SnapshotIsolationUpdateConflictTest.cs" />
<Compile Include="NHSpecificTest\NH1553\MsSQL\SQLUpdateConflictToStaleStateExceptionConverter.cs" />
@@ -1855,6 +1857,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" />
<EmbeddedResource Include="Events\PostEvents\SimpleEntity.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1789\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-06-04 14:15:01
|
Revision: 4408
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4408&view=rev
Author: fabiomaulo
Date: 2009-06-04 13:52:53 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
NH-1507 fixed by new QueryTranslator
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Employee.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Order.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Employee.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Employee.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Employee.cs 2009-06-04 13:52:53 UTC (rev 4408)
@@ -0,0 +1,66 @@
+using System;
+using System.Collections;
+
+namespace NHibernate.Test.NHSpecificTest.NH1507
+{
+ [Serializable]
+ public class Employee
+ {
+ private int _id;
+ private IList nativeOrders;
+
+ public virtual string LastName { get; set; }
+
+ public virtual string FirstName { get; set; }
+
+ public virtual string Title { get; set; }
+
+ public virtual string TitleOfCourtesy { get; set; }
+
+ public virtual DateTime? BirthDate { get; set; }
+
+ public virtual DateTime? HireDate { get; set; }
+
+ public virtual string Address { get; set; }
+
+ public virtual string City { get; set; }
+
+ public virtual string Region { get; set; }
+
+ public virtual string PostalCode { get; set; }
+
+ public virtual string Country { get; set; }
+
+ public virtual string HomePhone { get; set; }
+
+ public virtual string Extension { get; set; }
+
+ public virtual byte[] Photo { get; set; }
+
+ public virtual string Notes { get; set; }
+
+ public virtual int? ReportsTo { get; set; }
+
+ public virtual string PhotoPath { get; set; }
+
+ protected virtual IList orders
+ {
+ get
+ {
+ if (nativeOrders == null)
+ {
+ nativeOrders = new ArrayList();
+ }
+
+ return nativeOrders;
+ }
+ set
+ {
+ if (value != nativeOrders)
+ {
+ nativeOrders = value;
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Fixture.cs 2009-06-04 13:52:53 UTC (rev 4408)
@@ -0,0 +1,112 @@
+using System;
+using System.Collections;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1507
+{
+ [TestFixture]
+ public class Fixture : BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ CreateData();
+ }
+ protected override void OnTearDown()
+ {
+ CleanupData();
+ }
+ private void CreateData()
+ {
+ //Employee
+ var emp = new Employee
+ {
+ Address = "Zombie street",
+ City = "Bitonto",
+ PostalCode = "66666",
+ FirstName = "tomb",
+ LastName = "mutilated"
+ };
+
+ //and his related orders
+ var order = new Order
+ {OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 1", ShipCountry = "Deadville"};
+
+ var order2 = new Order
+ {OrderDate = DateTime.Now, Employee = emp, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};
+
+ //Employee with no related orders but with same PostalCode
+ var emp2 = new Employee
+ {
+ Address = "Gut street",
+ City = "Mariotto",
+ Country = "Arised",
+ PostalCode = "66666",
+ FirstName = "carcass",
+ LastName = "purulent"
+ };
+
+ //Order with no related employee but with same ShipCountry
+ var order3 = new Order {OrderDate = DateTime.Now, ShipAddress = "dead zone 2", ShipCountry = "Deadville"};
+
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ session.Save(emp);
+ session.Save(emp2);
+ session.Save(order);
+ session.Save(order2);
+ session.Save(order3);
+
+ tx.Commit();
+ }
+ }
+ }
+
+ private void CleanupData()
+ {
+ using (ISession session = OpenSession())
+ {
+ using (ITransaction tx = session.BeginTransaction())
+ {
+ //delete empolyee and related orders
+ session.Delete("from Employee ee where ee.PostalCode = '66666'");
+
+ //delete order not related to employee
+ session.Delete("from Order oo where oo.ShipCountry = 'Deadville'");
+
+ tx.Commit();
+ }
+ }
+ }
+
+ [Test]
+ public void ExplicitJoin()
+ {
+ using (ISession session = OpenSession())
+ {
+ //explicit join
+ IList results =
+ session.CreateQuery("select count(*) from Order as entity join entity.Employee ee "
+ + "where ee.PostalCode='66666' or entity.ShipCountry='Deadville'").List();
+
+ //Debug.Assert(list[0].Equals(191), "Wrong number of orders, returned: " + list[0].ToString());
+ Assert.AreEqual(2, results[0]);
+ }
+ }
+
+ [Test]
+ public void ImplicitJoinFailingTest()
+ {
+ using (ISession session = OpenSession())
+ {
+ //implicit join
+ IList results =
+ session.CreateQuery("select count(*) from Order as entity "
+ + "where entity.Employee.PostalCode='66666' or entity.ShipCountry='Deadville'").List();
+
+ Assert.AreEqual(2, results[0]);
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Mappings.hbm.xml 2009-06-04 13:52:53 UTC (rev 4408)
@@ -0,0 +1,51 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1507">
+
+ <class name="Employee">
+ <id column="EmployeeId" name="Id" access="field.camelcase-underscore">
+ <generator class="identity" />
+ </id>
+ <property name="LastName" length="20" not-null="true" />
+ <property name="FirstName" length="10" not-null="true" />
+ <property name="Title" length="30" />
+ <property name="TitleOfCourtesy" length="25"/>
+ <property name="BirthDate"/>
+ <property name="HireDate"/>
+ <property name="Address" length="60"/>
+ <property name="City" length="15"/>
+ <property name="Region" length="15"/>
+ <property name="PostalCode" length="10"/>
+ <property name="Country" length="15"/>
+ <property name="HomePhone" length="24"/>
+ <property name="Extension" length="4"/>
+ <property name="Photo" type="BinaryBlob"/>
+ <property name="Notes" />
+ <property name="ReportsTo"/>
+ <property name="PhotoPath" length="255"/>
+ <bag name="orders" inverse="true" cascade="all">
+ <key column="EmployeeId" />
+ <one-to-many class="Order" />
+ </bag>
+ </class>
+
+ <class name="Order" table="Orders">
+ <id column="OrderID" name="Id" access="field.camelcase-underscore">
+ <generator class="identity" />
+ </id>
+ <many-to-one name="Employee" lazy="false" column="EmployeeId"/>
+ <property name="CustomerId"/>
+ <property name="OrderDate"/>
+ <property name="RequiredDate"/>
+ <property name="ShippedDate"/>
+ <property name="ShipVia"/>
+ <property name="Freight"/>
+ <property name="ShipName" length="40" />
+ <property name="ShipAddress" length="60" />
+ <property name="ShipCity" length="15" />
+ <property name="ShipRegion" length="15" />
+ <property name="ShipPostalCode" length="10" />
+ <property name="ShipCountry" length="15" />
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Order.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Order.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1507/Order.cs 2009-06-04 13:52:53 UTC (rev 4408)
@@ -0,0 +1,38 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1507
+{
+ [Serializable]
+ public class Order
+ {
+ private int _id;
+
+ protected internal Order() {}
+
+ public virtual Employee Employee { get; set; }
+
+ public virtual string CustomerId { get; set; }
+
+ public virtual DateTime? OrderDate { get; set; }
+
+ public virtual DateTime? RequiredDate { get; set; }
+
+ public virtual DateTime? ShippedDate { get; set; }
+
+ public virtual int? ShipVia { get; set; }
+
+ public virtual decimal? Freight { get; set; }
+
+ public virtual string ShipName { get; set; }
+
+ public virtual string ShipAddress { get; set; }
+
+ public virtual string ShipCity { get; set; }
+
+ public virtual string ShipRegion { get; set; }
+
+ public virtual string ShipPostalCode { get; set; }
+
+ public virtual string ShipCountry { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 00:06:41 UTC (rev 4407)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 13:52:53 UTC (rev 4408)
@@ -369,6 +369,9 @@
<Compile Include="NHSpecificTest\NH1427\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1427\Person.cs" />
<Compile Include="NHSpecificTest\NH1487\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1507\Employee.cs" />
+ <Compile Include="NHSpecificTest\NH1507\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1507\Order.cs" />
<Compile Include="NHSpecificTest\NH1531\DomainClass.cs" />
<Compile Include="NHSpecificTest\NH1531\SampleTest.cs" />
<Compile Include="NHSpecificTest\NH1553\MsSQL\Person.cs" />
@@ -1862,6 +1865,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1507\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1044\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1531\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-06-04 17:10:58
|
Revision: 4409
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4409&view=rev
Author: fabiomaulo
Date: 2009-06-04 17:10:56 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
Test for NH-1092 (at least fixed with the new translator)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Domain.cs 2009-06-04 17:10:56 UTC (rev 4409)
@@ -0,0 +1,11 @@
+namespace NHibernate.Test.NHSpecificTest.NH1092
+{
+ public class SubscriberAbstract
+ {
+ public virtual string Username { get; set; }
+ }
+
+ public class Subscriber1 : SubscriberAbstract { }
+
+ public class Subscriber2 : SubscriberAbstract { }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Fixture.cs 2009-06-04 17:10:56 UTC (rev 4409)
@@ -0,0 +1,41 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1092
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test]
+ public void CountHasUniqueResult()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new Subscriber1 {Username = "u11"});
+ s.Save(new Subscriber1 {Username = "u12"});
+ s.Save(new Subscriber1 {Username = "u13"});
+ s.Save(new Subscriber2 {Username = "u21"});
+ s.Save(new Subscriber2 {Username = "u22"});
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ var count =
+ s.CreateQuery("select count(*) from SubscriberAbstract SA where SA.Username like :username")
+ .SetString("username","u%")
+ .UniqueResult<long>();
+ Assert.That(count, Is.EqualTo(5));
+ t.Commit();
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from SubscriberAbstract").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1092/Mappings.hbm.xml 2009-06-04 17:10:56 UTC (rev 4409)
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1092"
+ assembly="NHibernate.Test">
+
+ <class name="SubscriberAbstract" abstract="true">
+ <id type="int">
+ <generator class="hilo"/>
+ </id>
+ <discriminator column="ObjType"/>
+ <property name="Username"/>
+ <subclass name="Subscriber1"/>
+ <subclass name="Subscriber2"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 13:52:53 UTC (rev 4408)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 17:10:56 UTC (rev 4409)
@@ -352,6 +352,8 @@
<Compile Include="NHSpecificTest\ElementsEnums\Something.cs" />
<Compile Include="NHSpecificTest\NH1044\Domain.cs" />
<Compile Include="NHSpecificTest\NH1044\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1092\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1092\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1093\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1093\SimpleCached.cs" />
<Compile Include="NHSpecificTest\NH1159\Contact.cs" />
@@ -1865,6 +1867,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1092\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1507\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1044\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1427\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-06-04 23:32:04
|
Revision: 4411
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4411&view=rev
Author: fabiomaulo
Date: 2009-06-04 23:31:55 +0000 (Thu, 04 Jun 2009)
Log Message:
-----------
Test for NH-1810 (smell as external issue)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Child.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Children.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Disease.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Doctor.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/MedicalRecord.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Parent.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Child.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Child.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Child.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,66 @@
+using System;
+using log4net;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public class Child : IComparable<Child>
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int id;
+ int age;
+ Parent parent;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual int Age
+ {
+ get { return age; }
+ set { age = value; }
+ }
+
+ public virtual Parent Parent
+ {
+ get { return parent; }
+ set { parent = value; }
+ }
+
+ public virtual bool Equals(Child other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.Age == Age && Equals(other.Parent, Parent);
+ }
+
+ public virtual int CompareTo(Child other)
+ {
+ return Id.CompareTo(other.Id);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Child)) return false;
+ return Equals((Child) obj);
+ }
+
+ int? hashCode;
+
+ public override int GetHashCode()
+ {
+ Log.Debug("Child.GetHashCode()");
+
+ if (!hashCode.HasValue)
+ unchecked
+ {
+ hashCode = (Age*397) ^ (Parent != null ? Parent.GetHashCode() : 0);
+ }
+
+ return hashCode.Value;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Children.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Children.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Children.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,160 @@
+using System.Collections;
+using System.Collections.Generic;
+using Iesi.Collections.Generic;
+using NHibernate.Collection;
+using NHibernate.Collection.Generic;
+using NHibernate.Engine;
+using NHibernate.Persister.Collection;
+using NHibernate.UserTypes;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public interface IChildrenBehaviour
+ {
+ void AddChild(Child child);
+ }
+
+ public class ChildrenBehaviour : IChildrenBehaviour
+ {
+ private readonly ISet<Child> children;
+
+ public ChildrenBehaviour(ISet<Child> children)
+ {
+ this.children = children;
+ }
+
+ public void AddChild(Child child)
+ {
+ children.Add(child);
+ }
+ }
+
+ public interface IChildren : IChildrenBehaviour
+ {
+ }
+
+ // Using a HashedSet<Child> instead SortedSet<Child> all work fine.
+ public class Children : SortedSet<Child>, IChildren
+ {
+ private readonly IChildrenBehaviour behaviour;
+
+ public Children()
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public Children(IComparer<Child> comparer) : base(comparer)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public Children(ICollection<Child> initialValues) : base(initialValues)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public Children(ICollection initialValues) : base(initialValues)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public Children(ICollection<Child> initialValues, IComparer<Child> comparer) : base(initialValues, comparer)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public void AddChild(Child child)
+ {
+ behaviour.AddChild(child);
+ }
+ }
+
+ public class PersistentChildren : PersistentGenericSet<Child>, IChildren
+ {
+ private readonly IChildrenBehaviour behaviour;
+
+ public PersistentChildren(ISessionImplementor session)
+ : base(session)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public PersistentChildren(ISessionImplementor session, ISet<Child> collection)
+ : base(session, collection)
+ {
+ behaviour = new ChildrenBehaviour(this);
+ }
+
+ public void AddChild(Child child)
+ {
+ behaviour.AddChild(child);
+ }
+ }
+
+ public class Factory : SetFactory<Child>
+ {
+ public override IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister)
+ {
+ return new PersistentChildren(session);
+ }
+
+ public override IPersistentCollection Wrap(ISessionImplementor session, object collection)
+ {
+ return new PersistentChildren(session, (ISet<Child>)collection);
+ }
+
+ protected override object Instantiate()
+ {
+ return new Children();
+ }
+ }
+
+ public class SetFactory<T> : IUserCollectionType
+ {
+ public virtual IPersistentCollection Instantiate(ISessionImplementor session, ICollectionPersister persister)
+ {
+ return new PersistentGenericSet<T>(session);
+ }
+
+ public virtual IPersistentCollection Wrap(ISessionImplementor session, object collection)
+ {
+ return new PersistentGenericSet<T>(session, (ISet<T>)collection);
+ }
+
+ public IEnumerable GetElements(object collection)
+ {
+ return (IEnumerable)collection;
+ }
+
+ public bool Contains(object collection, object entity)
+ {
+ return ((ISet<T>)collection).Contains((T)entity);
+ }
+
+ public object IndexOf(object collection, object entity)
+ {
+ return new List<T>((ISet<T>)collection).IndexOf((T)entity);
+ }
+
+ public object ReplaceElements(object original, object target, ICollectionPersister persister, object owner, IDictionary copyCache, ISessionImplementor session)
+ {
+ var result = (ISet<T>)target;
+ result.Clear();
+
+ foreach (var o in (IEnumerable)original)
+ result.Add((T)o);
+
+ return result;
+ }
+
+ public object Instantiate(int anticipatedSize)
+ {
+ return Instantiate();
+ }
+
+ protected virtual object Instantiate()
+ {
+ return new HashedSet<T>();
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Disease.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Disease.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Disease.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,70 @@
+using log4net;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public class Disease
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int id;
+ string name;
+ int duration;
+ MedicalRecord medicalRecord;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual string Name
+ {
+ get { return name; }
+ set { name = value; }
+ }
+
+ public virtual int Duration
+ {
+ get { return duration; }
+ set { duration = value; }
+ }
+
+ public virtual MedicalRecord MedicalRecord
+ {
+ get { return medicalRecord; }
+ set { medicalRecord = value; }
+ }
+
+ public virtual bool Equals(Disease other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.Name, Name) && other.Duration == Duration && Equals(other.MedicalRecord, MedicalRecord);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Disease)) return false;
+ return Equals((Disease) obj);
+ }
+
+ int? hashCode;
+
+ public override int GetHashCode()
+ {
+ Log.Debug("Disease.GetHashCode()");
+
+ if (!hashCode.HasValue)
+ unchecked
+ {
+ int result = (Name != null ? Name.GetHashCode() : 0);
+ result = (result*397) ^ Duration;
+ result = (result*397) ^ (MedicalRecord != null ? MedicalRecord.GetHashCode() : 0);
+ hashCode = result;
+ }
+
+ return hashCode.Value;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Doctor.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Doctor.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Doctor.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,57 @@
+using log4net;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public class Doctor
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int id;
+ MedicalRecord medicalRecord;
+ int doctorNumber;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual MedicalRecord MedicalRecord
+ {
+ get { return medicalRecord; }
+ set { medicalRecord = value; }
+ }
+
+ public virtual int DoctorNumber
+ {
+ get { return doctorNumber; }
+ set { doctorNumber = value; }
+ }
+
+ public virtual bool Equals(Doctor other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return other.doctorNumber == doctorNumber;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Doctor)) return false;
+ return Equals((Doctor) obj);
+ }
+
+ int? hashCode;
+
+ public override int GetHashCode()
+ {
+ Log.Debug("Doctor.GetHashCode()");
+
+ if (!hashCode.HasValue)
+ hashCode = doctorNumber.GetHashCode();
+
+ return hashCode.Value;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Fixture.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,93 @@
+using System.Data;
+using log4net;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ [TestFixture, Ignore("To investigate.")]
+ public class Fixture : BugTestCase
+ {
+ // The problem is the same using a default sort="natural" collection for Children
+ // and there is no problem using a default HashedSet.
+ // look a the implementation of Children
+
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int parentId;
+ int doctorId;
+
+ protected override ISession OpenSession()
+ {
+ var session = base.OpenSession();
+ session.FlushMode = FlushMode.Commit;
+
+ return session;
+ }
+
+ protected override void OnSetUp()
+ {
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ var parent = new Parent {Address = "A street, A town, A country"};
+
+ // If you add a child all work fine.
+ //var child = new Child {Age = 2, Parent = parent};
+ //parent.Children.AddChild(child);
+
+ sess.Save(parent);
+
+ var doctor = new Doctor {DoctorNumber = 123, MedicalRecord = parent.MedicalRecord};
+
+ sess.Save(doctor);
+ tx.Commit();
+
+ parentId = parent.Id;
+ doctorId = doctor.Id;
+ }
+ }
+
+ [Test]
+ public void Test()
+ {
+ Log.Debug("Entering test");
+
+ using (ISession sess = OpenSession())
+ {
+ Log.Debug("Loading doctor");
+ var doctor = sess.Get<Doctor>(doctorId); // creates a proxy of the medical record
+
+ Log.Debug("Loading parent");
+ var parent = sess.Get<Parent>(parentId);
+
+ Log.Debug("Adding new child to parent");
+ parent.Children.AddChild(new Child { Age = 10, Parent = parent }); // does NOT cause Child.GetHashCode() to be called
+
+ using (ITransaction tx = sess.BeginTransaction(IsolationLevel.ReadCommitted))
+ {
+ Log.Debug("Saving parent");
+ sess.Update(parent);
+
+ Log.Debug("Committing transaction");
+ tx.Commit(); // triggers Child.GetHashCode() to be called in flush machiney, leading to CNPBF exception
+ }
+ }
+
+ Log.Debug("Exiting test");
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession sess = OpenSession())
+ using (ITransaction tx = sess.BeginTransaction())
+ {
+ sess.Delete("from Doctor");
+ sess.Delete("from Parent");
+ sess.Delete("from Child");
+ sess.Delete("from MedicalRecord");
+ sess.Delete("from Disease");
+ tx.Commit();
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Mappings.hbm.xml 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" namespace="NHibernate.Test.NHSpecificTest.NH1810" assembly="NHibernate.Test">
+
+ <class name="NHibernate.Test.NHSpecificTest.NH1810.Disease, NHibernate.Test" table="Disease" lazy="true">
+ <cache usage="read-write" />
+ <id name="Id" access="nosetter.camelcase" column="Id" type="Int32" unsaved-value="0">
+ <generator class="native">
+ </generator>
+ </id>
+ <property name="Name" access="property" type="String">
+ <column name="Name"/>
+ </property>
+ <property name="Duration" access="property" type="Int32">
+ <column name="Duration"/>
+ </property>
+ <many-to-one name="MedicalRecord" class="NHibernate.Test.NHSpecificTest.NH1810.MedicalRecord, NHibernate.Test" column="MedicalRecordId" lazy="proxy" cascade="none" />
+ </class>
+
+ <class name="NHibernate.Test.NHSpecificTest.NH1810.MedicalRecord, NHibernate.Test" table="MedicalRecord" lazy="true">
+ <cache usage="read-write" />
+ <id name="Id" access="nosetter.camelcase" column="Id" type="Int32" unsaved-value="0">
+ <generator class="native">
+ </generator>
+ </id>
+ <property name="Reference" access="property" type="String">
+ <column name="Reference"/>
+ </property>
+ <set name="Diseases" access="nosetter.camelcase" table="Disease" lazy="true" inverse="true" cascade="all-delete-orphan">
+ <key column="MedicalRecordId" />
+ <one-to-many class="NHibernate.Test.NHSpecificTest.NH1810.Disease, NHibernate.Test" />
+ </set>
+ </class>
+
+ <class name="NHibernate.Test.NHSpecificTest.NH1810.Doctor, NHibernate.Test" table="Doctor" lazy="true">
+ <cache usage="read-write" />
+ <id name="Id" access="nosetter.camelcase" column="Id" type="Int32" unsaved-value="0">
+ <generator class="native">
+ </generator>
+ </id>
+ <property name="DoctorNumber" access="property" type="Int32">
+ <column name="DoctorNumber"/>
+ </property>
+ <many-to-one name="MedicalRecord" class="NHibernate.Test.NHSpecificTest.NH1810.MedicalRecord, NHibernate.Test" column="MedicalRecordId" lazy="proxy" cascade="none" />
+ </class>
+
+ <class name="NHibernate.Test.NHSpecificTest.NH1810.Child, NHibernate.Test" table="Child" lazy="true">
+ <cache usage="read-write" />
+ <id name="Id" access="nosetter.camelcase" column="Id" type="Int32" unsaved-value="0">
+ <generator class="native">
+ </generator>
+ </id>
+ <property name="Age" access="property" type="Int32">
+ <column name="Age"/>
+ </property>
+ <many-to-one name="Parent" class="NHibernate.Test.NHSpecificTest.NH1810.Parent, NHibernate.Test" column="ParentId" lazy="proxy" cascade="none" />
+ </class>
+
+ <class name="NHibernate.Test.NHSpecificTest.NH1810.Parent, NHibernate.Test" table="Parent" lazy="true">
+ <cache usage="read-write" />
+ <id name="Id" access="nosetter.camelcase" column="Id" type="Int32" unsaved-value="0">
+ <generator class="native">
+ </generator>
+ </id>
+ <property name="Address" access="property" type="String">
+ <column name="Address"/>
+ </property>
+ <property name="Visits" access="property" type="Int32">
+ <column name="Visits"/>
+ </property>
+ <set name="Children" access="nosetter.camelcase" table="Child" lazy="true" inverse="true" cascade="all-delete-orphan" collection-type="NHibernate.Test.NHSpecificTest.NH1810.Factory, NHibernate.Test">
+ <key column="ParentId" />
+ <one-to-many class="NHibernate.Test.NHSpecificTest.NH1810.Child, NHibernate.Test" />
+ </set>
+ <many-to-one name="MedicalRecord" access="nosetter.camelcase" class="NHibernate.Test.NHSpecificTest.NH1810.MedicalRecord, NHibernate.Test" column="MedicalRecordId" lazy="proxy" cascade="all-delete-orphan" />
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/MedicalRecord.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/MedicalRecord.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/MedicalRecord.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,57 @@
+using Iesi.Collections.Generic;
+using log4net;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public class MedicalRecord
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int id;
+ ISet<Disease> diseases = new HashedSet<Disease>();
+ string reference;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual ISet<Disease> Diseases
+ {
+ get { return diseases; }
+ }
+
+ public virtual string Reference
+ {
+ get { return reference; }
+ set { reference = value; }
+ }
+
+ public virtual bool Equals(MedicalRecord other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.Reference, Reference);
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (MedicalRecord)) return false;
+ return Equals((MedicalRecord) obj);
+ }
+
+ int? hashCode;
+
+ public override int GetHashCode()
+ {
+ Log.Debug("MedicalRecord.GetHashCode()");
+
+ if (!hashCode.HasValue)
+ hashCode = (Reference != null ? Reference.GetHashCode() : 0);
+
+ return hashCode.Value;
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Parent.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Parent.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1810/Parent.cs 2009-06-04 23:31:55 UTC (rev 4411)
@@ -0,0 +1,76 @@
+using Iesi.Collections.Generic;
+using log4net;
+
+namespace NHibernate.Test.NHSpecificTest.NH1810
+{
+ public class Parent
+ {
+ private static readonly ILog Log = LogManager.GetLogger(typeof(Fixture));
+
+ int id;
+ IChildren children = new Children();
+ MedicalRecord medicalRecord = new MedicalRecord();
+ string address;
+ int visits;
+
+ public virtual int Id
+ {
+ get { return id; }
+ }
+
+ public virtual IChildren Children
+ {
+ get { return children; }
+ }
+
+ public virtual MedicalRecord MedicalRecord
+ {
+ get { return medicalRecord; }
+ }
+
+ public virtual string Address
+ {
+ get { return address; }
+ set { address = value; }
+ }
+
+ public virtual int Visits
+ {
+ get { return visits; }
+ set { visits = value; }
+ }
+
+ public virtual bool Equals(Parent other)
+ {
+ if (ReferenceEquals(null, other)) return false;
+ if (ReferenceEquals(this, other)) return true;
+ return Equals(other.MedicalRecord, MedicalRecord) && Equals(other.Address, Address) && other.Visits == Visits;
+ }
+
+ public override bool Equals(object obj)
+ {
+ if (ReferenceEquals(null, obj)) return false;
+ if (ReferenceEquals(this, obj)) return true;
+ if (obj.GetType() != typeof (Parent)) return false;
+ return Equals((Parent) obj);
+ }
+
+ int? hashCode;
+
+ public override int GetHashCode()
+ {
+ Log.Debug("Parent.GetHashCode()");
+
+ if (!hashCode.HasValue)
+ unchecked
+ {
+ int result = (MedicalRecord != null ? MedicalRecord.GetHashCode() : 0);
+ result = (result*397) ^ (Address != null ? Address.GetHashCode() : 0);
+ result = (result*397) ^ Visits;
+ hashCode = result;
+ }
+
+ return hashCode.Value;
+ }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 19:16:07 UTC (rev 4410)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-04 23:31:55 UTC (rev 4411)
@@ -472,6 +472,13 @@
<Compile Include="NHSpecificTest\NH1796\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1801\Domain.cs" />
<Compile Include="NHSpecificTest\NH1801\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Child.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Children.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Disease.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Doctor.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1810\MedicalRecord.cs" />
+ <Compile Include="NHSpecificTest\NH1810\Parent.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1867,6 +1874,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1810\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1092\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1507\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1044\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-06-05 17:05:25
|
Revision: 4415
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4415&view=rev
Author: fabiomaulo
Date: 2009-06-05 17:05:23 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
Test for NH-1812 (not fixed yet)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Fixture.cs 2009-06-05 17:05:23 UTC (rev 4415)
@@ -0,0 +1,75 @@
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1812
+{
+ public class AstBugBase : BugTestCase
+ {
+ [Test]
+ public void Test()
+ {
+ var p = new Person();
+
+ const string query =
+ @"select p from Person p
+ left outer join p.PeriodCollection p1
+ where p1.Start > coalesce((select max(p2.Start) from Period p2), :nullStart)";
+
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Save(p);
+ tx.Commit();
+ }
+
+ s.CreateQuery(query)
+ .SetDateTime("nullStart", new DateTime(2001, 1, 1))
+ .List<Person>();
+ }
+
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession s = OpenSession())
+ {
+ using (ITransaction tx = s.BeginTransaction())
+ {
+ s.Delete("from Person");
+ tx.Commit();
+ }
+ }
+ }
+ }
+
+ [TestFixture, Ignore("To fix for AST parser; there are problems with subquery in various places.")]
+ public class AstBug : AstBugBase
+ {
+
+ /* to the nh guy...
+ * sorry for not coming up with a more realistic use case
+ * We have a query that works fine with the old parser but not with the new AST parser
+ * I've broke our complex query down to this...
+ * I believe the problem is when mixing aggregate methods with isnull()
+ */
+ }
+
+ [TestFixture]
+ public class ItWorksWithClassicParser : AstBugBase
+ {
+
+ protected override void Configure(Cfg.Configuration configuration)
+ {
+ configuration.AddProperties(new Dictionary<string, string>
+ {
+ {
+ Cfg.Environment.QueryTranslator,
+ typeof (NHibernate.Hql.Classic.ClassicQueryTranslatorFactory).FullName
+ }
+ }
+ );
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Mappings.hbm.xml 2009-06-05 17:05:23 UTC (rev 4415)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1812"
+ assembly="NHibernate.Test" >
+
+ <class name="Person">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <bag name="PeriodCollection">
+ <key column="fk" />
+ <one-to-many class="Period"/>
+ </bag>
+ </class>
+
+ <class name="Period">
+ <id name="Id">
+ <generator class="native" />
+ </id>
+ <property name="Start" />
+ </class>
+</hibernate-mapping>
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1812/Model.cs 2009-06-05 17:05:23 UTC (rev 4415)
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1812
+{
+ public class Person
+ {
+ public virtual int Id {get; set;}
+ public virtual IList<Period> PeriodCollection { get; set; }
+
+ public Person(){PeriodCollection=new List<Period>();}
+ }
+
+ public class Period
+ {
+ public virtual int Id { get; set; }
+ public virtual DateTime? Start { get; set; }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 13:50:25 UTC (rev 4414)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 17:05:23 UTC (rev 4415)
@@ -486,6 +486,8 @@
<Compile Include="NHSpecificTest\NH1810\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1810\MedicalRecord.cs" />
<Compile Include="NHSpecificTest\NH1810\Parent.cs" />
+ <Compile Include="NHSpecificTest\NH1812\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1812\Model.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1881,6 +1883,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1601\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1617\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1810\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-06-05 19:48:57
|
Revision: 4417
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4417&view=rev
Author: fabiomaulo
Date: 2009-06-05 19:46:56 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
Fix NH-1444
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1444/Fixture.cs 2009-06-05 19:46:56 UTC (rev 4417)
@@ -0,0 +1,30 @@
+using NHibernate.Cfg;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1444
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ protected override void Configure(Configuration configuration)
+ {
+ configuration.SetProperty(Environment.FormatSql, "false");
+ }
+ [Test]
+ public void Bug()
+ {
+ using (ISession s = OpenSession())
+ {
+ long? filter = null;
+ using (var ls = new SqlLogSpy())
+ {
+ s.CreateQuery(@"SELECT c FROM xchild c WHERE (:filternull = true OR c.Parent.A < :filterval)")
+ .SetParameter("filternull", !filter.HasValue)
+ .SetParameter("filterval", filter.HasValue ? filter.Value : 0).List<xchild>();
+ var message = ls.GetWholeLog();
+ Assert.That(message, Text.Contains("xchild0_.ParentId=xparent1_.Id and (@p0=1 or xparent1_.A<@p1)"));
+ }
+ }
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 18:10:33 UTC (rev 4416)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 19:46:56 UTC (rev 4417)
@@ -370,6 +370,8 @@
<Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1427\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1427\Person.cs" />
+ <Compile Include="NHSpecificTest\NH1444\classes.cs" />
+ <Compile Include="NHSpecificTest\NH1444\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1487\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1507\Employee.cs" />
<Compile Include="NHSpecificTest\NH1507\Fixture.cs" />
@@ -1885,6 +1887,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1444\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1601\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-06-05 20:16:32
|
Revision: 4419
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4419&view=rev
Author: fabiomaulo
Date: 2009-06-05 20:15:26 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
Fix NH-1400 (probably fixed by new parser)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Domain.cs 2009-06-05 20:15:26 UTC (rev 4419)
@@ -0,0 +1,7 @@
+namespace NHibernate.Test.NHSpecificTest.NH1400
+{
+ public class SimpleGeographicalAddress
+ {
+ public string Line2 { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Fixture.cs 2009-06-05 20:15:26 UTC (rev 4419)
@@ -0,0 +1,17 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1400
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test]
+ public void DotInStringLiteralsConstant()
+ {
+ using (ISession s = OpenSession())
+ {
+ Assert.DoesNotThrow(() => s.CreateQuery("from SimpleGeographicalAddress as dga where dga.Line2 = 'B1 P9, Scb, Ap. 18'").List());
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1400/Mappings.hbm.xml 2009-06-05 20:15:26 UTC (rev 4419)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1400"
+ default-lazy="false">
+
+ <class name="SimpleGeographicalAddress">
+ <id type="int">
+ <generator class="native" />
+ </id>
+ <property name="Line2" />
+ </class>
+</hibernate-mapping>
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 19:55:12 UTC (rev 4418)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 20:15:26 UTC (rev 4419)
@@ -368,6 +368,8 @@
<Compile Include="NHSpecificTest\NH1343\Product.cs" />
<Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" />
<Compile Include="NHSpecificTest\NH1388\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1400\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1400\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1427\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1427\Person.cs" />
<Compile Include="NHSpecificTest\NH1444\classes.cs" />
@@ -1887,6 +1889,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1444\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1812\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-06-05 22:06:41
|
Revision: 4421
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4421&view=rev
Author: fabiomaulo
Date: 2009-06-05 22:06:40 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
Test for NH-1182 (was fixed in some moment in the past)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Domain.cs 2009-06-05 22:06:40 UTC (rev 4421)
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+
+namespace NHibernate.Test.NHSpecificTest.NH1182
+{
+ public class ObjectA
+ {
+ public virtual int Id { get; set; }
+ public virtual DateTime Version { get; set; }
+ public virtual IList<ObjectB> Bs { get; set; }
+ }
+
+ public class ObjectB
+ {
+ public virtual int Id { get; set; }
+ public virtual DateTime Version { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Fixture.cs 2009-06-05 22:06:40 UTC (rev 4421)
@@ -0,0 +1,47 @@
+using System.Collections.Generic;
+using NHibernate.Cfg;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1182
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ protected override void Configure(Configuration configuration)
+ {
+ configuration.SetProperty(Environment.FormatSql, "false");
+ }
+ [Test]
+ public void DeleteWithoutUpdateVersion()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new ObjectA { Bs = new List<ObjectB> { new ObjectB(), new ObjectB() } });
+ t.Commit();
+ }
+
+ using (var ls = new SqlLogSpy())
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ var a = s.CreateCriteria<ObjectA>().UniqueResult<ObjectA>();
+ s.Delete(a);
+ t.Commit();
+ }
+ string wholeLog = ls.GetWholeLog();
+ Assert.That(wholeLog, Text.DoesNotContain("UPDATE ObjectA"));
+ Assert.That(wholeLog, Text.Contains("UPDATE ObjectB"),"should create orphans");
+ }
+
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from ObjectB").ExecuteUpdate();
+ s.CreateQuery("delete from ObjectA").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1182/Mappings.hbm.xml 2009-06-05 22:06:40 UTC (rev 4421)
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1182"
+ assembly="NHibernate.Test">
+
+ <class name="ObjectA">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <timestamp name="Version"/>
+ <bag name="Bs" cascade="all">
+ <key column="AId"/>
+ <one-to-many class="ObjectB"/>
+ </bag>
+ </class>
+
+ <class name="ObjectB">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <timestamp name="Version"/>
+ </class>
+
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 21:27:54 UTC (rev 4420)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 22:06:40 UTC (rev 4421)
@@ -363,6 +363,8 @@
<Compile Include="NHSpecificTest\NH1159\HibernateInterceptor.cs" />
<Compile Include="NHSpecificTest\NH1171\Domain.cs" />
<Compile Include="NHSpecificTest\NH1171\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1182\Domain.cs" />
+ <Compile Include="NHSpecificTest\NH1182\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1264\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1264\Name.cs" />
<Compile Include="NHSpecificTest\NH1264\Passenger.cs" />
@@ -1892,6 +1894,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1182\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1171\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1400\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1444\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-06-11 02:55:46
|
Revision: 4450
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4450&view=rev
Author: fabiomaulo
Date: 2009-06-11 02:55:44 +0000 (Thu, 11 Jun 2009)
Log Message:
-----------
Minor (moved test in its place)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/ExpressionTest/RestrictionsFixture.cs
Removed Paths:
-------------
trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs
Deleted: trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs 2009-06-11 02:37:36 UTC (rev 4449)
+++ trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs 2009-06-11 02:55:44 UTC (rev 4450)
@@ -1,18 +0,0 @@
-using NHibernate.Criterion;
-using NUnit.Framework;
-
-namespace NHibernate.Test.Criteria
-{
- [TestFixture]
- public class RestrictionsFixture
- {
- [Test]
- public void LikeShouldContainsMatch()
- {
- ICriterion c = Restrictions.Like("Name", "n", MatchMode.Anywhere, null);
- Assert.That(c, Is.InstanceOf<LikeExpression>());
- var likeExpression = (LikeExpression) c;
- Assert.That(likeExpression.ToString(), Is.EqualTo("Name like %n%"));
- }
- }
-}
\ No newline at end of file
Copied: trunk/nhibernate/src/NHibernate.Test/ExpressionTest/RestrictionsFixture.cs (from rev 4449, trunk/nhibernate/src/NHibernate.Test/Criteria/RestrictionsFixture.cs)
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/ExpressionTest/RestrictionsFixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/ExpressionTest/RestrictionsFixture.cs 2009-06-11 02:55:44 UTC (rev 4450)
@@ -0,0 +1,18 @@
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.ExpressionTest
+{
+ [TestFixture]
+ public class RestrictionsFixture
+ {
+ [Test]
+ public void LikeShouldContainsMatch()
+ {
+ ICriterion c = Restrictions.Like("Name", "n", MatchMode.Anywhere, null);
+ Assert.That(c, Is.InstanceOf<LikeExpression>());
+ var likeExpression = (LikeExpression) c;
+ Assert.That(likeExpression.ToString(), Is.EqualTo("Name like %n%"));
+ }
+ }
+}
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 02:37:36 UTC (rev 4449)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-11 02:55:44 UTC (rev 4450)
@@ -147,7 +147,7 @@
<Compile Include="Criteria\MaterialResource.cs" />
<Compile Include="Criteria\ProjectionsTest.cs" />
<Compile Include="Criteria\Reptile.cs" />
- <Compile Include="Criteria\RestrictionsFixture.cs" />
+ <Compile Include="ExpressionTest\RestrictionsFixture.cs" />
<Compile Include="Criteria\Student.cs" />
<Compile Include="Criteria\StudentDTO.cs" />
<Compile Include="DebugConnectionProvider.cs" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <fab...@us...> - 2009-06-14 13:06:56
|
Revision: 4462
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4462&view=rev
Author: fabiomaulo
Date: 2009-06-14 13:06:55 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Test for NH-1835
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Document.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Document.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Document.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Document.cs 2009-06-14 13:06:55 UTC (rev 4462)
@@ -0,0 +1,10 @@
+using System;
+
+namespace NHibernate.Test.NHSpecificTest.NH1835
+{
+ public class Document
+ {
+ public virtual Guid Id { get; set; }
+ public virtual byte[] Contents { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Fixture.cs 2009-06-14 13:06:55 UTC (rev 4462)
@@ -0,0 +1,16 @@
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1835
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ [Test, Ignore("Not fixed yet.")]
+ public void ColumnTypeBinaryBlob()
+ {
+ var pc = sessions.GetEntityPersister(typeof (Document).FullName);
+ var type = pc.GetPropertyType("Contents");
+ Assert.That(type.SqlTypes(sessions)[0].Length, Is.EqualTo(3000));
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1835/Mappings.hbm.xml 2009-06-14 13:06:55 UTC (rev 4462)
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1835">
+
+ <class name="Document" table="documents_document">
+ <id name="Id">
+ <generator class="guid.comb" />
+ </id>
+ <property name="Contents">
+ <column name="Contents" sql-type="varbinary(3000)"/>
+ </property>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 10:01:50 UTC (rev 4461)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 13:06:55 UTC (rev 4462)
@@ -505,6 +505,8 @@
<Compile Include="NHSpecificTest\NH1821\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1834\A.cs" />
<Compile Include="NHSpecificTest\NH1834\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1835\Document.cs" />
+ <Compile Include="NHSpecificTest\NH1835\Fixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1905,6 +1907,7 @@
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1835\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1834\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1821\Mappings.hbm.xml" />
<EmbeddedResource Include="TypeParameters\EntityCustomId.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <te...@us...> - 2009-06-14 18:17:14
|
Revision: 4466
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4466&view=rev
Author: tehlike
Date: 2009-06-14 18:17:12 +0000 (Sun, 14 Jun 2009)
Log Message:
-----------
Adding tests for NH-1837 (already fixed in rev 4461)
Revision Links:
--------------
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4461&view=rev
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Customer.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Mappings.hbm.xml
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Order.cs
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Customer.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Customer.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Customer.cs 2009-06-14 18:17:12 UTC (rev 4466)
@@ -0,0 +1,17 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1837
+{
+ public class Customer
+ {
+ public Customer()
+ {
+ this.Orders = new List<Order>();
+ }
+ public virtual int Id { get; set; }
+ public virtual string Name { get; set; }
+ public virtual IList<Order> Orders { get; set; }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Fixture.cs 2009-06-14 18:17:12 UTC (rev 4466)
@@ -0,0 +1,92 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+using NHibernate.Criterion;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1837
+{
+ [TestFixture]
+ public class Fixture:BugTestCase
+ {
+ protected override void OnSetUp()
+ {
+ sessions.Statistics.IsStatisticsEnabled = true;
+ using(ISession session=this.OpenSession())
+ using(ITransaction tran=session.BeginTransaction())
+ {
+ var customer = new Customer {Name = "Fabio Maulo"};
+ var order = new Order {Date = DateTime.Now, Customer = customer};
+ customer.Orders.Add(order);
+ session.Save(customer);
+ session.Save(order);
+ tran.Commit();
+ }
+ }
+
+ protected override void OnTearDown()
+ {
+ using (ISession session = this.OpenSession())
+ using (ITransaction tran = session.BeginTransaction())
+ {
+ session.Delete("from Order");
+ session.Delete("from Customer");
+ tran.Commit();
+ }
+ }
+ [Test]
+ public void ExecutesOneQueryWithUniqueResultWithChildCriteriaNonGeneric()
+ {
+
+ sessions.Statistics.Clear();
+ using (ISession session = this.OpenSession())
+ {
+ var criteria = session.CreateCriteria(typeof(Order),"o");
+ criteria.CreateCriteria("o.Customer", "c")
+ .Add(Restrictions.Eq("c.Id", 1))
+ .SetProjection(Projections.RowCount())
+ .UniqueResult();
+ Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1));
+ }
+ }
+ [Test]
+ public void ExecutesOneQueryWithUniqueResultWithChildCriteriaGeneric()
+ {
+ sessions.Statistics.Clear();
+ using (ISession session = this.OpenSession())
+ {
+ session.CreateCriteria(typeof (Order), "o")
+ .CreateCriteria("o.Customer", "c")
+ .Add(Restrictions.Eq("c.Id", 1))
+ .SetProjection(Projections.RowCount())
+ .UniqueResult<int>();
+ Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1));
+ }
+ }
+ [Test]
+ public void ExecutesOneQueryWithUniqueResultWithCriteriaNonGeneric()
+ {
+ sessions.Statistics.Clear();
+ using (ISession session = this.OpenSession())
+ {
+ session.CreateCriteria(typeof (Order), "o")
+ .SetProjection(Projections.RowCount())
+ .UniqueResult();
+ Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1));
+ }
+ }
+
+ [Test]
+ public void ExecutesOneQueryWithUniqueResultWithCriteriaGeneric()
+ {
+ sessions.Statistics.Clear();
+ using (ISession session = this.OpenSession())
+ {
+ session.CreateCriteria(typeof (Order), "o")
+ .SetProjection(Projections.RowCount())
+ .UniqueResult<int>();
+ Assert.That(sessions.Statistics.QueryExecutionCount, Is.EqualTo(1));
+ }
+ }
+ }
+}
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Mappings.hbm.xml 2009-06-14 18:17:12 UTC (rev 4466)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="NHibernate.Test"
+ namespace="NHibernate.Test.NHSpecificTest.NH1837"
+ default-lazy="false">
+
+ <class name="Customer">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Name"/>
+ <bag name="Orders" lazy="true">
+ <key column="CustomerId" />
+ <one-to-many class="Order" />
+ </bag>
+ </class>
+ <class name="Order" table="`Order`">
+ <id name="Id">
+ <generator class="native"/>
+ </id>
+ <property name="Date"/>
+ <many-to-one name="Customer" class="Customer" column="CustomerId"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Order.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Order.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1837/Order.cs 2009-06-14 18:17:12 UTC (rev 4466)
@@ -0,0 +1,13 @@
+using System;
+using System.Collections.Generic;
+using System.Text;
+
+namespace NHibernate.Test.NHSpecificTest.NH1837
+{
+ public class Order
+ {
+ public int Id { get; set; }
+ public DateTime Date { get; set; }
+ public Customer Customer { get; set; }
+ }
+}
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 17:35:23 UTC (rev 4465)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-14 18:17:12 UTC (rev 4466)
@@ -507,6 +507,9 @@
<Compile Include="NHSpecificTest\NH1834\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1835\Document.cs" />
<Compile Include="NHSpecificTest\NH1835\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1837\Customer.cs" />
+ <Compile Include="NHSpecificTest\NH1837\Fixture.cs" />
+ <Compile Include="NHSpecificTest\NH1837\Order.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1909,6 +1912,7 @@
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<EmbeddedResource Include="Bytecode\Lightweight\ProductLine.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1837\Mappings.hbm.xml" />
<EmbeddedResource Include="TypesTest\MultiTypeEntity_WithSqlType.hbm.xml" />
<EmbeddedResource Include="TypesTest\MultiTypeEntity_WithColumnNode.hbm.xml" />
<EmbeddedResource Include="TypesTest\MultiTypeEntity_InLine.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|