These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 
Author Message
 Post subject: ORA-12704: character set mismatch with like expression
PostPosted: Thu Aug 10, 2006 9:59 am 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
Hi,

I recieve the ORA-12704: character set mismatch error when I attempt to fetch objects using a like expression in a criteria

for example:

criteria.Add(Expression.Like("Surname", surname, MatchMode.Start));
IList<Respondant> respondants = criteria.List<Respondant>();

If I just get the list of all records in the table it works for instance this works:

ICriteria criteria = session.CreateCriteria(typeof(Respondant));
IList<Respondant> respondants = criteria.List<Respondant>();

My mapping looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0" assembly="DpdBusiness" namespace="Northgate.LandAndProperty.Dpd">
<class name="Respondant" table="REPRESENTOR">
<id name="Id" >
<column name="Link" sql-type="NUMBER" not-null="true" length="9"/>
<generator class="sequence">
<param name="sequence">LP_REPRESENTOR_SEQ</param>
</generator>
</id>
<property name="AgentNumber" column="REPRESENTORAGENTNUMBER"/>
<property name="Title" column="REPRESENTORTITLE"/>
<property name="FirstName" column="REPRESENTORFIRSTNAME"/>
<property name="Surname" >
<column name="REPRESENTORSURNAME" sql-type="VARCHAR2(20)"/>
</property>

<property name="Company" column="REPRESENTORCOMPANY"/>
<property name="HouseNameOrNumber" column="REPRESENTORNAMESEC"/>
<property name="StreetName" column="REPRESENTORSTREETNAME"/>
<property name="Locality" column="REPRESENTORLOCALITY"/>
</class>
</hibernate-mapping>

Though I have tried mapping the Surname property without the sql-type but still get the same error

1.2.0.1001

This is the output I get:

TestCase 'DpdBusinessUnitTests.DpdManagerBasicTests.FetchRespondantsMatchingSurname' failed: NHibernate.ADOException : could not execute query
----> System.Data.OracleClient.OracleException : ORA-12704: character set mismatch

c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(1646,0): at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(1593,0): at NHibernate.Loader.Loader.ListIgnoreQueryCache(ISessionImplementor session, QueryParameters queryParameters)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(1587,0): at NHibernate.Loader.Loader.List(ISessionImplementor session, QueryParameters queryParameters, ISet querySpaces, IType[] resultTypes)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Criteria\CriteriaLoader.cs(65,0): at NHibernate.Loader.Criteria.CriteriaLoader.List(ISessionImplementor session)
c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs(4907,0): at NHibernate.Impl.SessionImpl.Find(CriteriaImpl criteria, IList results)
c:\net\nhibernate\nhibernate\src\NHibernate\Impl\SessionImpl.cs(4856,0): at NHibernate.Impl.SessionImpl.Find[T](CriteriaImpl criteria)
c:\net\nhibernate\nhibernate\src\NHibernate\Impl\CriteriaImpl.cs(285,0): at NHibernate.Impl.CriteriaImpl.List[T]()
F:\Richard.Harding\Visual Studio 2005\Projects\LDFWorkFlowPrototype\DpdBusiness\DpdManager.cs(81,0): at Northgate.LandAndProperty.Dpd.DpdManager.FetchRespondantsMatchingSurname(String surname)
F:\Richard.Harding\Visual Studio 2005\Projects\LDFWorkFlowPrototype\DpdBusinessUnitTests\DpdManagerBasicTests.cs(58,0): at DpdBusinessUnitTests.DpdManagerBasicTests.FetchRespondantsMatchingSurname()
--ADOException
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()
c:\net\nhibernate\nhibernate\src\NHibernate\Impl\BatcherImpl.cs(228,0): at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(1289,0): at NHibernate.Loader.Loader.GetResultSet(IDbCommand st, RowSelection selection, ISessionImplementor session)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(393,0): at NHibernate.Loader.Loader.DoQuery(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(182,0): at NHibernate.Loader.Loader.DoQueryAndInitializeNonLazyCollections(ISessionImplementor session, QueryParameters queryParameters, Boolean returnProxies)
c:\net\nhibernate\nhibernate\src\NHibernate\Loader\Loader.cs(1636,0): at NHibernate.Loader.Loader.DoList(ISessionImplementor session, QueryParameters queryParameters)

Out: NHibernate: SELECT this_.Link as Link0_, this_.REPRESENTORLOCALITY as REPRESEN9_0_0_, this_.REPRESENTORNAMESEC as REPRESEN7_0_0_, this_.REPRESENTORSURNAME as REPRESEN5_0_0_, this_.REPRESENTORTITLE as REPRESEN3_0_0_, this_.REPRESENTORSTREETNAME as REPRESEN8_0_0_, this_.REPRESENTORFIRSTNAME as REPRESEN4_0_0_, this_.REPRESENTORAGENTNUMBER as REPRESEN2_0_0_, this_.REPRESENTORCOMPANY as REPRESEN6_0_0_ FROM REPRESENTOR this_ WHERE this_.REPRESENTORSURNAME like :p0
:p0 = 'B%'

0 succeeded, 1 failed, 0 skipped, took 1.47 seconds.

[

The database is Oracle 817 and my nhibernate config looks like this:

<hibernate-configuration xmlns="urn:nhibernate-configuration-2.0">
<session-factory>
<property name="dialect">NHibernate.Dialect.OracleDialect</property>
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.connection_string">Data Source=sx3wiz;Persist Security Info=True;User ID=lp;Password=lpsx3;</property>
<property name="hibernate.show_sql">true</property>
<mapping assembly="DpdBusiness" />
</session-factory>
</hibernate-configuration>


The generated sql looks ok to me so not sure what else to check?

any help or advice much appreciated

Thanks
Richard


Top
 Profile  
 
 Post subject: some more information
PostPosted: Thu Aug 10, 2006 11:27 am 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
ok I did some more debugging and I think the problem is that the parameter type gets mapped to an Oracle NVarchar and the column in question is a Varchar which I think would explain the ORA error

Question is what can I do to influence what oracle type gets used - is there some config or property/column mapping attribute I can set?

Thanks
Rich


Top
 Profile  
 
 Post subject: solved
PostPosted: Fri Aug 11, 2006 6:35 am 
Newbie

Joined: Thu Aug 10, 2006 9:43 am
Posts: 7
Location: South West UK
ok I thought I'd tried it but when I tested again with the property type attribute set to AnsiString it all works


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 3 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.