|
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.
|