English 中文(简体)
NHibernate Blake XMLType
原标题:NHibernate Oracle XMLType issue

我们有一个功能在10g分册数据库中,该数据库的数值为XMLTYPE。 我们正试图利用参数Direction从功能中获取回归价值。 指挥物体返回。

但是,我们正像错误一样错过。

System.Data.OracleClient.OracleException (0x80131938): ORA-06550: line 1, column 27: PLS-00382: expression is of wrong type ORA-06550: line 1, column 7: PL/SQL: Statement ignored

How to resolve this?

问题回答

这是我在此工作以来的一点,目前我没有工作项目来证实这一问题,但我要说,这将解决你的问题。

我如何解决这一问题,就是在“自由”项目中进行习俗建设。 I edited the OracleDataClienthangr.cs file with the edits below. 你们应该指出,我刚刚下载了目前版本的档案,而且自我发言以来,过去两年来,这一版本略有变化。 如果你从NHibernate repo获得目前版本的档案,并且把档案与法典分开,我就会看到这些变化。 我的改动是线数(根据我的编辑)26、45、82-85。

固定装置的主题是,我不得不在XML的Oracle数据类型中增加从NHibernate绘图文档类型中绘制的地图。 甲骨质的司机将处理这类问题,但是在NHibernate使用这种疾病的逻辑缺失。 以下是这方面的规定。

开始仪式

using System.Data;
using System.Reflection;
using NHibernate.AdoNet;
using NHibernate.Engine.Query;
using NHibernate.SqlTypes;
using NHibernate.Util;

namespace NHibernate.Driver
{
    /// <summary>
    /// A NHibernate Driver for using the Oracle.DataAccess DataProvider
    /// </summary>
    /// <remarks>
    /// Code was contributed by <a href="http://sourceforge.net/users/jemcalgary/">James Mills</a>
    /// on the NHibernate forums in this 
    /// <a href="http://sourceforge.net/forum/message.php?msg_id=2952662">post</a>.
    /// </remarks>
    public class OracleDataClientDriver : ReflectionBasedDriver, IEmbeddedBatcherFactoryProvider
    {
        private const string driverAssemblyName = "Oracle.DataAccess";
        private const string connectionTypeName = "Oracle.DataAccess.Client.OracleConnection";
        private const string commandTypeName = "Oracle.DataAccess.Client.OracleCommand";
        private static readonly SqlType GuidSqlType = new SqlType(DbType.Binary, 16);
        private readonly PropertyInfo oracleDbType;
        private readonly object oracleDbTypeRefCursor; 
        private readonly object oracleDbTypeXmlType;

        /// <summary>
        /// Initializes a new instance of <see cref="OracleDataClientDriver"/>.
        /// </summary>
        /// <exception cref="HibernateException">
        /// Thrown when the <c>Oracle.DataAccess</c> assembly can not be loaded.
        /// </exception>
        public OracleDataClientDriver()
            : base(
            driverAssemblyName,
            connectionTypeName,
            commandTypeName)
        {
            System.Type parameterType = ReflectHelper.TypeFromAssembly("Oracle.DataAccess.Client.OracleParameter", driverAssemblyName, false);
            oracleDbType = parameterType.GetProperty("OracleDbType");

            System.Type oracleDbTypeEnum = ReflectHelper.TypeFromAssembly("Oracle.DataAccess.Client.OracleDbType", driverAssemblyName, false);
            oracleDbTypeRefCursor = System.Enum.Parse(oracleDbTypeEnum, "RefCursor");
            oracleDbTypeXmlType = System.Enum.Parse(oracleDbTypeEnum, "XmlType");
        }

        /// <summary></summary>
        public override bool UseNamedPrefixInSql
        {
            get { return true; }
        }

        /// <summary></summary>
        public override bool UseNamedPrefixInParameter
        {
            get { return true; }
        }

        /// <summary></summary>
        public override string NamedPrefix
        {
            get { return ":"; }
        }

        /// <remarks>
        /// This adds logic to ensure that a DbType.Boolean parameter is not created since
        /// ODP.NET doesn t support it.
        /// </remarks>
        protected override void InitializeParameter(IDbDataParameter dbParam, string name, SqlType sqlType)
        {
            // if the parameter coming in contains a boolean then we need to convert it 
            // to another type since ODP.NET doesn t support DbType.Boolean
            switch (sqlType.DbType)
            {
                case DbType.Boolean:
                    base.InitializeParameter(dbParam, name, SqlTypeFactory.Int16);
                    break;
                case DbType.Guid:
                    base.InitializeParameter(dbParam, name, GuidSqlType);
                    break;
                case DbType.Xml:
                    dbParam.ParameterName = base.FormatNameForParameter(name);
                    oracleDbType.SetValue(dbParam, oracleDbTypeXmlType, null);
                    break;
                default:
                    base.InitializeParameter(dbParam, name, sqlType);
                    break;
            }
        }

        protected override void OnBeforePrepare(IDbCommand command)
        {
            base.OnBeforePrepare(command);

            CallableParser.Detail detail = CallableParser.Parse(command.CommandText);

            if (!detail.IsCallable)
                return;

            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;

            IDbDataParameter outCursor = command.CreateParameter();
            oracleDbType.SetValue(outCursor, oracleDbTypeRefCursor, null);

            outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;

            command.Parameters.Insert(0, outCursor);
        }

        #region IEmbeddedBatcherFactoryProvider Members

        System.Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass
        {
            get { return typeof (OracleDataClientBatchingBatcherFactory); }
        }

        #endregion
    }

终结





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签