From: <fab...@us...> - 2009-05-06 14:38:07
|
Revision: 4252 http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4252&view=rev Author: fabiomaulo Date: 2009-05-06 14:38:06 +0000 (Wed, 06 May 2009) Log Message: ----------- Continue port of AST tests for Updates (Discriminator entity) Modified Paths: -------------- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs Modified: trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs =================================================================== --- trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-06 14:32:08 UTC (rev 4251) +++ trunk/nhibernate/src/NHibernate.Test/HQL/Ast/BulkManipulation.cs 2009-05-06 14:38:06 UTC (rev 4252) @@ -245,6 +245,48 @@ s.CreateQuery("delete Human").ExecuteUpdate(); t.Commit(); s.Close(); + } + + [Test] + public void UpdateOnDiscriminatorSubclass() + { + var data = new TestData(this); + data.Prepare(); + + ISession s = OpenSession(); + ITransaction t = s.BeginTransaction(); + + int count = s.CreateQuery("update PettingZoo set name = name").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count"); + + t.Rollback(); + t = s.BeginTransaction(); + + count = s.CreateQuery("update PettingZoo pz set pz.name = pz.name where pz.id = :id") + .SetInt64("id", data.PettingZoo.Id) + .ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count"); + + t.Rollback(); + t = s.BeginTransaction(); + + count = s.CreateQuery("update Zoo as z set z.name = z.name").ExecuteUpdate(); + Assert.That(count, Is.EqualTo(2), "Incorrect discrim subclass update count"); + + t.Rollback(); + t = s.BeginTransaction(); + + // TODO : not so sure this should be allowed. Seems to me that if they specify an alias, + // property-refs should be required to be qualified. + count = s.CreateQuery("update Zoo as z set name = name where id = :id") + .SetInt64("id", data.Zoo.Id) + .ExecuteUpdate(); + Assert.That(count, Is.EqualTo(1), "Incorrect discrim subclass update count"); + + t.Commit(); + s.Close(); + + data.Cleanup(); } #endregion This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |