You can subscribe to this list here.
2004 |
Jan
|
Feb
|
Mar
|
Apr
(248) |
May
(82) |
Jun
(90) |
Jul
(177) |
Aug
(253) |
Sep
(157) |
Oct
(151) |
Nov
(143) |
Dec
(278) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(152) |
Feb
(107) |
Mar
(177) |
Apr
(133) |
May
(259) |
Jun
(81) |
Jul
(119) |
Aug
(306) |
Sep
(416) |
Oct
(240) |
Nov
(329) |
Dec
(206) |
2006 |
Jan
(466) |
Feb
(382) |
Mar
(153) |
Apr
(162) |
May
(133) |
Jun
(21) |
Jul
(18) |
Aug
(37) |
Sep
(97) |
Oct
(114) |
Nov
(110) |
Dec
(28) |
2007 |
Jan
(74) |
Feb
(65) |
Mar
(49) |
Apr
(76) |
May
(43) |
Jun
(15) |
Jul
(68) |
Aug
(55) |
Sep
(63) |
Oct
(59) |
Nov
(70) |
Dec
(66) |
2008 |
Jan
(71) |
Feb
(60) |
Mar
(120) |
Apr
(31) |
May
(48) |
Jun
(81) |
Jul
(107) |
Aug
(51) |
Sep
(80) |
Oct
(83) |
Nov
(83) |
Dec
(79) |
2009 |
Jan
(83) |
Feb
(110) |
Mar
(97) |
Apr
(91) |
May
(291) |
Jun
(250) |
Jul
(197) |
Aug
(58) |
Sep
(54) |
Oct
(122) |
Nov
(68) |
Dec
(34) |
2010 |
Jan
(50) |
Feb
(17) |
Mar
(63) |
Apr
(61) |
May
(84) |
Jun
(81) |
Jul
(138) |
Aug
(144) |
Sep
(78) |
Oct
(26) |
Nov
(30) |
Dec
(61) |
2011 |
Jan
(33) |
Feb
(35) |
Mar
(166) |
Apr
(221) |
May
(109) |
Jun
(76) |
Jul
(27) |
Aug
(37) |
Sep
(1) |
Oct
(4) |
Nov
(2) |
Dec
(1) |
2012 |
Jan
|
Feb
|
Mar
(2) |
Apr
(2) |
May
|
Jun
|
Jul
(1) |
Aug
|
Sep
(1) |
Oct
|
Nov
(1) |
Dec
|
2013 |
Jan
|
Feb
(1) |
Mar
|
Apr
|
May
|
Jun
|
Jul
(1) |
Aug
(1) |
Sep
(3) |
Oct
(2) |
Nov
|
Dec
(1) |
2014 |
Jan
(1) |
Feb
(1) |
Mar
(3) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <fab...@us...> - 2009-06-05 04:39:26
|
Revision: 4412 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4412&view=rev Author: fabiomaulo Date: 2009-06-05 04:39:24 +0000 (Fri, 05 Jun 2009) Log Message: ----------- Breaking Change for external framework The method GetSession() was removed (some user is thinking that it is for child-session where it was only to avoid downcast in NHSR) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs Modified: trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Engine/ISessionImplementor.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -270,13 +270,6 @@ /// </summary> bool TransactionInProgress { get; } - /// <summary> - /// Allow to get the ISession instance without having to - /// down cast - /// </summary> - /// <returns></returns> - ISession GetSession(); - /// <summary> Retrieve the entity mode in effect for this session. </summary> EntityMode EntityMode { get; } Modified: trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/AbstractSessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -99,7 +99,6 @@ public abstract IList<T> ListCustomQuery<T>(ICustomQuery customQuery, QueryParameters queryParameters); public abstract object GetFilterParameterValue(string filterParameterName); public abstract IType GetFilterParameterType(string filterParameterName); - public abstract ISession GetSession(); public abstract IDictionary<string, IFilter> EnabledFilters { get; } public virtual IQuery GetNamedSQLQuery(string name) Modified: trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/SessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -2334,11 +2334,6 @@ return this; } - public override ISession GetSession() - { - return this; - } - public ISession GetSession(EntityMode entityMode) { using (new SessionIdLoggingContext(SessionId)) Modified: trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-06-04 23:31:55 UTC (rev 4411) +++ trunk/nhibernate/src/NHibernate/Impl/StatelessSessionImpl.cs 2009-06-05 04:39:24 UTC (rev 4412) @@ -924,12 +924,6 @@ #endregion - public override ISession GetSession() - { - // TODO: Verify the use of this method in NH.Search and remove it - throw new NotSupportedException(); - } - public override int ExecuteNativeUpdate(NativeSQLQuerySpecification nativeSQLQuerySpecification, QueryParameters queryParameters) { using (new SessionIdLoggingContext(SessionId)) 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-04 19:16:08
|
Revision: 4410 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4410&view=rev Author: fabiomaulo Date: 2009-06-04 19:16:07 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Minor refactoring (the message now include another possible cause) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/AssertionFailure.cs Modified: trunk/nhibernate/src/NHibernate/AssertionFailure.cs =================================================================== --- trunk/nhibernate/src/NHibernate/AssertionFailure.cs 2009-06-04 17:10:56 UTC (rev 4409) +++ trunk/nhibernate/src/NHibernate/AssertionFailure.cs 2009-06-04 19:16:07 UTC (rev 4410) @@ -10,13 +10,14 @@ [Serializable] public class AssertionFailure : ApplicationException { + private const string DefaultMessage = "An AssertionFailure occurred - this may indicate a bug in NHibernate or in your custom types."; + /// <summary> /// Initializes a new instance of the <see cref="AssertionFailure"/> class. /// </summary> public AssertionFailure() : base(String.Empty) { - LogManager.GetLogger(typeof(AssertionFailure)).Error( - "An AssertionFailure occurred - this may indicate a bug in NHibernate"); + LogManager.GetLogger(typeof(AssertionFailure)).Error(DefaultMessage); } /// <summary> @@ -25,8 +26,7 @@ /// <param name="message">The message that describes the error. </param> public AssertionFailure(string message) : base(message) { - LogManager.GetLogger(typeof(AssertionFailure)).Error( - "An AssertionFailure occurred - this may indicate a bug in NHibernate", this); + LogManager.GetLogger(typeof(AssertionFailure)).Error(DefaultMessage, this); } /// <summary> @@ -40,8 +40,7 @@ /// </param> public AssertionFailure(string message, Exception innerException) : base(message, innerException) { - LogManager.GetLogger(typeof(AssertionFailure)).Error( - "An AssertionFailure occurred - this may indicate a bug in NHibernate", innerException); + LogManager.GetLogger(typeof(AssertionFailure)).Error(DefaultMessage, innerException); } /// <summary> 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 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 00:06:47
|
Revision: 4407 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4407&view=rev Author: fabiomaulo Date: 2009-06-04 00:06:41 +0000 (Thu, 04 Jun 2009) Log Message: ----------- Test for bulkUpdate with StatelessSession (with minor bug fix) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Exec/BasicExecutor.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -61,6 +61,10 @@ var parameterTypes = new List<SqlType>(Parameters.Count); foreach (var parameterSpecification in Parameters) { + if (parameterSpecification.ExpectedType == null) + { + throw new QuerySyntaxException("Can't determine SqlType of parameter " + parameterSpecification.RenderDisplayInfo()+"\n Possible cause: wrong case-sensitive property-name."); + } parameterTypes.AddRange(parameterSpecification.ExpectedType.SqlTypes(Factory)); } st = session.Batcher.PrepareCommand(CommandType.Text, sql, parameterTypes.ToArray()); Modified: trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate/Param/NamedParameterSpecification.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -39,8 +39,10 @@ return typedValue.Type.GetColumnSpan( session.Factory ); } - public override string RenderDisplayInfo() { - return "name=" + _name + ", expectedType=" + ExpectedType; + public override string RenderDisplayInfo() + { + const string format = "name={0}, expectedType={1}"; + return ExpectedType != null ? string.Format(format, _name, ExpectedType) : string.Format(format, _name, "Unknow"); } /// <summary> Modified: trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-06-03 23:41:22 UTC (rev 4406) +++ trunk/nhibernate/src/NHibernate.Test/Stateless/StatelessSessionFixture.cs 2009-06-04 00:06:41 UTC (rev 4407) @@ -1,6 +1,7 @@ using System; using System.Collections; using System.Threading; +using NHibernate.Hql.Ast.ANTLR; using NUnit.Framework; namespace NHibernate.Test.Stateless @@ -88,7 +89,7 @@ } } - [Test, Ignore("Not supported yet")] + [Test] public void HqlBulk() { IStatelessSession ss = sessions.OpenStatelessSession(); @@ -101,10 +102,10 @@ tx = ss.BeginTransaction(); int count = - ss.CreateQuery("update Document set name = :newName where name = :oldName").SetString("newName", "Foos").SetString( + ss.CreateQuery("update Document set Name = :newName where Name = :oldName").SetString("newName", "Foos").SetString( "oldName", "Blahs").ExecuteUpdate(); Assert.AreEqual(1, count, "hql-delete on stateless session"); - count = ss.CreateQuery("update Paper set color = :newColor").SetString("newColor", "Goldenrod").ExecuteUpdate(); + count = ss.CreateQuery("update Paper set Color = :newColor").SetString("newColor", "Goldenrod").ExecuteUpdate(); Assert.AreEqual(1, count, "hql-delete on stateless session"); tx.Commit(); @@ -118,6 +119,27 @@ } [Test] + public void HqlBulkWithErrorInPropertyName() + { + using (IStatelessSession ss = sessions.OpenStatelessSession()) + { + ITransaction tx = ss.BeginTransaction(); + var doc = new Document("blah blah blah", "Blahs"); + ss.Insert(doc); + var paper = new Paper {Color = "White"}; + ss.Insert(paper); + tx.Commit(); + + Assert.Throws<QuerySyntaxException>(()=> + ss.CreateQuery("update Document set name = :newName where name = :oldName").SetString("newName", "Foos").SetString + ("oldName", "Blahs").ExecuteUpdate()); + tx = ss.BeginTransaction(); + ss.CreateQuery("delete Document").ExecuteUpdate(); + ss.CreateQuery("delete Paper").ExecuteUpdate(); + tx.Commit(); + } + } + [Test] public void InitId() { Paper paper; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-03 23:41:25
|
Revision: 4406 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4406&view=rev Author: fabiomaulo Date: 2009-06-03 23:41:22 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1044 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-06-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate/Cfg/MappingSchema/Hbm.generated.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -2,7 +2,7 @@ /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -83,7 +83,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -110,7 +110,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -128,7 +128,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -193,7 +193,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -207,7 +207,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -372,7 +372,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -386,7 +386,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -413,7 +413,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheUsage { @@ -436,7 +436,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheInclude { @@ -451,7 +451,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -465,7 +465,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -524,7 +524,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOndelete { @@ -539,7 +539,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -565,7 +565,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -586,7 +586,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -618,7 +618,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -632,7 +632,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -770,7 +770,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -784,7 +784,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOuterJoinStrategy { @@ -803,7 +803,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFetchMode { @@ -818,7 +818,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLaziness { @@ -837,7 +837,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmNotFoundMode { @@ -852,7 +852,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -888,7 +888,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1005,7 +1005,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1023,7 +1023,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1041,7 +1041,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPropertyGeneration { @@ -1060,7 +1060,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1121,7 +1121,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1151,7 +1151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1255,7 +1255,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1277,7 +1277,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmRestrictedLaziness { @@ -1292,7 +1292,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1329,7 +1329,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1343,7 +1343,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1373,7 +1373,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCustomSQLCheck { @@ -1392,7 +1392,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionFetchMode { @@ -1411,7 +1411,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1591,7 +1591,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCollectionLazy { @@ -1610,7 +1610,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1829,7 +1829,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1851,7 +1851,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmTuplizerEntitymode { @@ -1870,7 +1870,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1920,7 +1920,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -1970,7 +1970,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2015,7 +2015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmUnsavedValueType { @@ -2034,7 +2034,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2086,7 +2086,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2104,7 +2104,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2158,7 +2158,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2185,7 +2185,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2210,6 +2210,7 @@ [System.Xml.Serialization.XmlElementAttribute("bag", typeof(HbmBag))] [System.Xml.Serialization.XmlElementAttribute("component", typeof(HbmComponent))] [System.Xml.Serialization.XmlElementAttribute("dynamic-component", typeof(HbmDynamicComponent))] + [System.Xml.Serialization.XmlElementAttribute("idbag", typeof(HbmIdbag))] [System.Xml.Serialization.XmlElementAttribute("list", typeof(HbmList))] [System.Xml.Serialization.XmlElementAttribute("many-to-one", typeof(HbmManyToOne))] [System.Xml.Serialization.XmlElementAttribute("map", typeof(HbmMap))] @@ -2270,7 +2271,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2334,7 +2335,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2519,7 +2520,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2713,7 +2714,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2732,7 +2733,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2751,7 +2752,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2777,7 +2778,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2807,7 +2808,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2842,7 +2843,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2877,7 +2878,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -2970,7 +2971,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3112,7 +3113,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayOuterjoin { @@ -3131,7 +3132,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPrimitivearrayFetch { @@ -3150,7 +3151,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3334,170 +3335,11 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - [System.Xml.Serialization.XmlRootAttribute("timestamp", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] - public partial class HbmTimestamp { - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("meta")] - public HbmMeta[] meta; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string name; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string node; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string column; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string access; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] - public HbmTimestampUnsavedvalue unsavedvalue; - - /// <remarks/> - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool unsavedvalueSpecified; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmTimestampSource.Vm)] - public HbmTimestampSource source; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] - public HbmVersionGeneration generated; - - public HbmTimestamp() { - this.source = HbmTimestampSource.Vm; - this.generated = HbmVersionGeneration.Never; - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmTimestampUnsavedvalue { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("null")] - Null, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("undefined")] - Undefined, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmTimestampSource { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("vm")] - Vm, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("db")] - Db, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] - public enum HbmVersionGeneration { - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("never")] - Never, - - /// <remarks/> - [System.Xml.Serialization.XmlEnumAttribute("always")] - Always, - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] - [System.Xml.Serialization.XmlRootAttribute("version", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] - public partial class HbmVersion { - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("meta")] - public HbmMeta[] meta; - - /// <remarks/> - [System.Xml.Serialization.XmlElementAttribute("column")] - public HbmColumn[] column; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string name; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string node; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public string access; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("column")] - public string column1; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute("Int32")] - public string type; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] - public string unsavedvalue; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] - public HbmVersionGeneration generated; - - /// <remarks/> - [System.Xml.Serialization.XmlAttributeAttribute()] - public bool insert; - - /// <remarks/> - [System.Xml.Serialization.XmlIgnoreAttribute()] - public bool insertSpecified; - - public HbmVersion() { - this.type = "Int32"; - this.generated = HbmVersionGeneration.Never; - } - } - - /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] - [System.SerializableAttribute()] - [System.Diagnostics.DebuggerStepThroughAttribute()] - [System.ComponentModel.DesignerCategoryAttribute("code")] - [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] [System.Xml.Serialization.XmlRootAttribute("idbag", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] public partial class HbmIdbag { @@ -3676,7 +3518,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3709,11 +3551,170 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + [System.Xml.Serialization.XmlRootAttribute("timestamp", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] + public partial class HbmTimestamp { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("meta")] + public HbmMeta[] meta; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string name; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string node; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string column; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string access; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] + public HbmTimestampUnsavedvalue unsavedvalue; + + /// <remarks/> + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool unsavedvalueSpecified; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmTimestampSource.Vm)] + public HbmTimestampSource source; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] + public HbmVersionGeneration generated; + + public HbmTimestamp() { + this.source = HbmTimestampSource.Vm; + this.generated = HbmVersionGeneration.Never; + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmTimestampUnsavedvalue { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("null")] + Null, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("undefined")] + Undefined, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmTimestampSource { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("vm")] + Vm, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("db")] + Db, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] + public enum HbmVersionGeneration { + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("never")] + Never, + + /// <remarks/> + [System.Xml.Serialization.XmlEnumAttribute("always")] + Always, + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] + [System.Xml.Serialization.XmlRootAttribute("version", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] + public partial class HbmVersion { + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("meta")] + public HbmMeta[] meta; + + /// <remarks/> + [System.Xml.Serialization.XmlElementAttribute("column")] + public HbmColumn[] column; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string name; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string node; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public string access; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("column")] + public string column1; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute("Int32")] + public string type; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute("unsaved-value")] + public string unsavedvalue; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + [System.ComponentModel.DefaultValueAttribute(HbmVersionGeneration.Never)] + public HbmVersionGeneration generated; + + /// <remarks/> + [System.Xml.Serialization.XmlAttributeAttribute()] + public bool insert; + + /// <remarks/> + [System.Xml.Serialization.XmlIgnoreAttribute()] + public bool insertSpecified; + + public HbmVersion() { + this.type = "Int32"; + this.generated = HbmVersionGeneration.Never; + } + } + + /// <remarks/> + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] + [System.SerializableAttribute()] + [System.Diagnostics.DebuggerStepThroughAttribute()] + [System.ComponentModel.DesignerCategoryAttribute("code")] + [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] [System.Xml.Serialization.XmlRootAttribute("properties", Namespace="urn:nhibernate-mapping-2.2", IsNullable=false)] public partial class HbmProperties { @@ -3761,7 +3762,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -3844,7 +3845,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(AnonymousType=true, Namespace="urn:nhibernate-mapping-2.2")] public enum HbmJoinFetch { @@ -3859,7 +3860,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4020,7 +4021,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4041,7 +4042,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4072,7 +4073,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4094,7 +4095,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4108,7 +4109,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmLockMode { @@ -4135,7 +4136,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4174,7 +4175,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4188,7 +4189,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4219,7 +4220,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4237,7 +4238,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4312,7 +4313,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4330,7 +4331,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmFlushMode { @@ -4349,7 +4350,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmCacheMode { @@ -4376,7 +4377,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4466,7 +4467,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4605,7 +4606,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4763,7 +4764,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmPolymorphismType { @@ -4778,7 +4779,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Xml.Serialization.XmlTypeAttribute(Namespace="urn:nhibernate-mapping-2.2")] public enum HbmOptimisticLockMode { @@ -4801,7 +4802,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4815,7 +4816,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4835,7 +4836,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4849,7 +4850,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4863,7 +4864,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4881,7 +4882,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4907,7 +4908,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -4925,7 +4926,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5014,7 +5015,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] @@ -5036,7 +5037,7 @@ } /// <remarks/> - [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.1001")] + [System.CodeDom.Compiler.GeneratedCodeAttribute("HbmXsd", "2.1.0.2001")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] Modified: trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-06-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate/nhibernate-mapping.xsd 2009-06-03 23:41:22 UTC (rev 4406) @@ -266,6 +266,7 @@ <xs:element ref="set" /> <xs:element ref="list" /> <xs:element ref="bag" /> + <xs:element ref="idbag" /> <xs:element ref="array" /> <xs:element ref="primitive-array" /> </xs:choice> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Domain.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,20 @@ +using System.Collections.Generic; + +namespace NHibernate.Test.NHSpecificTest.NH1044 +{ + public class Person + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual Delivery Delivery { get; set; } + } + + public class Delivery + { + public Delivery() + { + Adresses = new List<string>(); + } + public virtual IList<string> Adresses { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Fixture.cs 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,40 @@ +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1044 +{ + [TestFixture] + public class Fixture: BugTestCase + { + [Test] + public void Crud() + { + // Only as a quick check that is can work with the idbag inside the component + var p = new Person {Name = "Fiamma", Delivery = new Delivery()}; + p.Delivery.Adresses.Add("via Parenzo 96"); + p.Delivery.Adresses.Add("viale Don Bosco 192"); + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + s.Save(p); + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var pp = s.Get<Person>(p.Id); + pp.Delivery.Adresses.RemoveAt(0); + t.Commit(); + } + + using (ISession s = OpenSession()) + using (ITransaction t = s.BeginTransaction()) + { + var pp = s.Get<Person>(p.Id); + Assert.That(pp.Delivery.Adresses.Count, Is.EqualTo(1)); + s.Delete(pp); + t.Commit(); + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1044/Mappings.hbm.xml 2009-06-03 23:41:22 UTC (rev 4406) @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1044" + assembly="NHibernate.Test"> + + <class name="Person"> + <id name="Id"> + <generator class="hilo"/> + </id> + <property name="Name"/> + <component name="Delivery"> + <idbag name="Adresses" cascade="all"> + <collection-id type="int" column="poid"> + <generator class="hilo"/> + </collection-id> + <key column="owner"/> + <element column="street"/> + </idbag> + </component> + </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-03 22:56:42 UTC (rev 4405) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 23:41:22 UTC (rev 4406) @@ -350,6 +350,8 @@ <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagPartialNameFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\IntEnumsBagFixture.cs" /> <Compile Include="NHSpecificTest\ElementsEnums\Something.cs" /> + <Compile Include="NHSpecificTest\NH1044\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1044\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1093\SimpleCached.cs" /> <Compile Include="NHSpecificTest\NH1159\Contact.cs" /> @@ -1860,6 +1862,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1044\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1757\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 22:56:52
|
Revision: 4405 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4405&view=rev Author: fabiomaulo Date: 2009-06-03 22:56:42 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1427 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -345,10 +345,13 @@ //PropertiesFromXML(node, persistentClass, mappings); foreach (XmlNode subnode in node.ChildNodes) { + //I am only concerned with elements that are from the nhibernate namespace + if (subnode.NamespaceURI != Configuration.MappingSchemaXMLNS) + continue; + string name = subnode.Name; XmlAttribute nameAttribute = subnode.Attributes["name"]; string propertyName = nameAttribute == null ? null : nameAttribute.Value; - IValue value = null; var collectionBinder = new CollectionBinder(this); if (collectionBinder.CanCreate(name)) Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Fixture.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,16 @@ +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1427 +{ + [TestFixture] + public class Fixture + { + [Test] + public void TestMappingWithJoinElementContainingXmlComments() + { + Configuration cfg = TestConfigurationHelper.GetDefaultConfiguration(); + Assert.DoesNotThrow(() => cfg.AddResource("NHibernate.Test.NHSpecificTest.NH1427.Mappings.hbm.xml", GetType().Assembly)); + } + } +} Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Mappings.hbm.xml 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping + xmlns="urn:nhibernate-mapping-2.2" + assembly="NHibernate.Test" + namespace="NHibernate.Test.NHSpecificTest.NH1427"> + + <class name="Person" table="Person1"> + + <id name="PersonId" column="PersonId" type="Int32"> + <generator class="assigned" /> + </id> + + <property name="Name" column="Name" type="String" length="25" not-null="true" /> + + <join table="Person2"> + <!-- Comment: causes test to fail --> + <key column="PersonId" /> + <property name="LogonId" column="LogonId" type="String" length="16" not-null="true" /> + <property name="LastLogon" column="LastLogon" type="DateTime" not-null="false" /> + </join> + + </class> + +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1427/Person.cs 2009-06-03 22:56:42 UTC (rev 4405) @@ -0,0 +1,12 @@ +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1427 +{ + public class Person + { + public virtual int PersonId { get; set; } + public virtual string Name { get; set; } + public virtual string LogonId { get; set; } + public virtual DateTime LastLogon { 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-03 06:15:26 UTC (rev 4404) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 22:56:42 UTC (rev 4405) @@ -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\NH1427\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1427\Person.cs" /> <Compile Include="NHSpecificTest\NH1487\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1531\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1531\SampleTest.cs" /> @@ -1858,6 +1860,7 @@ <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1427\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1531\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" /> <EmbeddedResource Include="Events\PostEvents\SimpleEntity.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 06:15:31
|
Revision: 4404 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4404&view=rev Author: fabiomaulo Date: 2009-06-03 06:15:26 +0000 (Wed, 03 Jun 2009) Log Message: ----------- Fix NH-1487 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -1108,9 +1108,9 @@ { if (indexAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(indexAttribute.Value, ", "); + var tokens = new StringTokenizer(indexAttribute.Value, ",", false); foreach (string token in tokens) - table.GetOrCreateIndex(token).AddColumn(column); + table.GetOrCreateIndex(token.Trim()).AddColumn(column); } } @@ -1118,9 +1118,9 @@ { if (uniqueKeyAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(uniqueKeyAttribute.Value, ", "); + var tokens = new StringTokenizer(uniqueKeyAttribute.Value, ",", false); foreach (string token in tokens) - table.GetOrCreateUniqueKey(token).AddColumn(column); + table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } @@ -1287,9 +1287,9 @@ { if (indexAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(indexAttribute, ", "); + var tokens = new StringTokenizer(indexAttribute, ",", false); foreach (string token in tokens) - table.GetOrCreateIndex(token).AddColumn(column); + table.GetOrCreateIndex(token.Trim()).AddColumn(column); } } @@ -1297,9 +1297,9 @@ { if (uniqueKeyAttribute != null && table != null) { - StringTokenizer tokens = new StringTokenizer(uniqueKeyAttribute, ", "); + var tokens = new StringTokenizer(uniqueKeyAttribute, ",", false); foreach (string token in tokens) - table.GetOrCreateUniqueKey(token).AddColumn(column); + table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassIdBinder.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -152,16 +152,16 @@ if (columnSchema.index != null && id.Table != null) { - StringTokenizer tokens = new StringTokenizer(columnSchema.index, ", "); + var tokens = new StringTokenizer(columnSchema.index, ",", false); foreach (string token in tokens) - id.Table.GetOrCreateIndex(token).AddColumn(column); + id.Table.GetOrCreateIndex(token.Trim()).AddColumn(column); } if (columnSchema.uniquekey != null && id.Table != null) { - StringTokenizer tokens = new StringTokenizer(columnSchema.uniquekey, ", "); + var tokens = new StringTokenizer(columnSchema.uniquekey, ",", false); foreach (string token in tokens) - id.Table.GetOrCreateUniqueKey(token).AddColumn(column); + id.Table.GetOrCreateUniqueKey(token.Trim()).AddColumn(column); } } } Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1487/Fixture.cs 2009-06-03 06:15:26 UTC (rev 4404) @@ -0,0 +1,215 @@ +using System.Text; +using NHibernate.Cfg; +using NHibernate.Dialect; +using NHibernate.Tool.hbm2ddl; +using NUnit.Framework; +using System; + +namespace NHibernate.Test.NHSpecificTest.NH1487 +{ + public class Entity + { + int field; + public int Id { get { return field; } set { field = value; } } + public int A { get { return field; } set { field = value; } } + public int B { get { return field; } set { field = value; } } + public int C { get { return field; } set { field = value; } } + } + + /// <summary> + /// Summary description for TestTestCase. + /// </summary> + [TestFixture] + public class Fixture + { + + public Configuration GetConf() + { + var cfg = new Configuration(); + if (TestConfigurationHelper.hibernateConfigFile != null) + cfg.Configure(TestConfigurationHelper.hibernateConfigFile); + return cfg; + } + + [Test] + public void GenerateSchemaMultipleUniqueKeys() + { + if(!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A' unique-key='AC'/> + <property name='B' unique-key='BC'/> + <property name='C' unique-key='AC, BC'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + + cfg.AddXmlString(hbm); + + // Can create the schema + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("unique (A, C)")); + Assert.That(script, Text.Contains("unique (B, C)")); + Assert.That(script, Text.DoesNotContain("unique (C)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaMultipleIndex() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A' index='AC'/> + <property name='B' index='BC'/> + <property name='C' index='AC, BC'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index AC on Entity (A, C)")); + Assert.That(script, Text.Contains("create index BC on Entity (B, C)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaMultipleIndexOnColumn() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <generator class='assigned' /> + </id> + <property name='A'> + <column name='A' index='AC'/> + </property> + <property name='B'> + <column name='B' index='BC'/> + </property> + <property name='C'> + <column name='C' index='AC,BC'/> + </property> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index AC on Entity (A, C)")); + Assert.That(script, Text.Contains("create index BC on Entity (B, C)")); + + new SchemaExport(cfg).Drop(false, true); + } + [Test] + public void GenerateSchemaIndexOnId() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <column name='Id' index='IdxId1,IdxId2'/> + <generator class='assigned' /> + </id> + <property name='A'/> + <property name='B'/> + <property name='C'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.Append(sl), true); + var script = scriptB.ToString(); + Assert.That(script, Text.Contains("create index IdxId1 on Entity (Id)")); + Assert.That(script, Text.Contains("create index IdxId2 on Entity (Id)")); + + new SchemaExport(cfg).Drop(false, true); + } + + [Test] + public void GenerateSchemaUniqueOnId() + { + if (!(Dialect.Dialect.GetDialect() is MsSql2000Dialect)) + { + Assert.Ignore("Specific for MsSql2000Dialect"); + } + const string hbm = @"<?xml version='1.0' encoding='utf-8' ?> +<hibernate-mapping xmlns='urn:nhibernate-mapping-2.2' +namespace='NHibernate.Test.NHSpecificTest.NH1487' +assembly='NHibernate.Test'> + <class name='Entity' > + <id name='Id' > + <column name='Id' unique-key='UIdxId1,UIdxId2'/> + <generator class='assigned' /> + </id> + <property name='A'/> + <property name='B'/> + <property name='C'/> + </class> +</hibernate-mapping>"; + + var cfg = GetConf(); + cfg.AddXmlString(hbm); + + var scriptB = new StringBuilder(); + new SchemaExport(cfg).Create(sl => scriptB.AppendLine(sl), true); + var script = scriptB.ToString().Split(new[] { System.Environment.NewLine, "\n" }, StringSplitOptions.RemoveEmptyEntries); + int count=0; + foreach (var s in script) + { + if (s.Contains("unique (Id)")) + count++; + } + Assert.That(count, Is.EqualTo(2)); + + new SchemaExport(cfg).Drop(false, true); + } + + } +} \ 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-03 04:22:51 UTC (rev 4403) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-03 06:15:26 UTC (rev 4404) @@ -364,6 +364,7 @@ <Compile Include="NHSpecificTest\NH1343\Product.cs" /> <Compile Include="NHSpecificTest\NH1343\ProductFixture.cs" /> <Compile Include="NHSpecificTest\NH1388\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1487\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1531\DomainClass.cs" /> <Compile Include="NHSpecificTest\NH1531\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1553\MsSQL\Person.cs" /> 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-02 23:09:15
|
Revision: 4402 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4402&view=rev Author: fabiomaulo Date: 2009-06-02 23:09:13 +0000 (Tue, 02 Jun 2009) Log Message: ----------- Fix NH-1517 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs Modified: trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-06-01 19:58:58 UTC (rev 4401) +++ trunk/nhibernate/src/NHibernate/Event/Default/DefaultMergeEventListener.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -1,6 +1,7 @@ using System; using System.Collections; using log4net; +using NHibernate.Classic; using NHibernate.Engine; using NHibernate.Intercept; using NHibernate.Persister.Entity; @@ -230,6 +231,12 @@ } else { + // NH different behavior : NH-1517 + if (InvokeUpdateLifecycle(entity, persister, source)) + { + return; + } + copyCache[entity] = result; //before cascade! object target = source.PersistenceContext.Unproxy(result); @@ -263,6 +270,20 @@ } } + protected virtual bool InvokeUpdateLifecycle(object entity, IEntityPersister persister, IEventSource source) + { + if (persister.ImplementsLifecycle(source.EntityMode)) + { + log.Debug("calling onUpdate()"); + if (((ILifecycle)entity).OnUpdate(source) == LifecycleVeto.Veto) + { + log.Debug("update vetoed by onUpdate()"); + return true; + } + } + return false; + } + private void MarkInterceptorDirty(object entity, object target) { if (FieldInterceptionHelper.IsInstrumented(entity)) Added: trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,63 @@ +using System.Collections.Generic; +using NHibernate.Classic; + +namespace NHibernate.Test.Classic +{ + public class EntityWithLifecycle : ILifecycle + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + public virtual double Heigth { get; set; } + public virtual double Width { get; set; } + public EntityWithLifecycle() {} + public EntityWithLifecycle(string name, double heigth, double width) + { + Name = name; + Heigth = heigth; + Width = width; + } + + public virtual LifecycleVeto OnSave(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual LifecycleVeto OnUpdate(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual LifecycleVeto OnDelete(ISession s) + { + return IsValid() ? LifecycleVeto.NoVeto : LifecycleVeto.Veto; + } + + public virtual void OnLoad(ISession s, object id) + { + // nothing to do + } + + public virtual IList<string> GetBrokenRules() + { + IList<string> result = new List<string>(3); + if (string.IsNullOrEmpty(Name) || Name.Trim().Length < 2) + result.Add("The Name must have more than one char."); + if (Heigth <= 0) + result.Add("Heigth must be great than 0"); + if (Width <= 0) + result.Add("Width must be great than 0."); + return result; + } + + /// <summary> + /// Validate the state of the object before persisting it. If a violation occurs, + /// throw a <see cref="ValidationFailure" />. This method must not change the state of the object + /// by side-effect. + /// </summary> + private bool IsValid() + { + IList<string> br = GetBrokenRules(); + return br == null || br.Count == 0; + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/EntityWithLifecycle.hbm.xml 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,13 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.Classic" + assembly="NHibernate.Test" > + <class name="EntityWithLifecycle"> + <id name="Id"> + <generator class="hilo" /> + </id> + <property name="Name" type="string" length="40"/> + <property name="Heigth" type="double"/> + <property name="Width" type="double"/> + </class> +</hibernate-mapping> Added: trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/Classic/LifecycleFixture.cs 2009-06-02 23:09:13 UTC (rev 4402) @@ -0,0 +1,134 @@ +using System.Collections; +using NHibernate.Cfg; +using NUnit.Framework; + +namespace NHibernate.Test.Classic +{ + [TestFixture] + public class LifecycleFixture : TestCase + { + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "Classic.EntityWithLifecycle.hbm.xml" }; } + } + + protected override void Configure(Configuration configuration) + { + configuration.SetProperty(Environment.GenerateStatistics, "true"); + } + + [Test] + public void Save() + { + sessions.Statistics.Clear(); + using (ISession s = OpenSession()) + { + s.Save(new EntityWithLifecycle()); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); + + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Delete(v); + s.Flush(); + } + } + + [Test] + public void Update() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + } + + // update detached + sessions.Statistics.Clear(); + v.Heigth = 0; + using (ISession s = OpenSession()) + { + s.Update(v); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + // cleanup + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + public void SaveOrUpdateCopy() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + } + v.Heigth = 0; + sessions.Statistics.Clear(); + using (ISession s = OpenSession()) + { + s.SaveOrUpdateCopy(v); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + var v1 = new EntityWithLifecycle("Shinobi", 0, 10); + using (ISession s = OpenSession()) + { + s.SaveOrUpdateCopy(v1); + s.Flush(); + } + Assert.That(sessions.Statistics.EntityInsertCount, Is.EqualTo(0)); + Assert.That(sessions.Statistics.EntityUpdateCount, Is.EqualTo(0)); + + + // cleanup + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.Commit(); + } + } + + [Test] + public void Delete() + { + var v = new EntityWithLifecycle("Shinobi", 10, 10); + using (ISession s = OpenSession()) + { + s.Save(v); + s.Flush(); + sessions.Statistics.Clear(); + v.Heigth = 0; + s.Delete(v); + s.Flush(); + Assert.That(sessions.Statistics.EntityDeleteCount, Is.EqualTo(0)); + } + + using (ISession s = OpenSession()) + using (ITransaction tx = s.BeginTransaction()) + { + s.CreateQuery("delete from EntityWithLifecycle").ExecuteUpdate(); + tx.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-06-01 19:58:58 UTC (rev 4401) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-02 23:09:13 UTC (rev 4402) @@ -110,6 +110,8 @@ <Compile Include="CfgTest\LocatedInTestAssembly.cs" /> <Compile Include="CfgTest\MappingDocumentAggregatorTests.cs" /> <Compile Include="CfgTest\MappingDocumentParserTests.cs" /> + <Compile Include="Classic\EntityWithLifecycle.cs" /> + <Compile Include="Classic\LifecycleFixture.cs" /> <Compile Include="Classic\ValidatableFixture.cs" /> <Compile Include="Classic\Video.cs" /> <Compile Include="CollectionTest\A.cs" /> @@ -1851,6 +1853,7 @@ <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> + <EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1757\Mappings.hbm.xml" /> <EmbeddedResource Include="Events\PostEvents\SimpleEntity.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-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 18:19:17
|
Revision: 4399 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4399&view=rev Author: fabiomaulo Date: 2009-06-01 18:18:23 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Fix NH-1789 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -39,7 +39,9 @@ { try { - MethodInfo method = clazz.GetMethod(methodName, parametersTypes); + MethodInfo method = !clazz.IsInterface + ? clazz.GetMethod(methodName, parametersTypes) + : GetMethodFromInterface(clazz, methodName, parametersTypes); if (method == null) { return false; @@ -59,6 +61,29 @@ } } + private static MethodInfo GetMethodFromInterface(System.Type type, string methodName, System.Type[] parametersTypes) + { + const BindingFlags flags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.DeclaredOnly; + if(type == null) + { + return null; + } + MethodInfo method = type.GetMethod(methodName, flags, null, parametersTypes, null); + if (method == null) + { + System.Type[] interfaces = type.GetInterfaces(); + foreach (var @interface in interfaces) + { + method = GetMethodFromInterface(@interface, methodName, parametersTypes); + if(method != null) + { + return method; + } + } + } + return method; + } + /// <summary> /// Determine if the specified <see cref="System.Type"/> overrides the /// implementation of GetHashCode from <see cref="Object"/> @@ -67,7 +92,7 @@ /// <returns><see langword="true" /> if any type in the hierarchy overrides GetHashCode().</returns> public static bool OverridesGetHashCode(System.Type clazz) { - return OverrideMethod(clazz, "Equals", System.Type.EmptyTypes); + return OverrideMethod(clazz, "GetHashCode", System.Type.EmptyTypes); } /// <summary> Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Cat.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,34 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + public class Cat : DomainObject, ICat + { + public Cat(string name, long id) + { + Name = name; + _id = id; + } + + /// <summary> + /// NHibernate parameterless constructor + /// </summary> + protected Cat() {} + + #region ICat Members + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + public override string BusinessKey + { + get { return Name; } + } + + /// <summary> + /// Name of the cat + /// </summary> + public virtual string Name { get; set; } + + #endregion + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/DomainObject.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,133 @@ +using System; +using NHibernate.Proxy; + +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + ///<summary> + /// The base for all objects in the model + ///</summary> + [Serializable] + public abstract class DomainObject : IDomainObject + { + protected long _id; + + #region IDomainObject Members + + /// <summary> + /// Database ID. This ID doesn't have any business meaning. + /// </summary> + public virtual long ID + { + get { return _id; } + set { _id = value; } + } + + /// <summary> + /// Transient objects are not associated with an + /// item already in storage. For instance, a + /// Customer is transient if its ID is 0. + /// </summary> + public virtual bool IsTransient() + { + return ID.Equals(0); + } + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + public abstract string BusinessKey { get; } + + /// <summary> + /// Returns the concrete type of the object, not the proxy one. + /// </summary> + /// <returns></returns> + public virtual System.Type GetConcreteType() + { + return NHibernateProxyHelper.GuessClass(this); + } + + #endregion + + ///<summary> + /// The equals method works with the persistence framework too + ///</summary> + ///<param name="obj"></param> + ///<returns></returns> + public override bool Equals(object obj) + { + Console.Out.WriteLine("Calling Equals"); + + var compareTo = obj as IDomainObject; + + if (compareTo == null) + { + return false; + } + + if (compareTo.GetConcreteType() != GetConcreteType()) + { + return false; + } + + if (BothNonDefaultIds(compareTo)) + { + return ID.CompareTo(compareTo.ID).Equals(0); + } + + if ((IsTransient() || compareTo.IsTransient()) && HasSameBusinessSignatureAs(compareTo)) + { + return true; + } + + return false; + } + + private bool HasSameBusinessSignatureAs(IDomainObject compareTo) + { + return BusinessKey.Equals(compareTo.BusinessKey); + } + + private bool BothNonDefaultIds(IDomainObject compareTo) + { + return !ID.Equals(0) && !compareTo.ID.Equals(0); + } + + /// <summary> + /// Must be implemented to compare two objects + /// </summary> + public override int GetHashCode() + { + return ID.GetHashCode(); + } + + /// <summary> + /// Turn a proxy object into a "real" object. If the <paramref name="proxy"/> you give in parameter is not a INHibernateProxy, it will returns the same object without any change. + /// </summary> + /// <typeparam name="T">Type in which the unproxied object should be returned</typeparam> + /// <param name="proxy">Proxy object</param> + /// <returns>Unproxied object</returns> + public static T UnProxy<T>(object proxy) + { + //If the object is not a proxy, just cast it and returns it + if (!(proxy is INHibernateProxy)) + { + return (T) proxy; + } + + //Otherwise, use the NHibernate methods to get the implementation, and cast it + var p = (INHibernateProxy) proxy; + return (T) p.HibernateLazyInitializer.GetImplementation(); + } + + /// <summary> + /// Turn a proxy object into a "real" object. If the <paramref name="proxy"/> you give in parameter is not a INHibernateProxy, it will returns the same object without any change. + /// </summary> + /// <param name="proxy">Proxy object</param> + /// <returns>Unproxied object</returns> + public static object UnProxy(object proxy) + { + return UnProxy<object>(proxy); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ICat.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,13 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + /// <summary> + /// An interface + /// </summary> + public interface ICat : IDomainObject + { + /// <summary> + /// Name of the cat + /// </summary> + string Name { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/IDomainObject.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,35 @@ +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + /// <summary> + /// Domain Object + /// </summary> + public interface IDomainObject + { + /// <summary> + /// Database unique ID for this object. This ID shouldn't have any business meaning. + /// </summary> + long ID { get; set; } + + ///<summary> + /// This is a string which uniquely identifies an instance in the case that the ids + /// are both transient + ///</summary> + string BusinessKey { get; } + + /// <summary> + /// Transient objects are not associated with an + /// item already in storage. For instance, a + /// Customer is transient if its ID is 0. + /// </summary> + bool IsTransient(); + + /// <summary> + /// Returns the concrete type of the object, not the proxy one. + /// </summary> + /// <returns></returns> + System.Type GetConcreteType(); + + bool Equals(object that); + int GetHashCode(); + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/Mappings.hbm.xml 2009-06-01 18:18:23 UTC (rev 4399) @@ -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.NH1789"> + <class name="ICat"> + <id name="ID"> + <generator class="assigned" /> + </id> + + <discriminator column="Type"></discriminator> + + <property name="Name" /> + + <subclass name="Cat" discriminator-value="cat"></subclass> + + </class> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1789/ProxyEqualityProblemTest.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -0,0 +1,124 @@ +using System.Collections; +using NHibernate.Proxy; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1789 +{ + [TestFixture] + public class ProxyEqualityProblemTest : BugTestCase + { + protected override void OnSetUp() + { + base.OnSetUp(); + using (ISession session = OpenSession()) + { + ICat cat1 = new Cat("Marcel", 1); + ICat cat2 = new Cat("Maurice", 2); + + session.Save(cat1); + session.Save(cat2); + session.Flush(); + } + } + + protected override void OnTearDown() + { + base.OnTearDown(); + using (ISession session = OpenSession()) + { + string hql = "from System.Object"; + session.Delete(hql); + session.Flush(); + } + } + + /// <summary> + /// This test fails: when compariing a proxy with a non-proxy, I want the proxy to use the Equals() method on DomainObject to check for equality. + /// It doesn't do it, so the equality fails. + /// </summary> + [Test] + public void TestProxyEqualityProblem() + { + using (ISession session = OpenSession()) + { + //We load a proxy version of Maurice + var mauriceProxy = session.Load<ICat>((long) 2); + + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + + //From it's proxy, we get a non-proxied (concrete?) version + var mauriceNonProxy = DomainObject.UnProxy<ICat>(mauriceProxy); + + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + + //We check if the name and ID matches (as they should be because they are the same entity!) + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Now here's the problem: + //When calling Equals() on the non-proxy, everything works (calling the overriden Equals() method on DomainObject as it should be) + Assert.IsTrue(mauriceNonProxy.Equals(mauriceProxy), "The two instances should be declared equal"); + + //But when calling it on the proxy, it doesn't, and they return a false for the equality, and that's a bug IMHO + bool condition = mauriceProxy.Equals(mauriceNonProxy); + Assert.IsTrue(condition, "The two instances should be declared equal"); + } + } + + /// <summary> + /// Here, instead of querying an ICat, we query a Cat directly: everything works, and DomainObject.Equals() is properly called on the proxy. + /// </summary> + [Test] + public void TestProxyEqualityWhereItDoesWork() + { + using (ISession session = OpenSession()) + { + //We load a proxy version of Maurice + var mauriceProxy = session.Load<Cat>((long) 2); + + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + + //From it's proxy, we get a non-proxied (concrete?) version + var mauriceNonProxy = DomainObject.UnProxy<Cat>(mauriceProxy); + + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + + //We check if the name and ID matches (as they should be because they are the same entity!) + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Because we queried a concrete class (Cat instead of ICat), here it works both ways: + Assert.IsTrue(mauriceNonProxy.Equals(mauriceProxy), "The two instances should be declared equal"); + Assert.IsTrue(mauriceProxy.Equals(mauriceNonProxy), "The two instances should be declared equal"); + } + } + + /// <summary> + /// That's how I discovered something was wrong: here my object is not found in the collection, even if it's there. + /// </summary> + [Test] + public void TestTheProblemWithCollection() + { + using (ISession session = OpenSession()) + { + //As before, we load a proxy, a non-proxy of the same entity, and checks everything is correct: + var mauriceProxy = session.Load<ICat>((long) 2); + Assert.IsTrue(mauriceProxy is INHibernateProxy, "The proxy should be of type INHibernateProxy"); + var mauriceNonProxy = DomainObject.UnProxy<ICat>(mauriceProxy); + Assert.IsTrue(!(mauriceNonProxy is INHibernateProxy), "The non-proxy shouldn't be of type INHibernateProxy"); + Assert.AreEqual(mauriceProxy.Name, mauriceNonProxy.Name, "The two objects should have the same name"); + Assert.AreEqual(mauriceProxy.ID, mauriceNonProxy.ID, "The two objects should have the same ID"); + + //Ok now we add the proxy version into a collection: + var collection = new ArrayList(); + collection.Add(mauriceProxy); + + //The proxy should be able to find itself: + Assert.IsTrue(collection.Contains(mauriceProxy), "The proxy should be present in the collection"); + + //Now, the non-proxy should also be able to find itself in the collection, using the Equals() on DomainObject... + Assert.IsTrue(collection.Contains(mauriceNonProxy), "The proxy should be present in the collection"); + } + } + } +} \ 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 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-01 18:18:23 UTC (rev 4399) @@ -440,6 +440,11 @@ <Compile Include="NHSpecificTest\NH1783\SampleTest.cs" /> <Compile Include="NHSpecificTest\NH1788\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1788\Person.cs" /> + <Compile Include="NHSpecificTest\NH1789\Cat.cs" /> + <Compile Include="NHSpecificTest\NH1789\DomainObject.cs" /> + <Compile Include="NHSpecificTest\NH1789\ICat.cs" /> + <Compile Include="NHSpecificTest\NH1789\IDomainObject.cs" /> + <Compile Include="NHSpecificTest\NH1789\ProxyEqualityProblemTest.cs" /> <Compile Include="NHSpecificTest\NH1792\Fixture.cs" /> <Compile Include="NHSpecificTest\NH1792\Product.cs" /> <Compile Include="NHSpecificTest\NH1794\Fixture.cs" /> @@ -1842,6 +1847,7 @@ <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1789\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1801\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1796\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> Modified: trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-01 16:46:16 UTC (rev 4398) +++ trunk/nhibernate/src/NHibernate.Test/UtilityTest/ReflectHelperFixture.cs 2009-06-01 18:18:23 UTC (rev 4399) @@ -19,6 +19,26 @@ Assert.AreEqual(1, (int) result, "Should have found value of 1"); } + public interface IMyBaseWithEqual + { + bool Equals(object that); + int GetHashCode(); + } + + public interface IMyInheritedWithEqual : IMyBaseWithEqual + { + } + + public interface IEmpty + { + + } + + public interface IComplex: IEmpty, IMyInheritedWithEqual + { + + } + [Test] public void OverridesEquals() { @@ -26,9 +46,35 @@ Assert.IsTrue(ReflectHelper.OverridesEquals(typeof(string)), "String does override equals"); Assert.IsFalse(ReflectHelper.OverridesEquals(typeof(IDisposable)), "IDisposable does not override equals"); Assert.IsTrue(ReflectHelper.OverridesEquals(typeof(BRhf)), "Base class overrides equals"); + Assert.That(!ReflectHelper.OverridesEquals(typeof (object)), "System.Object does not override."); } [Test] + public void InheritedInterfaceOverridesEquals() + { + Assert.That(ReflectHelper.OverridesEquals(typeof(IMyBaseWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesEquals(typeof(IMyInheritedWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesEquals(typeof(IComplex)), "does override."); + } + + [Test] + public void OverridesGetHashCode() + { + Assert.IsFalse(ReflectHelper.OverridesGetHashCode(this.GetType()), "ReflectHelperFixture does not override GetHashCode"); + Assert.IsTrue(ReflectHelper.OverridesGetHashCode(typeof(string)), "String does override equals"); + Assert.IsFalse(ReflectHelper.OverridesGetHashCode(typeof(IDisposable)), "IDisposable does not override GetHashCode"); + Assert.IsTrue(ReflectHelper.OverridesGetHashCode(typeof(BRhf)), "Base class overrides GetHashCode"); + Assert.That(!ReflectHelper.OverridesGetHashCode(typeof(object)), "System.Object does not override."); + } + + [Test] + public void InheritedInterfaceOverridesGetHashCode() + { + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IMyBaseWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IMyInheritedWithEqual)), "does override."); + Assert.That(ReflectHelper.OverridesGetHashCode(typeof(IComplex)), "does override."); + } + [Test] public void NoTypeFoundReturnsNull() { System.Type noType = ReflectHelper.TypeFromAssembly("noclass", "noassembly", false); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-01 16:46:16
|
Revision: 4398 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4398&view=rev Author: fabiomaulo Date: 2009-06-01 16:46:16 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Removed TODO because done Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 16:44:04 UTC (rev 4397) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 16:46:16 UTC (rev 4398) @@ -87,9 +87,6 @@ .GetGetter(theClass, propertyName); } - //TODO: add a method in here ReflectedPropertyClass and replace most calls to GetGetter - // with calls to it - /// <summary> /// Get the NHibernate <see cref="IType" /> for the named property of the <see cref="System.Type"/>. /// </summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-01 16:44:07
|
Revision: 4397 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4397&view=rev Author: fabiomaulo Date: 2009-06-01 16:44:04 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Refactoring (DRY) Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs Modified: trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 00:16:33 UTC (rev 4396) +++ trunk/nhibernate/src/NHibernate/Util/ReflectHelper.cs 2009-06-01 16:44:04 UTC (rev 4397) @@ -32,10 +32,15 @@ /// <returns><see langword="true" /> if any type in the hierarchy overrides Equals(object).</returns> public static bool OverridesEquals(System.Type clazz) { + return OverrideMethod(clazz, "Equals", new[] { typeof(object) }); + } + + private static bool OverrideMethod(System.Type clazz, string methodName, System.Type[] parametersTypes) + { try { - MethodInfo equals = clazz.GetMethod("Equals", new[] { typeof(object) }); - if (equals == null) + MethodInfo method = clazz.GetMethod(methodName, parametersTypes); + if (method == null) { return false; } @@ -43,7 +48,7 @@ { // make sure that the DeclaringType is not System.Object - if that is the // declaring type then there is no override. - return !equals.DeclaringType.Equals(typeof(object)); + return !method.DeclaringType.Equals(typeof(object)); } } catch (AmbiguousMatchException) @@ -62,26 +67,7 @@ /// <returns><see langword="true" /> if any type in the hierarchy overrides GetHashCode().</returns> public static bool OverridesGetHashCode(System.Type clazz) { - try - { - MethodInfo getHashCode = clazz.GetMethod("GetHashCode", new System.Type[0]); - if (getHashCode == null) - { - return false; - } - else - { - // make sure that the DeclaringType is not System.Object - if that is the - // declaring type then there is no override. - return !getHashCode.DeclaringType.Equals(typeof(object)); - } - } - catch (AmbiguousMatchException) - { - // an ambiguous match means that there is an override and it - // can't determine which one to use. - return true; - } + return OverrideMethod(clazz, "Equals", System.Type.EmptyTypes); } /// <summary> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-06-01 01:14:27
|
Revision: 4396 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4396&view=rev Author: fabiomaulo Date: 2009-06-01 00:16:33 +0000 (Mon, 01 Jun 2009) Log Message: ----------- Fix NH-1735 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Type/TicksType.cs trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs Modified: trunk/nhibernate/src/NHibernate/Type/TicksType.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Type/TicksType.cs 2009-05-31 22:33:06 UTC (rev 4395) +++ trunk/nhibernate/src/NHibernate/Type/TicksType.cs 2009-06-01 00:16:33 UTC (rev 4396) @@ -96,7 +96,7 @@ public IComparer Comparator { - get { return Comparer<Int64>.Default; } + get { return Comparer<DateTime>.Default; } } #endregion Modified: trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs 2009-05-31 22:33:06 UTC (rev 4395) +++ trunk/nhibernate/src/NHibernate.Test/TypesTest/TicksTypeFixture.cs 2009-06-01 00:16:33 UTC (rev 4396) @@ -28,5 +28,14 @@ TicksType type = (TicksType) NHibernateUtil.Ticks; Assert.IsTrue(type.Seed(null) is DateTime, "seed should be DateTime"); } + + [Test] + public void Comparer() + { + var type = (IVersionType)NHibernateUtil.Ticks; + object v1 = type.Seed(null); + var v2 = v1; + Assert.DoesNotThrow(() => type.Comparator.Compare(v1, v2)); + } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-31 22:33:08
|
Revision: 4395 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4395&view=rev Author: fabiomaulo Date: 2009-05-31 22:33:06 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1801 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml Modified: trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-31 20:53:09 UTC (rev 4394) +++ trunk/nhibernate/src/NHibernate/Hql/Ast/ANTLR/Tree/BinaryLogicOperatorNode.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -70,35 +70,45 @@ MutateRowValueConstructorSyntaxesIfNecessary( lhsType, rhsType ); } - protected void MutateRowValueConstructorSyntaxesIfNecessary(IType lhsType, IType rhsType) + protected void MutateRowValueConstructorSyntaxesIfNecessary(IType lhsType, IType rhsType) { // TODO : this really needs to be delayed unitl after we definitively know all node types // where this is currently a problem is parameters for which where we cannot unequivocally // resolve an expected type ISessionFactoryImplementor sessionFactory = SessionFactoryHelper.Factory; - if ( lhsType != null && rhsType != null ) + if (lhsType != null && rhsType != null) { - int lhsColumnSpan = lhsType.GetColumnSpan( sessionFactory ); - if ( lhsColumnSpan != rhsType.GetColumnSpan( sessionFactory ) ) + int lhsColumnSpan = lhsType.GetColumnSpan(sessionFactory); + var rhsColumnSpan = rhsType.GetColumnSpan(sessionFactory); + // NH different behavior NH-1801 + if (lhsColumnSpan != rhsColumnSpan && !AreCompatibleEntityTypes(lhsType, rhsType)) { - throw new TypeMismatchException( - "left and right hand sides of a binary logic operator were incompatibile [" + - lhsType.Name + " : "+ rhsType.Name + "]" - ); + throw new TypeMismatchException("left and right hand sides of a binary logic operator were incompatibile [" + + lhsType.Name + " : " + rhsType.Name + "]"); } - if ( lhsColumnSpan > 1 ) + if (lhsColumnSpan > 1) { // for dialects which are known to not support ANSI-SQL row-value-constructor syntax, // we should mutate the tree. - if ( !sessionFactory.Dialect.SupportsRowValueConstructorSyntax) + if (!sessionFactory.Dialect.SupportsRowValueConstructorSyntax) { - MutateRowValueConstructorSyntax( lhsColumnSpan ); + MutateRowValueConstructorSyntax(lhsColumnSpan); } } } } + private static bool AreCompatibleEntityTypes(IType lhsType, IType rhsType) + { + if(lhsType.IsEntityType && rhsType.IsEntityType) + { + return lhsType.ReturnedClass.IsAssignableFrom(rhsType.ReturnedClass) || + rhsType.ReturnedClass.IsAssignableFrom(lhsType.ReturnedClass); + } + return false; + } + /** * Mutate the subtree relating to a row-value-constructor to instead use * a series of ANDed predicates. This allows multi-column type comparisons Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Domain.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,24 @@ +namespace NHibernate.Test.NHSpecificTest.NH1801 +{ + public class A + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + } + + public class B + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual A A { get; set; } + } + + public class C + { + public virtual int Id { get; set; } + public virtual string Name { get; set; } + + public virtual A A { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Fixture.cs 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,57 @@ +using System.Collections; +using NUnit.Framework; + +namespace NHibernate.Test.NHSpecificTest.NH1801 +{ + [TestFixture] + public class Fixture : BugTestCase + { + [Test] + public void Test() + { + try + { + using (ISession s = OpenSession()) + { + var a1 = new A {Id = 1, Name = "A1"}; + var a2 = new A {Id = 2, Name = "A2"}; + + var b1 = new B {Id = 1, Name = "B1", A = a1}; + var b2 = new B {Id = 2, Name = "B2", A = a2}; + + var c1 = new C {Name = "C1", A = a1}; + var c2 = new C {Name = "C2", A = a2}; + + s.Save(a1); + s.Save(a2); + s.Save(b1); + s.Save(b2); + s.Save(c1); + s.Save(c2); + + s.Flush(); + } + + using (ISession s = OpenSession()) + { + IList res = s.CreateQuery("from B b, C c where b.A = c.A and b.Id = :id").SetInt32("id", 1).List(); + + Assert.That(res, Has.Count.EqualTo(1)); + + s.Flush(); + } + } + finally + { + using (ISession s = OpenSession()) + { + s.Delete("from B"); + s.Delete("from C"); + s.Delete("from A"); + + s.Flush(); + } + } + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1801/Mappings.hbm.xml 2009-05-31 22:33:06 UTC (rev 4395) @@ -0,0 +1,38 @@ +<?xml version="1.0" encoding="utf-8" ?> +<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" + namespace="NHibernate.Test.NHSpecificTest.NH1801" + assembly="NHibernate.Test"> + + <class name="A"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + </class> + + <class name="B"> + <id name="Id"> + <generator class="assigned" /> + </id> + + <property name="Name" /> + + <many-to-one name="A"/> + </class> + + <class name="C"> + <id name="Id"> + <generator class="foreign"> + <param name="property">A</param> + </generator> + </id> + <property name="Name" /> + + <one-to-one name="A" class="A" constrained="true"/> + + <!--using a many-to-one assosciation instead makes the test succeed --> + + <!--<many-to-one name="A"></many-to-one>--> + </class> +</hibernate-mapping> Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj =================================================================== --- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 20:53:09 UTC (rev 4394) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 22:33:06 UTC (rev 4395) @@ -446,6 +446,8 @@ <Compile Include="NHSpecificTest\NH1794\Person.cs" /> <Compile Include="NHSpecificTest\NH1796\Entity.cs" /> <Compile Include="NHSpecificTest\NH1796\Fixture.cs" /> + <Compile Include="NHSpecificTest\NH1801\Domain.cs" /> + <Compile Include="NHSpecificTest\NH1801\Fixture.cs" /> <Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" /> <Compile Include="HQL\HQLFunctions.cs" /> <Compile Include="HQL\Human.cs" /> @@ -1840,6 +1842,7 @@ <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> + <EmbeddedResource Include="NHSpecificTest\NH1801\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1796\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1788\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-05-31 18:39:02
|
Revision: 4393 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4393&view=rev Author: fabiomaulo Date: 2009-05-31 18:38:56 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1805 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-31 16:39:08 UTC (rev 4392) +++ trunk/nhibernate/src/NHibernate/Cfg/XmlHbmBinding/ClassBinder.cs 2009-05-31 18:38:56 UTC (rev 4393) @@ -201,7 +201,9 @@ model.OptimisticLockMode = GetOptimisticLockMode(olNode); // META ATTRIBUTES - model.MetaAttributes = GetMetas(classMapping, inheritedMetas); + model.MetaAttributes = classMapping != null + ? GetMetas(classMapping, inheritedMetas) + : GetMetas(node.SelectNodes(HbmConstants.nsMeta, namespaceManager), inheritedMetas); // PERSISTER XmlAttribute persisterNode = node.Attributes["persister"]; Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-31 18:38:56 UTC (rev 4393) @@ -165,12 +165,20 @@ Assert.That(col.ComparerClassName, Text.StartsWith("NHibernate.Test.MappingTest.NonExistingComparator")); } - [Test, Ignore("Not fixed yet.")] + [Test] public void ReadSubClasses() { PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.DomesticAnimal"); MetaAttribute metaAttribute = cm.GetMetaAttribute("Auditable"); Assert.That(metaAttribute, Is.Not.Null); + + cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Cat"); + metaAttribute = cm.GetMetaAttribute("Auditable"); + Assert.That(metaAttribute, Is.Not.Null); + + cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.Dog"); + metaAttribute = cm.GetMetaAttribute("Auditable"); + Assert.That(metaAttribute, Is.Not.Null); } } } \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-31 16:39:13
|
Revision: 4392 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4392&view=rev Author: fabiomaulo Date: 2009-05-31 16:39:08 +0000 (Sun, 31 May 2009) Log Message: ----------- Fix NH-1802 Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj Added Paths: ----------- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs Modified: trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate/Cache/FilterKey.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -48,7 +48,7 @@ public override string ToString() { - return "FilterKey[" + filterName + filterParameters + ']'; + return string.Format("FilterKey[{0}{1}]", filterName, CollectionPrinter.ToString(filterParameters)); } public static ISet CreateFilterKeys(IDictionary<string, IFilter> enabledFilters, EntityMode entityMode) Modified: trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2009-05-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate/Cache/QueryKey.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -122,12 +122,12 @@ } } - if (!CollectionHelper.DictionaryEquals(namedParameters, that.namedParameters)) + if (!CollectionHelper.SetEquals(filters, that.filters)) { return false; } - if (!CollectionHelper.SetEquals(filters, that.filters)) + if (!CollectionHelper.DictionaryEquals(namedParameters, that.namedParameters)) { return false; } @@ -217,6 +217,10 @@ .Append("; named parameters: ") .Append(print.ToString(namedParameters)); } + if (filters != null) + { + buf.Append("; filters: ").Append(CollectionPrinter.ToString(filters)); + } if (firstRow != RowSelection.NoValue) { buf.Append("; first row: ").Append(firstRow); Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,9 @@ +namespace NHibernate.Test.CacheTest +{ + public class EntityWithFilters + { + public virtual int Id { get; set; } + public virtual string Description { get; set; } + public virtual int Value { get; set; } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/EntityWithFilters.xml 2009-05-31 16:39:08 UTC (rev 4392) @@ -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.CacheTest"> + <class name="EntityWithFilters"> + <id type="int"/> + <property name="Description"/> + <property name="Value"/> + + <filter name="DescriptionLike" /> + <filter name="DescriptionEqualAndValueGT" /> + </class> + <query name="EntityWithFilters.All" cache-region="aRegion" cacheable="true"> + from EntityWithFilters + </query> + <filter-def name="DescriptionLike" condition="Description like :pLike"> + <filter-param name="pLike" type="string"/> + </filter-def> + <filter-def name="DescriptionEqualAndValueGT" condition="Description = :pDesc and Value > :pValue"> + <filter-param name="pDesc" type="string"/> + <filter-param name="pValue" type="int"/> + </filter-def> +</hibernate-mapping> \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/FilterKeyFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,112 @@ +using System.Collections; +using NHibernate.Cache; +using NHibernate.Impl; +using NUnit.Framework; + +namespace NHibernate.Test.CacheTest +{ + [TestFixture] + public class FilterKeyFixture: TestCase + { + protected override string MappingsAssembly + { + get{return "NHibernate.Test";} + } + + protected override IList Mappings + { + get { return new[] { "CacheTest.EntityWithFilters.xml" }; } + } + + [Test] + public void ToStringIncludeAll() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionLike{'pLike'='so%'}]")); + + filterName = "DescriptionEqualAndValueGT"; + f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + Assert.That(fk.ToString(), Is.EqualTo("FilterKey[DescriptionEqualAndValueGT{'pDesc'='something', 'pValue'='10'}]")); + } + + [Test] + public void Equality() + { + // Equality is aware only by parameters names not values + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + Assert.That(fk, Is.EqualTo(fk1)); + + FilterDescValueToCompare(out fk, out fk1); + Assert.That(fk, Is.EqualTo(fk1)); + } + + private void FilterDescLikeToCompare(out FilterKey fk, out FilterKey fk1) + { + const string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pLike", "%ing"); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + } + + private void FilterDescValueToCompare(out FilterKey fk, out FilterKey fk1) + { + const string filterName = "DescriptionEqualAndValueGT"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); + fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + } + + [Test] + public void NotEquality() + { + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + + FilterKey fvk, fvk1; + FilterDescValueToCompare(out fvk, out fvk1); + + Assert.That(fk, Is.Not.EqualTo(fvk)); + Assert.That(fk1, Is.Not.EqualTo(fvk1)); + } + + [Test] + public void HashCode() + { + // HashCode is aware only by parameters names not values (should work as Equal) + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + Assert.That(fk.GetHashCode(), Is.EqualTo(fk1.GetHashCode())); + + FilterDescValueToCompare(out fk, out fk1); + Assert.That(fk.GetHashCode(), Is.EqualTo(fk1.GetHashCode())); + + } + + [Test] + public void NotEqualHashCode() + { + FilterKey fk, fk1; + FilterDescLikeToCompare(out fk, out fk1); + + FilterKey fvk, fvk1; + FilterDescValueToCompare(out fvk, out fvk1); + + Assert.That(fk.GetHashCode(), Is.Not.EqualTo(fvk.GetHashCode())); + Assert.That(fk1.GetHashCode(), Is.Not.EqualTo(fvk1.GetHashCode())); + } + } +} \ No newline at end of file Added: trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs (rev 0) +++ trunk/nhibernate/src/NHibernate.Test/CacheTest/QueryKeyFixture.cs 2009-05-31 16:39:08 UTC (rev 4392) @@ -0,0 +1,147 @@ +using System.Collections; +using Iesi.Collections.Generic; +using NHibernate.Cache; +using NHibernate.Engine; +using NHibernate.Impl; +using NHibernate.SqlCommand; +using NUnit.Framework; +using Iesi.Collections; + +namespace NHibernate.Test.CacheTest +{ + [TestFixture] + public class QueryKeyFixture : TestCase + { + private readonly SqlString SqlAll = + new SqlString("select entitywith0_.id as id0_, entitywith0_.Description as Descript2_0_, entitywith0_.Value as Value0_ from EntityWithFilters entitywith0_"); + + protected override string MappingsAssembly + { + get { return "NHibernate.Test"; } + } + + protected override IList Mappings + { + get { return new[] { "CacheTest.EntityWithFilters.xml" }; } + } + + [Test] + public void EqualityWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + Assert.That(qk, Is.EqualTo(qk1)); + + QueryKeyFilterDescValueToCompare(out qk, out qk1); + Assert.That(qk, Is.EqualTo(qk1)); + } + + private void QueryKeyFilterDescLikeToCompare(out QueryKey qk, out QueryKey qk1) + { + const string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pLike", "%ing"); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk1 }; + qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + } + + private void QueryKeyFilterDescValueToCompare(out QueryKey qk, out QueryKey qk1) + { + const string filterName = "DescriptionEqualAndValueGT"; + + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + + var f1 = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f1.SetParameter("pDesc", "something").SetParameter("pValue", 11); + var fk1 = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk1 }; + qk1 = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + } + + [Test] + public void NotEqualityWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + + QueryKey qvk, qvk1; + QueryKeyFilterDescValueToCompare(out qvk, out qvk1); + + Assert.That(qk, Is.Not.EqualTo(qvk)); + Assert.That(qk1, Is.Not.EqualTo(qvk1)); + } + + [Test] + public void HashCodeWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + Assert.That(qk.GetHashCode(), Is.EqualTo(qk1.GetHashCode())); + + QueryKeyFilterDescValueToCompare(out qk, out qk1); + Assert.That(qk.GetHashCode(), Is.EqualTo(qk1.GetHashCode())); + } + + [Test] + public void NotEqualHashCodeWithFilters() + { + QueryKey qk, qk1; + QueryKeyFilterDescLikeToCompare(out qk, out qk1); + + QueryKey qvk, qvk1; + QueryKeyFilterDescValueToCompare(out qvk, out qvk1); + + Assert.That(qk.GetHashCode(), Is.Not.EqualTo(qvk.GetHashCode())); + Assert.That(qk1.GetHashCode(), Is.Not.EqualTo(qvk1.GetHashCode())); + } + + [Test] + public void ToStringWithFilters() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk }; + var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}']",fk))); + + filterName = "DescriptionEqualAndValueGT"; + f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pDesc", "something").SetParameter("pValue", 10); + fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + fks = new HashedSet<FilterKey> { fk }; + qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}']", fk))); + } + + [Test] + public void ToStringWithMoreFilters() + { + string filterName = "DescriptionLike"; + var f = new FilterImpl(sessions.GetFilterDefinition(filterName)); + f.SetParameter("pLike", "so%"); + var fk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + filterName = "DescriptionEqualAndValueGT"; + var fv = new FilterImpl(sessions.GetFilterDefinition(filterName)); + fv.SetParameter("pDesc", "something").SetParameter("pValue", 10); + var fvk = new FilterKey(filterName, f.Parameters, f.FilterDefinition.ParameterTypes, EntityMode.Poco); + + ISet<FilterKey> fks = new HashedSet<FilterKey> { fk, fvk }; + var qk = new QueryKey(sessions, SqlAll, new QueryParameters(), (ISet)fks); + Assert.That(qk.ToString(), Text.Contains(string.Format("filters: ['{0}', '{1}']", fk, fvk))); + } + } +} \ 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-30 03:49:14 UTC (rev 4391) +++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-05-31 16:39:08 UTC (rev 4392) @@ -93,7 +93,10 @@ <Compile Include="Bytecode\Lightweight\BytecodeProviderFixture.cs" /> <Compile Include="Bytecode\WrongProxyFactoryFactory.cs" /> <Compile Include="CacheTest\CacheFixture.cs" /> + <Compile Include="CacheTest\EntityWithFilters.cs" /> + <Compile Include="CacheTest\FilterKeyFixture.cs" /> <Compile Include="CacheTest\QueryCacheFixture.cs" /> + <Compile Include="CacheTest\QueryKeyFixture.cs" /> <Compile Include="CacheTest\TimestamperFixture.cs" /> <Compile Include="Cascade\Job.cs" /> <Compile Include="Cascade\JobBatch.cs" /> @@ -1833,6 +1836,7 @@ <EmbeddedResource Include="BulkManipulation\SimpleClass.hbm.xml" /> <EmbeddedResource Include="Ado\VerySimple.hbm.xml" /> <EmbeddedResource Include="Ado\AlmostSimple.hbm.xml" /> + <EmbeddedResource Include="CacheTest\EntityWithFilters.xml" /> <Content Include="DynamicEntity\package.html" /> <EmbeddedResource Include="NHSpecificTest\NH1553\MsSQL\Mappings.hbm.xml" /> <EmbeddedResource Include="NHSpecificTest\NH1788\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-30 03:49:20
|
Revision: 4391 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4391&view=rev Author: fabiomaulo Date: 2009-05-30 03:49:14 +0000 (Sat, 30 May 2009) Log Message: ----------- Fix NH-1804 introducing a new property cache.default_expiration Modified Paths: -------------- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd Modified: trunk/nhibernate/src/NHibernate/Cfg/Environment.cs =================================================================== --- trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-05-29 16:35:45 UTC (rev 4390) +++ trunk/nhibernate/src/NHibernate/Cfg/Environment.cs 2009-05-30 03:49:14 UTC (rev 4391) @@ -120,6 +120,7 @@ public const string UseSecondLevelCache = "cache.use_second_level_cache"; public const string CacheRegionPrefix = "cache.region_prefix"; public const string UseMinimalPuts = "cache.use_minimal_puts"; + public const string CacheDefaultExpiration = "cache.default_expiration"; public const string QuerySubstitutions = "query.substitutions"; /// <summary> Should named queries be checked during startup (the default is enabled). </summary> Modified: trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd =================================================================== --- trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-05-29 16:35:45 UTC (rev 4390) +++ trunk/nhibernate/src/NHibernate/nhibernate-configuration.xsd 2009-05-30 03:49:14 UTC (rev 4391) @@ -79,6 +79,7 @@ <xs:enumeration value="cache.use_second_level_cache" /> <xs:enumeration value="cache.region_prefix" /> <xs:enumeration value="cache.use_minimal_puts" /> + <xs:enumeration value="cache.default_expiration" /> <xs:enumeration value="query.substitutions" /> <xs:enumeration value="query.factory_class" /> <xs:enumeration value="query.imports" /> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-29 16:35:50
|
Revision: 4390 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4390&view=rev Author: fabiomaulo Date: 2009-05-29 16:35:45 +0000 (Fri, 29 May 2009) Log Message: ----------- Simple pagination Test using Criteria Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs Modified: trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2009-05-27 23:06:09 UTC (rev 4389) +++ trunk/nhibernate/src/NHibernate.Test/Criteria/CriteriaQueryTest.cs 2009-05-29 16:35:45 UTC (rev 4390) @@ -286,6 +286,44 @@ } [Test] + public void SimplePagination() + { + using (ISession session = OpenSession()) + using (ITransaction t = session.BeginTransaction()) + { + session.Save(new Student {Name = "Mengano", StudentNumber = 232}); + session.Save(new Student {Name = "Ayende", StudentNumber = 999}); + session.Save(new Student {Name = "Fabio", StudentNumber = 123}); + session.Save(new Student {Name = "Merlo", StudentNumber = 456}); + session.Save(new Student {Name = "Fulano", StudentNumber = 0}); + + t.Commit(); + } + + using (ISession session = OpenSession()) + using (ITransaction t = session.BeginTransaction()) + { + var result = session.CreateCriteria<Student>() + .Add(Restrictions.Gt("StudentNumber", 0L)) + .AddOrder(Order.Asc("StudentNumber")) + .SetFirstResult(1).SetMaxResults(2) + .List<Student>(); + Assert.That(result.Count, Is.EqualTo(2)); + Assert.That(result[0].StudentNumber, Is.EqualTo(232)); + Assert.That(result[1].StudentNumber, Is.EqualTo(456)); + + t.Commit(); + } + + using (ISession session = OpenSession()) + using (ITransaction t = session.BeginTransaction()) + { + session.CreateQuery("delete from Student").ExecuteUpdate(); + t.Commit(); + } + } + + [Test] public void CloningDetachedCriteriaTest() { DetachedCriteria dc = DetachedCriteria.For(typeof(Student)) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <fab...@us...> - 2009-05-27 23:06:13
|
Revision: 4389 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4389&view=rev Author: fabiomaulo Date: 2009-05-27 23:06:09 +0000 (Wed, 27 May 2009) Log Message: ----------- Test for a bug (NH-1805) to fix Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-25 22:26:28 UTC (rev 4388) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/NonReflectiveBinderFixture.cs 2009-05-27 23:06:09 UTC (rev 4389) @@ -82,7 +82,7 @@ MetaAttribute metaAttribute = cm.GetMetaAttribute("globalmutated"); Assert.That(metaAttribute, Is.Not.Null); - /*assertEquals( metaAttribute.getValues().size(), 2 ); + /*assertEquals( metaAttribute.getValues().size(), 2 ); assertEquals( "top level", metaAttribute.getValues().get(0) );*/ Assert.That(metaAttribute.Value, Is.EqualTo("wicked level")); @@ -90,8 +90,8 @@ MetaAttribute propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 3 ); - assertEquals( "top level", propertyAttribute.getValues().get(0) ); + /*assertEquals( propertyAttribute.getValues().size(), 3 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount level")); @@ -100,9 +100,9 @@ propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 4 ); - assertEquals( "top level", propertyAttribute.getValues().get(0) ); - assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); assertEquals( "monetaryamount level", propertyAttribute.getValues().get(2) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount x level")); @@ -110,8 +110,8 @@ propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 3 ); - assertEquals( "top level", propertyAttribute.getValues().get(0) ); + /*assertEquals( propertyAttribute.getValues().size(), 3 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); assertEquals( "wicked level", propertyAttribute.getValues().get(1) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("sortedemployee level")); @@ -119,7 +119,7 @@ propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 2 ); + /*assertEquals( propertyAttribute.getValues().size(), 2 ); assertEquals( "top level", propertyAttribute.getValues().get(0) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("wicked level")); @@ -129,8 +129,8 @@ Assert.That(component.MetaAttributes.Count, Is.EqualTo(4)); metaAttribute = component.GetMetaAttribute("globalmutated"); - /*assertEquals( metaAttribute.getValues().size(), 3 ); - assertEquals( "top level", metaAttribute.getValues().get(0) ); + /*assertEquals( metaAttribute.getValues().size(), 3 ); + assertEquals( "top level", metaAttribute.getValues().get(0) ); assertEquals( "wicked level", metaAttribute.getValues().get(1) );*/ Assert.That(metaAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite level")); @@ -138,9 +138,9 @@ propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 4 ); - assertEquals( "top level", propertyAttribute.getValues().get(0) ); - assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property emp level")); @@ -148,9 +148,9 @@ propertyAttribute = property.GetMetaAttribute("globalmutated"); Assert.That(propertyAttribute, Is.Not.Null); - /*assertEquals( propertyAttribute.getValues().size(), 4 ); - assertEquals( "top level", propertyAttribute.getValues().get(0) ); - assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); + /*assertEquals( propertyAttribute.getValues().size(), 4 ); + assertEquals( "top level", propertyAttribute.getValues().get(0) ); + assertEquals( "wicked level", propertyAttribute.getValues().get(1) ); assertEquals( "monetaryamount anotherSet composite level", propertyAttribute.getValues().get(2) );*/ Assert.That(propertyAttribute.Value, Is.EqualTo("monetaryamount anotherSet composite property empinone level")); } @@ -164,5 +164,13 @@ var col = (Mapping.Collection)property.Value; Assert.That(col.ComparerClassName, Text.StartsWith("NHibernate.Test.MappingTest.NonExistingComparator")); } + + [Test, Ignore("Not fixed yet.")] + public void ReadSubClasses() + { + PersistentClass cm = cfg.GetClassMapping("NHibernate.Test.MappingTest.DomesticAnimal"); + MetaAttribute metaAttribute = cm.GetMetaAttribute("Auditable"); + Assert.That(metaAttribute, Is.Not.Null); + } } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-25 22:26:28 UTC (rev 4388) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.cs 2009-05-27 23:06:09 UTC (rev 4389) @@ -1,3 +1,4 @@ +using System; using System.Collections; using Iesi.Collections; @@ -23,4 +24,32 @@ public string Emp { get; set; } public Employee Empinone { get; set; } } + + public class Animal + { + public virtual string Description { get; set; } + } + + public class Reptile : Animal + { + public virtual double BodyTemperature { get; set; } + } + + public class Lizard : Reptile { } + + public class Mammal : Animal + { + public virtual bool Pregnant { get; set; } + public virtual DateTime Birthdate { get; set; } + } + + public class DomesticAnimal : Animal + { + public virtual string Name { get; set; } + public virtual Employee Owner { get; set; } + } + + public class Cat : Animal { } + + public class Dog : Animal { } } \ No newline at end of file Modified: trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml =================================================================== --- trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-25 22:26:28 UTC (rev 4388) +++ trunk/nhibernate/src/NHibernate.Test/MappingTest/Wicked.hbm.xml 2009-05-27 23:06:09 UTC (rev 4389) @@ -56,5 +56,28 @@ <generator class="assigned"/> </id> </class> + + <class name="Animal" abstract="true"> + <id type="int"> + <generator class="hilo"/> + </id> + <discriminator column="ObjectType"/> + <property name="Description"/> + <subclass name="Reptile"> + <property name="BodyTemperature"/> + <subclass name="Lizard"/> + </subclass> + <subclass name="Mammal"> + <property name="Pregnant"/> + <property name="Birthdate" type="Date"/> + <subclass name="DomesticAnimal"> + <meta attribute="Auditable"/> + <property name="Name"/> + <many-to-one name="Owner"/> + <subclass name="Cat"/> + <subclass name="Dog"/> + </subclass> + </subclass> + </class> </hibernate-mapping> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <MAI...@he...> - 2009-05-26 18:52:08
|
Failed to deliver to '<nh...@he...>' This user rejects any mail from your e-mail address! You seems to be a spammer. |