Hi,
I am using NHibernate 1.2 for connecting MS Sql Server 2005 database.
At one place in code I am calling session.Save for one of my entity object.
This works for few hours and gets records inserted into Database but after
4-5 hours of inserting it throws an error which seems to be in guts of NHibernate code. It seems that Save method of Hibernate source is calling
System.String.CopyTo in its guts and the argument "count" is being passed as less than zero.
See below error stack,
[2007-06-18 00:00:03][Error ][Navis.Common.Core.Logger]NHibernate.ADOException: could not insert: [Navis.Common.Entity.SAICHost][SQL: INSERT INTO saic_host (msg_id, msg_time, msg_type, asset_id, ocr_obj_ref, ocr_obj_ctr1, ocr_obj_ctr2, ocr_obj_chs, ocr_obj_gen1, ocr_obj_gen2, trolleyvalue, hoistvalue, message, creator, created, changer, changed, processed) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)] ---> System.ArgumentOutOfRangeException: Count cannot be less than zero.
Parameter name: count
at System.String.CopyTo(Int32 sourceIndex, Char[] destination, Int32 destinationIndex, Int32 count)
at System.IO.StreamWriter.Write(String value)
at System.IO.TextWriter.SyncTextWriter.Write(String value)
at NHibernate.Impl.BatcherImpl.LogCommand(IDbCommand command)
at NHibernate.Impl.BatcherImpl.Prepare(IDbCommand cmd)
at NHibernate.Impl.BatcherImpl.ExecuteReader(IDbCommand cmd)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session)
--- End of inner exception stack trace ---
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Boolean[] notNull, SqlCommandInfo sql, Object obj, ISessionImplementor session)
at NHibernate.Persister.Entity.AbstractEntityPersister.Insert(Object[] fields, Object obj, ISessionImplementor session)
at NHibernate.Impl.ScheduledIdentityInsertion.Execute()
at NHibernate.Impl.SessionImpl.Execute(IExecutable executable)
at NHibernate.Impl.SessionImpl.DoSave(Object theObj, EntityKey key, IEntityPersister persister, Boolean replicate, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.DoSave(Object obj, Object id, IEntityPersister persister, Boolean useIdentityColumn, CascadingAction cascadeAction, Object anything)
at NHibernate.Impl.SessionImpl.SaveWithGeneratedIdentifier(Object obj, CascadingAction action, Object anything)
at NHibernate.Impl.SessionImpl.Save(Object obj)
at Navis.Common.Consumer.DBConsumer.DBConsumer.ProcessSAICHost(Object obj, EventArgs evargs)
The code part, which does this is,
ISession session = null;
ITransaction transaction = null;
try
{
session = DatabaseHelper.GetNewSession();
transaction = session.BeginTransaction();
SAICHost inSAICHost = obj as SAICHost;
if (inSAICHost != null)
{
session.Save(inSAICHost);
}
}
catch (Exception e)
{
if (transaction != null)
transaction.Rollback();
transaction = null;
Logger.LOGEXCEPTION(e);
}
finally
{
if (transaction != null)
transaction.Commit();
transaction = null;
if (session != null)
session.Close();
session = null;
}
The hibernate.cfg.xml has below given entries,
<?xml version="1.0" encoding="utf-8" ?>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<!-- an ISessionFactory instance -->
<session-factory>
<!-- properties -->
<property name="connection.provider">NHibernate.Connection.DriverConnectionProvider</property>
<property name="connection.driver_class">NHibernate.Driver.SqlClientDriver</property>
<property name="dialect">NHibernate.Dialect.MsSql2005Dialect</property>
<property name="hibernate.connection.isolation">ReadCommitted</property>
<property name="show_sql">false</property>
<property name="connection.connection_string">Server=DELLD810-1000\SQLEXPRESS;initial catalog=edgemanager;Integrated Security=SSPI</property>
</session-factory>
</hibernate-configuration>
I am struggling with this problem since last one week and any help on this will be highly appreciated.
Ajay
|