Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8627729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T08:21:20+00:00 2026-06-12T08:21:20+00:00

Im trying to get NHibernate to work with Oracle 11g´s XmlType. The following Exception

  • 0

Im trying to get NHibernate to work with Oracle 11g´s XmlType.

The following Exception is thrown:

Dialect does not support DbType.Xml

My configuration looks like:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
  <session-factory>
    <property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
    <property name="dialect">NHibernate.Dialect.Oracle10gDialect</property>
    <property name="connection.driver_class">NHibernate.Driver.OracleClientDriver</property>
    <property name="connection.connection_string">...</property>
    <property name="show_sql">false</property>
  </session-factory>
</hibernate-configuration>

Sure, the XmlType functionality was introduced in 11g but I dont know the configuration Mapping. Anyone here using this feature and willing to show its config?

Thanks.

Edit 1:

The important part of the class:

    [DataMember]
    public virtual XmlDocument History { get; set; }

The important part of the mapping file:

    <property name="History" />
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T08:21:21+00:00Added an answer on June 12, 2026 at 8:21 am

    Try to use custom Oracle data client driver, here is the code:

    using System;
    using System.Data;
    using System.Data.Common;
    using System.Reflection;
    using NHibernate;
    using NHibernate.AdoNet;
    using NHibernate.Driver;
    using NHibernate.Engine.Query;
    using NHibernate.SqlTypes;
    using NHibernate.Util;
    using Oracle.DataAccess.Client;
    
    /// <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 CustomOracleDataClientDriver : 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 CustomOracleDataClientDriver()
            : base(
                DriverAssemblyName,
                ConnectionTypeName,
                CommandTypeName) {
            var parameterType = ReflectHelper.TypeFromAssembly("Oracle.DataAccess.Client.OracleParameter",
                DriverAssemblyName, false);
            this.oracleDbType = parameterType.GetProperty("OracleDbType");
    
            var oracleDbTypeEnum = ReflectHelper.TypeFromAssembly("Oracle.DataAccess.Client.OracleDbType",
                DriverAssemblyName, false);
            this.oracleDbTypeRefCursor = Enum.Parse(oracleDbTypeEnum, "RefCursor");
            this.oracleDbTypeXmlType = 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 ":"; }
        }
    
        #region IEmbeddedBatcherFactoryProvider Members
    
        Type IEmbeddedBatcherFactoryProvider.BatcherFactoryClass {
            get { return typeof (OracleDataClientBatchingBatcherFactory); }
        }
    
        #endregion
    
        /// <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 = this.FormatNameForParameter(name);
                    this.oracleDbType.SetValue(dbParam, this.oracleDbTypeXmlType, null);
                    break;
                default:
                    base.InitializeParameter(dbParam, name, sqlType);
                    break;
            }
        }
    
        protected override void OnBeforePrepare(IDbCommand command) {
            base.OnBeforePrepare(command);
    
            ((OracleCommand) command).BindByName = true;
    
            var detail = CallableParser.Parse(command.CommandText);
    
            if (!detail.IsCallable)
                return;
    
            command.CommandType = CommandType.StoredProcedure;
            command.CommandText = detail.FunctionName;
    
            var outCursor = command.CreateParameter();
            this.oracleDbType.SetValue(outCursor, this.oracleDbTypeRefCursor, null);
    
            outCursor.Direction = detail.HasReturn ? ParameterDirection.ReturnValue : ParameterDirection.Output;
    
            command.Parameters.Insert(0, outCursor);
        }
    }
    

    NHibernate configuration:

    ...
    <property name="connection.driver_class">
      Your.NameSpace.CustomOracleDataClientDriver, Your.Assembly.Name
    </property>
    <property name="dialect">
      NHibernate.Dialect.Oracle10gDialect
    </property>
    ...
    

    Here is an example https://gist.github.com/3762475

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've been racking my head trying to get Nhibernate to work with a byte
I'm trying to get to grips with NHibernate, Fluent NHibernate and Spring. Following domain-driven
I've been trying to get an NHibernate ICompositeUserType mapping to work. But am stuck
I'm trying to get NHibernate to work. I've got this class: mm.k.Domain.Kampagne (namespace/assembly is
I'm trying to work through the Your first NHibernate based application to get the
I'm trying to get a paged query to work properly using LINQ and NHibernate.
In my quest to further my knowledge, I'm trying to get get NHibernate running.
I am trying to get Fluent nHibernate to generate mappings so I can take
i'm trying to get multi tenancy working in my app - using nhibernate integration
I'm trying to get logging enabled on my application using Fluent NHibernate and log4net.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.