|
From: <fab...@us...> - 2008-10-24 13:46:09
|
Revision: 3875
http://nhibernate.svn.sourceforge.net/nhibernate/?rev=3875&view=rev
Author: fabiomaulo
Date: 2008-10-24 13:45:59 +0000 (Fri, 24 Oct 2008)
Log Message:
-----------
Fix NH-1539, NH-1540, NH-1541, NH-1542 (Improv ORACLE dialect by Jaroslav Mart?\195?\161sek)
Modified Paths:
--------------
trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
Modified: trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2008-10-23 19:27:00 UTC (rev 3874)
+++ trunk/nhibernate/src/NHibernate/Dialect/Oracle9Dialect.cs 2008-10-24 13:45:59 UTC (rev 3875)
@@ -1,7 +1,8 @@
-using System;
+using System.Collections;
using System.Data;
using NHibernate.Dialect.Function;
using NHibernate.Dialect.Schema;
+using NHibernate.Engine;
using NHibernate.SqlCommand;
using Environment=NHibernate.Cfg.Environment;
using System.Data.Common;
@@ -110,15 +111,19 @@
RegisterFunction("sysdate", new NoArgSQLFunction("sysdate", NHibernateUtil.Date, false));
RegisterFunction("uid", new NoArgSQLFunction("uid", NHibernateUtil.Int32, false));
RegisterFunction("user", new NoArgSQLFunction("user", NHibernateUtil.String, false));
+ RegisterFunction("current_timestamp", new CurrentTimeStamp());
+ RegisterFunction("str", new SQLFunctionTemplate(NHibernateUtil.String, "cast(?1 as nvarchar2(2000))"));
+
// Multi-param string dialect functions...
- RegisterFunction("concat", new StandardSQLFunction("concat", NHibernateUtil.String));
+ RegisterFunction("concat", new VarArgsSQLFunction(NHibernateUtil.String, "(", "||", ")"));
RegisterFunction("instr", new StandardSQLFunction("instr", NHibernateUtil.String));
RegisterFunction("instrb", new StandardSQLFunction("instrb", NHibernateUtil.String));
RegisterFunction("lpad", new StandardSQLFunction("lpad", NHibernateUtil.String));
RegisterFunction("replace", new StandardSQLFunction("replace", NHibernateUtil.String));
RegisterFunction("rpad", new StandardSQLFunction("rpad", NHibernateUtil.String));
RegisterFunction("substr", new StandardSQLFunction("substr", NHibernateUtil.String));
+ RegisterFunction("substring", new StandardSQLFunction("substr", NHibernateUtil.String));
RegisterFunction("substrb", new StandardSQLFunction("substrb", NHibernateUtil.String));
RegisterFunction("translate", new StandardSQLFunction("translate", NHibernateUtil.String));
@@ -184,9 +189,12 @@
get { return true; }
}
- public override SqlString GetLimitString(SqlString querySqlString, bool hasOffset)
+
+ public override SqlString GetLimitString(SqlString querySqlString, int offset, int limit)
{
SqlStringBuilder pagingBuilder = new SqlStringBuilder();
+ var hasOffset = offset > 0;
+
if (hasOffset)
{
pagingBuilder.Add("select * from ( select row_.*, rownum rownum_ from ( ");
@@ -199,14 +207,14 @@
if (hasOffset)
{
pagingBuilder.Add(" ) row_ where rownum <= ");
- pagingBuilder.Add(Parameter.Placeholder);
+ pagingBuilder.Add(offset.ToString());
pagingBuilder.Add(" ) where rownum_ > ");
- pagingBuilder.Add(Parameter.Placeholder);
+ pagingBuilder.Add((limit + offset).ToString());
}
else
{
pagingBuilder.Add(" ) where rownum <= ");
- pagingBuilder.Add(Parameter.Placeholder);
+ pagingBuilder.Add(offset.ToString());
}
return pagingBuilder.ToSqlString();
@@ -243,5 +251,17 @@
{
return new OracleDataBaseSchema(connection);
}
+
+ private class CurrentTimeStamp : NoArgSQLFunction
+ {
+ public CurrentTimeStamp()
+ : base("current_timestamp", NHibernateUtil.DateTime, true)
+ { }
+
+ public override SqlString Render(IList args, ISessionFactoryImplementor factory)
+ {
+ return new SqlString(name);
+ }
+ }
}
-}
\ No newline at end of file
+}
Modified: trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs
===================================================================
--- trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2008-10-23 19:27:00 UTC (rev 3874)
+++ trunk/nhibernate/src/NHibernate/Persister/Collection/AbstractCollectionPersister.cs 2008-10-24 13:45:59 UTC (rev 3875)
@@ -1445,7 +1445,7 @@
{
KeyType.NullSafeSet(st, key, 0, session);
rs = session.Batcher.ExecuteReader(st);
- return rs.Read() ? rs.GetInt32(0) - baseIndex : 0;
+ return rs.Read() ? Convert.ToInt32(rs.GetValue(0)) - baseIndex : 0;
}
finally
{
@@ -2022,4 +2022,4 @@
#endregion
}
-}
\ No newline at end of file
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|