-->
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.  [ 3 posts ] 
Author Message
 Post subject: TransientObjectException after saving object with null value
PostPosted: Fri Jan 07, 2011 9:22 am 
Newbie

Joined: Fri Jan 07, 2011 9:12 am
Posts: 3
Hi

Im facing a rather odd situation here. I get a TransientObjectException when i try to save an object, where the attribute is actually null. I allowed this attribute to be null and the relation optional.

I specially ensured that the attribute is really null when i try to save it.

Heres the stack:

Code:
Exception in thread "Thread-17" org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: ch.sisa.reportit.business.ReportItBlob; nested exception is org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ch.sisa.reportit.business.ReportItBlob
   at org.springframework.orm.hibernate3.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:654)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.convertHibernateAccessException(HibernateTransactionManager.java:793)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:664)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:754)
   at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:723)
   at org.springframework.transaction.interceptor.TransactionAspectSupport.commitTransactionAfterReturning(TransactionAspectSupport.java:374)
   at org.springframework.transaction.aspectj.AbstractTransactionAspect.ajc$afterReturning$org_springframework_transaction_aspectj_AbstractTransactionAspect$3$2a73e96c(AbstractTransactionAspect.aj:78)
   at ch.sisa.reportit.business.reports.execution.ReportExecutionService.saveReportingResult(ReportExecutionService.java:212)
   at ch.sisa.reportit.business.reports.execution.ReportExecutionService$1.run(ReportExecutionService.java:523)
Caused by: org.hibernate.TransientObjectException: object references an unsaved transient instance - save the transient instance before flushing: ch.sisa.reportit.business.ReportItBlob
   at org.hibernate.engine.ForeignKeys.getEntityIdentifierIfNotUnsaved(ForeignKeys.java:243)
   at org.hibernate.type.EntityType.getIdentifier(EntityType.java:456)
   at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:265)
   at org.hibernate.type.ManyToOneType.isDirty(ManyToOneType.java:275)
   at org.hibernate.type.TypeHelper.findDirty(TypeHelper.java:295)
   at org.hibernate.persister.entity.AbstractEntityPersister.findDirty(AbstractEntityPersister.java:3378)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.dirtyCheck(DefaultFlushEntityEventListener.java:520)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.isUpdateNecessary(DefaultFlushEntityEventListener.java:230)
   at org.hibernate.event.def.DefaultFlushEntityEventListener.onFlushEntity(DefaultFlushEntityEventListener.java:154)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEntities(AbstractFlushingEventListener.java:219)
   at org.hibernate.event.def.AbstractFlushingEventListener.flushEverythingToExecutions(AbstractFlushingEventListener.java:99)
   at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:50)
   at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
   at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
   at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
   at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:656)
   ... 6 more

And heres the code snip of the attribute:

Code:
   // workarround for lazy property fetch
   //@Cascade(value=org.hibernate.annotations.CascadeType.DELETE)
   @ManyToOne(fetch = FetchType.LAZY,optional=true)
   @JoinColumn(name = "dataFetchId",nullable=true)
   private ReportItBlob data = null;


Can someone tell me why this happens? I dont get it...

Bonus question:
As you can see, i used a @ManyToOne here. The thing about it is, ReportItBlob is used whenever i need a lazy loaded Lob object, and is therefore spread all over my beans. I dont like the idea of having dozens of empty @OneToMany in the ReportItBlob. Problem is, when i try to save/delete the @ManyToOne side of the relationship before saving/deleting the ReportItBlob i also get an exception like the one metioned before. This requires coding on the service side to manually clean the object.

Can someone tell me a more sophisticated way to solve this without this stupid code overhead?

Thanks in advance


Top
 Profile  
 
 Post subject: Re: TransientObjectException after saving object with null value
PostPosted: Thu Jan 13, 2011 4:55 am 
Newbie

Joined: Fri Jan 07, 2011 9:12 am
Posts: 3
Sorry to bumb that shameless, but the issue still exists and i cannot find a real way to fix this..


Top
 Profile  
 
 Post subject: Re: TransientObjectException after saving object with null value
PostPosted: Fri Jan 14, 2011 4:48 am 
Newbie

Joined: Fri Jan 07, 2011 9:12 am
Posts: 3
Really.. no one has at least a hint about this?


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