-->
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.  [ 4 posts ] 
Author Message
 Post subject: Oracle & AnsiString
PostPosted: Wed Jan 04, 2006 11:19 am 
Newbie

Joined: Wed Jan 04, 2006 10:41 am
Posts: 2
Hi.

I am using NHibernate 1.0.1.0 with Oracle 8, dialect: NHibernate.Dialect.OracleDialect and driver NHibernate.Driver.OracleClientDriver.

I have a mapping which includes this line:

<property name="Description" column="DESCRIPTION" type="AnsiString" length="400"/>

which maps to this table field:

DESCRIPTION NVARCHAR2 (400),

which accepts null values.

When I SaveOrUpdate an object with an empty 'description' string the next exception throws:

{"Parameter ':p5': No size set for variable length data type: String." }

at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)\r\n at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)\r\n at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)\r\n at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)\r\n at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()\r\n at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)\r\n at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)\r\n at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)





And this is the SQL generated:

INSERT INTO GEPWF_GEN_PARAMETER (LAST_UPDATED_BY, LAST_UPDATE_DATE, PARAMETER_TYPE_ID, DELETE_MARK, CREATED_BY, DESCRIPTION, ACTION_ID, CREATION_DATE, NAME, PARAMETER_LENGTH, ID) VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10)


Details:


Hibernate version:

NHibernate 1.0.1.0

Mapping documents:

<?xml version="1.0" encoding="utf-8" ?>
<hibernate-mapping xmlns="urn:nhibernate-mapping-2.0">
<class name="GEP.Exides.Workflow.Model.Parameter, GEP.Exides.Workflow" table="GEPWF_GEN_PARAMETER">
<id name="Id" column="ID" type="Decimal" unsaved-value="-1">
<generator class="sequence">
<param name="sequence">GEPWF_GEN_PARAMETER_SEQ</param>
</generator>
</id>
<property name="Name" column= "NAME" type="string" length="1"/>
<property name="Description" column="DESCRIPTION" type="string" length="400" not-null="false"/>
<property name="ParameterLength" column="PARAMETER_LENGTH" type="Decimal"/>

<property name="LastUpdateDate" column="LAST_UPDATE_DATE" type="DateTime"/>
<property name="LastUpdatedBy" column="LAST_UPDATED_BY" type="AnsiString" length="9"/>
<property name="CreationDate" column="CREATION_DATE" type="DateTime"/>
<property name="CreatedBy" column="CREATED_BY" type="AnsiString" length="2"/>
<property name="DeleteMark" column="DELETE_MARK" type="Decimal"/>

<many-to-one name="ActionObj" class="GEP.Exides.Workflow.Model.Action, GEP.Exides.Workflow" column="ACTION_ID" not-null="true"/>

<many-to-one name="ParameterTypeObj" class="GEP.Exides.Workflow.Model.ParameterType, GEP.Exides.Workflow" column="PARAMETER_TYPE_ID" not-null="true"/>
</class>
</hibernate-mapping>


Full stack trace of any exception that occurs:

{"Parameter ':p5': No size set for variable length data type: String." }

at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)\r\n at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)\r\n at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)\r\n at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)\r\n at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()\r\n at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)\r\n at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)\r\n at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)


Name and version of the database you are using:

Oracle 8

The generated SQL (show_sql=true):


INSERT INTO GEPWF_GEN_PARAMETER (LAST_UPDATED_BY, LAST_UPDATE_DATE, PARAMETER_TYPE_ID, DELETE_MARK, CREATED_BY, DESCRIPTION, ACTION_ID, CREATION_DATE, NAME, PARAMETER_LENGTH, ID) VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10)

Debug level Hibernate log excerpt:

2006-01-04 16:05:37,059 [2556] DEBUG NHibernate.SQL [(null)] <(null)> - INSERT INTO GEPWF_GEN_PARAMETER (LAST_UPDATED_BY, LAST_UPDATE_DATE, PARAMETER_TYPE_ID, DELETE_MARK, CREATED_BY, DESCRIPTION, ACTION_ID, CREATION_DATE, NAME, PARAMETER_LENGTH, ID) VALUES (:p0, :p1, :p2, :p3, :p4, :p5, :p6, :p7, :p8, :p9, :p10)
2006-01-04 16:05:37,090 [2556] DEBUG NHibernate.Impl.BatcherImpl [(null)] <(null)> - Closed IDbCommand, open IDbCommands :0
2006-01-04 16:05:37,106 [2556] DEBUG NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - could not insert: [GEP.Exides.Workflow.Model.Parameter#10]
System.Exception: Parameter ':p5': No size set for variable length data type: String.
at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2006-01-04 16:05:37,106 [2556] WARN NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - System.Exception: Parameter ':p5': No size set for variable length data type: String.
at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2006-01-04 16:05:37,106 [2556] ERROR NHibernate.Util.ADOExceptionReporter [(null)] <(null)> - Parameter ':p5': No size set for variable length data type: String.
2006-01-04 16:05:37,106 [2556] ERROR NHibernate.ADOException [(null)] <(null)> - could not insert: [GEP.Exides.Workflow.Model.Parameter#10]
System.Exception: Parameter ':p5': No size set for variable length data type: String.
at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
2006-01-04 16:05:37,106 [2556] ERROR NHibernate.Impl.SessionImpl [(null)] <(null)> - could not synchronize database state with session
NHibernate.ADOException: could not insert: [GEP.Exides.Workflow.Model.Parameter#10] ---> System.Exception: Parameter ':p5': No size set for variable length data type: String.
at System.Data.OracleClient.OracleParameterBinding.PrepareForBind(OracleConnection connection, Int32& offset)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean isReader, Boolean needRowid, OciHandle& rowidDescriptor, ArrayList& refCursorParameterOrdinals)
at System.Data.OracleClient.OracleCommand.Execute(OciHandle statementHandle, CommandBehavior behavior, Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQueryInternal(Boolean needRowid, OciHandle& rowidDescriptor)
at System.Data.OracleClient.OracleCommand.ExecuteNonQuery()
at NHibernate.Impl.BatcherImpl.ExecuteNonQuery(IDbCommand cmd)
at NHibernate.Impl.NonBatchingBatcher.AddToBatch(Int32 expectedRowCount)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Boolean[] notNull, SqlString sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.EntityPersister.Insert(Object id, Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledInsertion.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.ExecuteAll(IList list)
at NHibernate.Impl.SessionImpl.Execute()


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 04, 2006 12:20 pm 
Regular
Regular

Joined: Tue Mar 15, 2005 12:38 pm
Posts: 73
Location: Bucharest
Check if the value bound to the string is not an empty string (not null, but empty). Oracle treats empty strings as null values.

If so, I couldn't find other solution for this but saving a space " " instead of empty strings. This can be done either manually, or via an interceptor or something...

Hope it helps,
Dragos


Top
 Profile  
 
 Post subject: Empty string
PostPosted: Wed Jan 04, 2006 12:27 pm 
Newbie

Joined: Wed Jan 04, 2006 10:41 am
Posts: 2
Yes it is.
I have initialized all string properties to null instead of "".

Thank you.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 13, 2006 10:46 am 
Newbie

Joined: Fri Mar 03, 2006 5:55 am
Posts: 7
I'm experiencing the same problem now.
But the field accepts nulls. What for should i initialize the fields with nulls if oracle treats empty strings as nulls. Or am i missing something.
Please can you give more detailed explanation.


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.