Comments on: nHibernate–manual session flushing https://www.anujvarma.com/nhibernatemanual-session-flushing/ Production Grade Technical Solutions | Data Encryption and Public Cloud Expert Thu, 01 Mar 2018 08:48:12 +0000 hourly 1 https://wordpress.org/?v=7.1.5 By: Bala https://www.anujvarma.com/nhibernatemanual-session-flushing/#comment-31664 Thu, 01 Mar 2018 08:48:12 +0000 http://www.anujvarma.com/?p=1757#comment-31664 I have added web reference and selected wsdl files. I have a source url & destination url. currently they are pointing to same application. (only url is different) I have to replicate object(s) from source to destination. Parent object is : orgHierarchy This has sub-objects : (nested objects) orgLevel, contact, OrgOption when i try to save the parent object in destination i get below error : object references an unsaved transient instance – save the transient instance before flushing: com.XXX.config.orghierarchy.domain.OrgLevel; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance – save the transient instance before flushing: com.XXX.config.orghierarchy.domain.OrgLevel

I have to fix this issue, please note that i wont be given database credentials I tried by setting the id’s to zero in target object but still it is throwing the same error.

Any idea how to fix this error.

]]>
By: smruti.r. parida https://www.anujvarma.com/nhibernatemanual-session-flushing/#comment-27166 Tue, 09 Jan 2018 08:34:33 +0000 http://www.anujvarma.com/?p=1757#comment-27166 I have ran into an issue when I am trying to bulk update through PUT operation using nHibernate with spring.net in my project and I am getting below exception.
“message”: “An error has occurred.”,
“exceptionMessage”: “collection [] was not processed by flush()”,
“exceptionType”: “NHibernate.AssertionFailure”,

My session saving has been written as below.
public IUnitOfWork UnitOfWork { get; set; }

public virtual T Save(T entity)
{
return Save(entity, SaveAction.Edit);
}

public virtual T Save(T entity, SaveAction action)
{
if (action == SaveAction.Edit)
{
var session = GetSession();
session.SaveOrUpdate(entity);

}
else
GetSession().Save(entity);

if (entity.HasAttributes())
entity.DynamicAttributes.Save();

return entity;
}

public virtual void Save(IEnumerable entities)
{
foreach (var entity in entities)
{
Save(entity, SaveAction.Edit);
}
}

Can u pls help me in getting rid of the exception.

]]>
By: Ryan Edwards https://www.anujvarma.com/nhibernatemanual-session-flushing/#comment-10856 Mon, 30 Mar 2015 20:35:30 +0000 http://www.anujvarma.com/?p=1757#comment-10856 Hey Anuj, thanks for this article. I’ve searched all over for help with that exception. In my case I was getting the TransientObjectException in a method that only did a select. I was pretty confused but the stack trace showed me that while doing the select, AutoFlush was called. So I simply set autoflush to Never, performed the select, then set it back to Auto. Worked like a charm..

]]>