We use NH3.3.1 build.
Here is our configuration:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="hibernate-configuration"
type="NHibernate.Cfg.ConfigurationSectionHandler,
NHibernate" />
</configSections>
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2">
<session-factory>
<property name="connection.provider">
NHibernate.Connection.DriverConnectionProvider
</property>
<property name="dialect">
NHibernate.Dialect.SybaseASE15Dialect
</property>
<property name="show_sql">true</property>
<property name="command_timeout">180</property>
</session-factory>
</hibernate-configuration>
</configuration>
We got exception
NHibernate.HibernateException was caught
Message=The length of the string value exceeds the length configured in the
mapping/parameter.
Source=NHibernate
StackTrace:
at NHibernate.Type.AbstractStringType.Set(IDbCommand cmd, Object value,
Int32 index) in
C:\nHibernate3.3.2_GA_3.3.1.4000Proj_minimum\nhibernate-core\src\NHibernate\Type\AbstractStringType.cs:line
23
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand cmd, Object value,
Int32 index) in
C:\nHibernate3.3.2_GA_3.3.1.4000Proj_minimum\nhibernate-core\src\NHibernate\Type\NullableType.cs:line
180
at NHibernate.Type.NullableType.NullSafeSet(IDbCommand st, Object value,
Int32 index, Boolean[] settable, ISessionImplementor session) in
C:\nHibernate3.3.2_GA_3.3.1.4000Proj_minimum\nhibernate-core\src\NHibernate\Type\NullableType.cs:line
121
at NHibernate.Persister.Entity.AbstractEntityPersister.Dehydrate(Object id,
Object[] fields, Object rowId, Boolean[] includeProperty, Boolean[][]
includeColumns, Int32 table, IDbCommand statement, ISessionImplementor
session, Int32 index) in
C:\nHibernate3.3.2_GA_3.3.1.4000Proj_minimum\nhibernate-core\src\NHibernate\Persister\Entity\AbstractEntityPersister.cs:line
2409
InnerException:
in this line:
for (inti = 0; i < entityMetamodel.PropertySpan; i++)
{
if (includeProperty[i] && IsPropertyOfTable(i, table))
{
try
{
PropertyTypes[i].NullSafeSet(statement, fields[i], index,
includeColumns[i], session);
index += ArrayHelper.CountTrue(includeColumns[i]); //TODO: this is kinda
slow...
}
catch (Exception ex)
{
*throw new PropertyValueException("Error dehydrating property value for",
EntityName, entityMetamodel.PropertyNames[i], ex);*
}
}
}
In AbstractEntityPersister.cs
public bool SaveFundingParties(IList<FundingParty> fundingParties)
{
using (var nhSession = SessionFactory.GetNewSession())
{
//Start Transaction
using (nhSession.BeginTransaction())
{
try
{
this._fundingPartyRepository.Save(fundingParties, nhSession);
//Transaction : Committed
nhSession.Transaction.Commit();
return true;
}
catch (Exception ex)
{
throw ex;
}
}
}
}
The exception is originally thrown at :
public overridevoid Set(IDbCommandcmd, object value, intindex)
{
IDbDataParameter parameter = (IDbDataParameter)cmd.Parameters[index];
// set the parameter value before the size check, since ODBC changes the
size automatically
parameter.Value = value;
if (parameter.Size > 0 && ((string)value).Length > parameter.Size)
throw new HibernateException("The length of the string value exceeds the
length configured in the mapping/parameter.");
}
It was called by :
public voidNullSafeSet(IDbCommand cmd, object value, intindex)
{
if (value == null)
{
if (IsDebugEnabled)
{
Log.Debug("binding null to parameter: " + index);
}
//Do we check IsNullable?
// TODO: find out why a certain Parameter would not take a null value...
// From reading the .NET SDK the default is to NOT accept a null value.
// I definitely need to look into this more...
((IDataParameter) cmd.Parameters[index]).Value = DBNull.Value;
}
else
{
if (IsDebugEnabled)
{
Log.Debug("binding '" + ToString(value) + "' to parameter: " + index);
}
*Set(cmd, value, index);*
}
}
The problem is parameter.Size (the parameter is of a stringtype) is
automatically
assigned to the the length of the column of the first row /record, instead
of the size of the database column.
This is a big and should be an easy bug to fix!!!
Our project is now got stuck on this bug. Can nHibernate team fix this
please ?
Thanks,
Michael Fan
--
You received this message because you are subscribed to the Google Groups
"nhusers" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/nhusers/-/q_QCOmeHNEoJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/nhusers?hl=en.