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

  • Home
  • SEARCH
  • 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 7702015
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T23:07:44+00:00 2026-05-31T23:07:44+00:00

The problem of typecasting when comparing NHibernate. The error occurs when using Telerik Dynamic

  • 0

The problem of typecasting when comparing NHibernate.
The error occurs when using Telerik Dynamic Custom Binding using NHibernate and Oracle database.

Here is the class implements the Telerik Custom Binding which works fine with the Entity Framework and MS SQL Server 2008 when used with NHibernate and Oracle database errors casts VARCHAR to NVARCHAR at this in mapinga NHibernate NO Property which specifies the type of Oracle database.

public static class DynamicDataBinding
    {
        public static IQueryable<T> Binding<T>(this IQueryable<T> query, GridCommand cmd, out int total)
        {
            query = query.Filtering(cmd.FilterDescriptors);
            total = query.Count();
            return query.Sorting(cmd.GroupDescriptors, cmd.SortDescriptors).Paging(cmd.Page, cmd.PageSize);
        }

        private static IQueryable<T> Filtering<T>(this IQueryable<T> query, IList<IFilterDescriptor> filters)
        {
            return filters.Any() ? query.Where(ExpressionBuilder.Expression<T>(filters)) : query;
        }

        private static IQueryable<T> Paging<T>(this IQueryable<T> query, int currentPage, int pageSize)
        {
            return ((pageSize > 0 && currentPage > 0) ? query.Skip((currentPage - 1) * pageSize) : query).Take(pageSize);
        }

        private static IQueryable<T> Sorting<T>(this IQueryable<T> query, IEnumerable<GroupDescriptor> groups, IEnumerable<SortDescriptor> sorts)
        {
            query = groups.Any() ? groups.Reverse().Aggregate(query, (cur, group) => cur.AddSortExp(group.SortDirection, group.Member)) : query;
            return sorts.Any() ? sorts.Aggregate(query, (cur, sort) => cur.AddSortExp(sort.SortDirection, sort.Member)) : query;
        }

        private static IQueryable<T> AddSortExp<T>(this IQueryable<T> query, ListSortDirection sort, string member)
        {
            return (sort == ListSortDirection.Ascending) ? query.OrderBy(member) : query.OrderByDescending(member);
        }
    }

Here is an error log, SQL from which the Oracle executed!

12:04:40.125 [11] DEBUG NHibernate.Engine.Query.QueryPlanCache - located HQL query plan in cache (.Count[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](NHibernate.Linq.NhQueryable`1[X4Data.Entity.IIndicatorsHistory], Quote((x, ) => (Equal(x.DeviceId, p1))), ), Quote((x, ) => (Equal(x.IndicatorId, p2))), ), Quote((item, ) => (String.op_Equality(Coalesce(NotEqual(item, NULLp3) ? item.Value : NULLp4, EmptyList).ToLower(), p6))), ), ))
12:04:40.125 [11] DEBUG NHibernate.Engine.Query.HQLQueryPlan - find: .Count[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](.Where[X4Data.Entity.IIndicatorsHistory](NHibernate.Linq.NhQueryable`1[X4Data.Entity.IIndicatorsHistory], Quote((x, ) => (Equal(x.DeviceId, p1))), ), Quote((x, ) => (Equal(x.IndicatorId, p2))), ), Quote((item, ) => (String.op_Equality(Coalesce(NotEqual(item, NULLp3) ? item.Value : NULLp4, EmptyList).ToLower(), p6))), ), )
12:04:40.125 [11] DEBUG NHibernate.Engine.QueryParameters - named parameters: {'p1'='72', 'p2'='1', 'p4'=null, 'p5'='', 'p6'='poweroff'}
12:04:40.126 [11] DEBUG NHibernate.AdoNet.AbstractBatcher - Opened new IDbCommand, open IDbCommands: 1
12:04:40.126 [11] DEBUG NHibernate.AdoNet.AbstractBatcher - Building an IDbCommand object for the SqlString: select cast(count(*) as NUMBER(10,0)) as col_0_0_ from WEBMONITOR.V_INDICATORS_HISTORY indicators0_ where indicators0_.DEVICE_ID=? and indicators0_.INDICATOR_ID=? and lower(nvl(cast(case when indicators0_.ID is not null or indicators0_.INDICATOR_ID is not null then indicators0_.VALUE else ? end as NVARCHAR2(255)), ?))=?
12:04:40.126 [11] DEBUG NHibernate.Type.Int64Type - binding '72' to parameter: 0
12:04:40.126 [11] DEBUG NHibernate.Type.Int64Type - binding '1' to parameter: 1
12:04:40.126 [11] DEBUG NHibernate.Type.StringType - binding '' to parameter: 3
12:04:40.126 [11] DEBUG NHibernate.Type.StringType - binding 'poweroff' to parameter: 4
12:04:40.126 [11] INFO  NHibernate.Loader.Loader - select cast(count(*) as NUMBER(10,0)) as col_0_0_ from WEBMONITOR.V_INDICATORS_HISTORY indicators0_ where indicators0_.DEVICE_ID=:p0 and indicators0_.INDICATOR_ID=:p1 and lower(nvl(cast(case when indicators0_.ID is not null or indicators0_.INDICATOR_ID is not null then indicators0_.VALUE else :p2 end as NVARCHAR2(255)), :p3))=:p4
12:04:40.126 [11] DEBUG NHibernate.SQL - select cast(count(*) as NUMBER(10,0)) as col_0_0_ from WEBMONITOR.V_INDICATORS_HISTORY indicators0_ where indicators0_.DEVICE_ID=:p0 and indicators0_.INDICATOR_ID=:p1 and lower(nvl(cast(case when indicators0_.ID is not null or indicators0_.INDICATOR_ID is not null then indicators0_.VALUE else :p2 end as NVARCHAR2(255)), :p3))=:p4;:p0 = 72 [Type: Int64 (0)], :p1 = 1 [Type: Int64 (0)], :p2 = NULL [Type: String (0)], :p3 = '' [Type: String (0)], :p4 = 'poweroff' [Type: String (8)]
12:04:40.126 [11] DEBUG NHibernate.Connection.DriverConnectionProvider - Obtaining IDbConnection from Driver
12:04:40.139 [11] ERROR NHibernate.AdoNet.AbstractBatcher - Could not execute query: select cast(count(*) as NUMBER(10,0)) as col_0_0_ from WEBMONITOR.V_INDICATORS_HISTORY indicators0_ where indicators0_.DEVICE_ID=:p0 and indicators0_.INDICATOR_ID=:p1 and lower(nvl(cast(case when indicators0_.ID is not null or indicators0_.INDICATOR_ID is not null then indicators0_.VALUE else :p2 end as NVARCHAR2(255)), :p3))=:p4
System.Data.OracleClient.OracleException (0x80131938): ORA-12704: character set mismatch

   at System.Data.OracleClient.OracleConnection.CheckError(OciErrorHandle errorHandle, Int32 rc)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciRowidDescriptor& rowidDescriptor, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.Execute(OciStatementHandle statementHandle, CommandBehavior behavior, ArrayList& resultParameterOrdinals)
   at System.Data.OracleClient.OracleCommand.ExecuteReader(CommandBehavior behavior)
   at System.Data.OracleClient.OracleCommand.ExecuteDbDataReader(CommandBehavior behavior)
   at System.Data.Common.DbCommand.System.Data.IDbCommand.ExecuteReader()
   at NHibernate.AdoNet.AbstractBatcher.ExecuteReader(IDbCommand cmd)

That mapping is that I use for bindings!

<?xml version="1.0" encoding="utf-8"?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.2" assembly="X4Data" namespace="X4Data.Entity" schema="WEBMONITOR">
  <class name="IndicatorsHistory" table="V_INDICATORS_HISTORY" lazy="true" >
    <composite-id>
      <key-property name="Id" column="ID" type="long"></key-property>
      <key-property name="IndicatorId" column="INDICATOR_ID" type="long"></key-property>
    </composite-id>

    <property name="Time" column="START_TIME" />
    <many-to-one class="CriticalState" lazy="false" name="CriticalState">
      <column name="CRITICAL_STATE_ID" />
    </many-to-one>
    <property name="DeviceId" column="DEVICE_ID" />
    <property name="Value" column="VALUE" />
    <property name="LocalizationKey" column="LOCALIZATION_KEY" />
    <property name="LocalizationValue" formula="(select GENERAL.RS_LOCALIZE(V_INDICATORS_HISTORY.LOCALIZATION_KEY, :CultureFilter.CultureId) FROM V_INDICATORS_HISTORY WHERE V_INDICATORS_HISTORY.INDICATOR_ID = INDICATOR_ID AND V_INDICATORS_HISTORY.ID = ID)" />
  </class>
</hibernate-mapping>

Mapping binding the presentation followed the format V_INDICATORS_HISTORY

SELECT
    uis.id,
    uis.indicator_id,
    ins.device_id,
    ins.start_time,
    uis.critical_state_id,
    uis.value,
    (SELECT localization_key
    FROM WEBMONITOR.indicator_value_codes ivc
    WHERE ivc.value = uis.value
    ) AS localization_key
FROM WEBMONITOR.integral_states ins,
    WEBMONITOR.unit_states unts,
    WEBMONITOR.unit_indicator_states uis
WHERE unts.integral_states_id = ins.id
AND uis.unit_state_id = unts.id

Help please this is very urgent, who should know how to fix the problem in NHibernate casts.

  • 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-05-31T23:07:45+00:00Added an answer on May 31, 2026 at 11:07 pm

    mapping as varchar is discussed here:

    <property name="SomeName" />
        <column sql-type="varchar" />
    </property>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Any ideas for this typecasting problem? Here's what I am trying to do. This
Problem: I have an address field from an Access database which has been converted
Problem: I need an array (datamember) in a parent class A. However, depending on
I've written an iPhone-App and encountered a problem concerning typecasting between float and int.
I'm running into a paradigm problem here. I don't know whether I should store
Problem I am using jQuery UI dialog to show a dialog box with some
Problem: I'm attempting to disable a radio button by using the code below. This
Problem I have a Silverlight 5 application using the treeview from the SDK. Now
Problem: Following error is arising if I use NavigatorContent in Repeater. Is there a
Problem description is here : http://www.spoj.pl/problems/FASHION/ Process : Took two lists as input ,

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.