tborowski
05-22-2007, 03:51 PM
Hi,
I recently changed my datasource over from MS Access to SQLExpress 2005. After the change, when trying to perform a HibernateTemplate.SaveOrUpdate() operation I am getting a strange error and I cannot figure out why. The error I am getting is:
"'Errors' node cannot be resolved for the specified root context."
I am using Spring.Data.NHibernate nightly build 20070204-2142.
Here is the code that calls the HibernateTemplate method:
public override Boolean Save(AttachmentXRef ai)
{
Boolean success = false;
try
{
attachTransUtil.GetTransactionChangeType(ai.Attach ment);
HibernateTemplate.SaveOrUpdate(ai.Attachment);
attachTransUtil.GetTransactionChangeType(ai);
HibernateTemplate.SaveOrUpdate((AttachmentImports) ai);
success = true;
}
catch (Exception e)
{
log.Error(e);
}
Here is my Spring-Config.xml:
<db:dbProvider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\MARS.mdf;User ID=user;Password=password;Integrated Security=True"/>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate" singleton="true">
<property name="DbProvider" ref="DbProvider" />
<property name="MappingAssemblies">
<list>
<value>DPMCore</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<!--<entry key="hibernate.show_sql" value="true" />-->
<!--<entry key="hibernate.hbm2ddl.auto" value="create" />-->
<!-- SQL Server Express DB -->
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<!--
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<entry key="hibernate.connection.connection_string" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\MARS.mdf;User ID=MARS_USER;Password=mar$User!;Integrated Security=True" />
-->
</dictionary>
</property>
</object>
I know specifically why the exception is being thrown. The reason is that some of the date properties in the Attachment object are not being set and SQL server is throwing a SqlDateTime overflow exception, but the AdoExceptionTranslator seems to be failing thus giving me the error described above.
Here is the stacktrace:
Spring.Objects.InvalidPropertyException was caught
Message="'Errors' node cannot be resolved for the specified root context."
Source="Spring.Core"
OffendingPropertyName="Errors"
StackTrace:
at Spring.Expressions.PropertyOrFieldNode.InitializeN ode(Object context)
at Spring.Expressions.PropertyOrFieldNode.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.Expression.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.ExpressionEvaluator.GetValue(Ob ject root, String expression)
at Spring.Data.Common.DbProvider.ExtractError(Excepti on e)
at Spring.Data.Support.ErrorCodeExceptionTranslator.E xtractErrorCode(Exception exception)
at Spring.Data.Support.ErrorCodeExceptionTranslator.T ranslate(String task, String sql, Exception exception)
at Spring.Data.NHibernate.HibernateAccessor.ConvertAd oAccessException(ADOException ex)
at Spring.Data.NHibernate.HibernateTemplate.Execute(I HibernateCallback action, Boolean exposeNativeSession)
at Spring.Data.NHibernate.HibernateTemplate.SaveOrUpd ate(Object entity)
at gov.usda.mars.dpm.dao.imports.ImportAttachmentDAO. Save(AttachmentXRef ai) in C:\projects\VS2005\DPSCore\DPSCore\dao\imports\Imp ortAttachmentDAO.cs:line 75
Any help would be appreciated.
Thanks!
I recently changed my datasource over from MS Access to SQLExpress 2005. After the change, when trying to perform a HibernateTemplate.SaveOrUpdate() operation I am getting a strange error and I cannot figure out why. The error I am getting is:
"'Errors' node cannot be resolved for the specified root context."
I am using Spring.Data.NHibernate nightly build 20070204-2142.
Here is the code that calls the HibernateTemplate method:
public override Boolean Save(AttachmentXRef ai)
{
Boolean success = false;
try
{
attachTransUtil.GetTransactionChangeType(ai.Attach ment);
HibernateTemplate.SaveOrUpdate(ai.Attachment);
attachTransUtil.GetTransactionChangeType(ai);
HibernateTemplate.SaveOrUpdate((AttachmentImports) ai);
success = true;
}
catch (Exception e)
{
log.Error(e);
}
Here is my Spring-Config.xml:
<db:dbProvider id="DbProvider"
provider="SqlServer-2.0"
connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\MARS.mdf;User ID=user;Password=password;Integrated Security=True"/>
<object id="SessionFactory" type="Spring.Data.NHibernate.LocalSessionFactoryObject, Spring.Data.NHibernate" singleton="true">
<property name="DbProvider" ref="DbProvider" />
<property name="MappingAssemblies">
<list>
<value>DPMCore</value>
</list>
</property>
<property name="HibernateProperties">
<dictionary>
<entry key="hibernate.connection.provider" value="NHibernate.Connection.DriverConnectionProvider" />
<!--<entry key="hibernate.show_sql" value="true" />-->
<!--<entry key="hibernate.hbm2ddl.auto" value="create" />-->
<!-- SQL Server Express DB -->
<entry key="hibernate.dialect" value="NHibernate.Dialect.MsSql2000Dialect" />
<!--
<entry key="hibernate.connection.driver_class" value="NHibernate.Driver.SqlClientDriver" />
<entry key="hibernate.connection.connection_string" value="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirector y|\MARS.mdf;User ID=MARS_USER;Password=mar$User!;Integrated Security=True" />
-->
</dictionary>
</property>
</object>
I know specifically why the exception is being thrown. The reason is that some of the date properties in the Attachment object are not being set and SQL server is throwing a SqlDateTime overflow exception, but the AdoExceptionTranslator seems to be failing thus giving me the error described above.
Here is the stacktrace:
Spring.Objects.InvalidPropertyException was caught
Message="'Errors' node cannot be resolved for the specified root context."
Source="Spring.Core"
OffendingPropertyName="Errors"
StackTrace:
at Spring.Expressions.PropertyOrFieldNode.InitializeN ode(Object context)
at Spring.Expressions.PropertyOrFieldNode.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.Expression.Get(Object context, IDictionary variables)
at Spring.Expressions.BaseNode.GetValue(Object context, IDictionary variables)
at Spring.Expressions.ExpressionEvaluator.GetValue(Ob ject root, String expression)
at Spring.Data.Common.DbProvider.ExtractError(Excepti on e)
at Spring.Data.Support.ErrorCodeExceptionTranslator.E xtractErrorCode(Exception exception)
at Spring.Data.Support.ErrorCodeExceptionTranslator.T ranslate(String task, String sql, Exception exception)
at Spring.Data.NHibernate.HibernateAccessor.ConvertAd oAccessException(ADOException ex)
at Spring.Data.NHibernate.HibernateTemplate.Execute(I HibernateCallback action, Boolean exposeNativeSession)
at Spring.Data.NHibernate.HibernateTemplate.SaveOrUpd ate(Object entity)
at gov.usda.mars.dpm.dao.imports.ImportAttachmentDAO. Save(AttachmentXRef ai) in C:\projects\VS2005\DPSCore\DPSCore\dao\imports\Imp ortAttachmentDAO.cs:line 75
Any help would be appreciated.
Thanks!