|
From: <fab...@us...> - 2009-06-05 18:10:39
|
Revision: 4416
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=4416&view=rev
Author: fabiomaulo
Date: 2009-06-05 18:10:33 +0000 (Fri, 05 Jun 2009)
Log Message:
-----------
Fix NH-1813
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs
trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
Added Paths:
-----------
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs
trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml
Modified: trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-06-05 17:05:23 UTC (rev 4415)
+++ trunk/nhibernate/src/NHibernate/Persister/Entity/AbstractEntityPersister.cs 2009-06-05 18:10:33 UTC (rev 4416)
@@ -2632,7 +2632,7 @@
var exceptionContext = new AdoExceptionContextInfo
{
SqlException = sqle,
- Message = "could not insert: " + MessageHelper.InfoString(this),
+ Message = "could not insert: " + MessageHelper.InfoString(this, id),
Sql = sql.ToString(),
EntityName = EntityName,
EntityId = id
Modified: trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs 2009-06-05 17:05:23 UTC (rev 4415)
+++ trunk/nhibernate/src/NHibernate/SqlCommand/SqlCommandInfo.cs 2009-06-05 18:10:33 UTC (rev 4416)
@@ -29,5 +29,10 @@
{
get { return parameterTypes; }
}
+
+ public override string ToString()
+ {
+ return Text != null ? Text.ToString().Trim(): GetType().FullName;
+ }
}
}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/EntityWithUnique.cs 2009-06-05 18:10:33 UTC (rev 4416)
@@ -0,0 +1,8 @@
+namespace NHibernate.Test.NHSpecificTest.NH1813
+{
+ public class EntityWithUnique
+ {
+ public int Id { get; set; }
+ public string Description { get; set; }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Fixture.cs 2009-06-05 18:10:33 UTC (rev 4416)
@@ -0,0 +1,66 @@
+using NHibernate.Cfg;
+using NHibernate.Exceptions;
+using NUnit.Framework;
+
+namespace NHibernate.Test.NHSpecificTest.NH1813
+{
+ [TestFixture]
+ public class Fixture: BugTestCase
+ {
+ protected override void Configure(Configuration configuration)
+ {
+ configuration.SetProperty(Environment.BatchSize, "0");
+ }
+
+ [Test]
+ public void ContainSQLInInsert()
+ {
+ using (ISession s = OpenSession())
+ using(ITransaction t = s .BeginTransaction())
+ {
+ s.Save(new EntityWithUnique {Id = 1, Description = "algo"});
+ t.Commit();
+ }
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new EntityWithUnique { Id = 2, Description = "algo" });
+ var exception = Assert.Throws<GenericADOException>(t.Commit);
+ Assert.That(exception.Message, Text.Contains("INSERT"), "should contain SQL");
+ Assert.That(exception.Message, Text.Contains("#2"), "should contain id");
+ }
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from EntityWithUnique").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+
+ [Test]
+ public void ContainSQLInUpdate()
+ {
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.Save(new EntityWithUnique { Id = 1, Description = "algo" });
+ s.Save(new EntityWithUnique { Id = 2, Description = "mas" });
+ t.Commit();
+ }
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ var e = s.Get<EntityWithUnique>(2);
+ e.Description = "algo";
+ var exception = Assert.Throws<GenericADOException>(t.Commit);
+ Assert.That(exception.Message, Text.Contains("UPDATE"), "should contain SQL");
+ }
+ using (ISession s = OpenSession())
+ using (ITransaction t = s.BeginTransaction())
+ {
+ s.CreateQuery("delete from EntityWithUnique").ExecuteUpdate();
+ t.Commit();
+ }
+ }
+ }
+}
\ No newline at end of file
Added: trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml (rev 0)
+++ trunk/nhibernate/src/NHibernate.Test/NHSpecificTest/NH1813/Mappings.hbm.xml 2009-06-05 18:10:33 UTC (rev 4416)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="utf-8" ?>
+<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2"
+ namespace="NHibernate.Test.NHSpecificTest.NH1813"
+ assembly="NHibernate.Test"
+ default-lazy="false">
+ <class name="EntityWithUnique">
+ <id name="Id"/>
+ <property name="Description" unique-key="ewu_description"/>
+ </class>
+</hibernate-mapping>
\ No newline at end of file
Modified: trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj
===================================================================
--- trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 17:05:23 UTC (rev 4415)
+++ trunk/nhibernate/src/NHibernate.Test/NHibernate.Test.csproj 2009-06-05 18:10:33 UTC (rev 4416)
@@ -488,6 +488,8 @@
<Compile Include="NHSpecificTest\NH1810\Parent.cs" />
<Compile Include="NHSpecificTest\NH1812\Fixture.cs" />
<Compile Include="NHSpecificTest\NH1812\Model.cs" />
+ <Compile Include="NHSpecificTest\NH1813\EntityWithUnique.cs" />
+ <Compile Include="NHSpecificTest\NH1813\Fixture.cs" />
<Compile Include="NHSpecificTest\NH645\HQLFunctionFixture.cs" />
<Compile Include="HQL\HQLFunctions.cs" />
<Compile Include="HQL\Human.cs" />
@@ -1883,6 +1885,7 @@
<EmbeddedResource Include="CacheTest\EntityWithFilters.xml" />
<EmbeddedResource Include="Classic\EntityWithLifecycle.hbm.xml" />
<Content Include="DynamicEntity\package.html" />
+ <EmbeddedResource Include="NHSpecificTest\NH1813\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1812\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1601\Mappings.hbm.xml" />
<EmbeddedResource Include="NHSpecificTest\NH1617\Mappings.hbm.xml" />
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|