Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

TransientObjectException

 
Heather Garvin
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am relatively new to using Spring and Hibernate and am hoping someone will know how to handle this situation.

We retrieve on object from the database, alter the object and then pass it to other classes that perform business rule validation on the object. The validation needs to complete before the object can be persisted. When I try to go to the database for ANY data - even data completely unrelated to the transient object, Hibernate throws the TransientObjectException. Because of the Spring framework's OpenSessionViewFilter, I don't have direct access to the session.

For my named queries I have tried:
-using a named query that references a model object

-using an sql-query with no return type



I have also tried cloning the object and then saving the transient object but this doesn't work either.

Here are some of the code snippets (right now I'm using a test stub because the front end isn't finished). The person who wrote this code passes in a second IpAddress object to hold the new values that should be applied to the old object. I'm thinking they did this to work around the problem I'm having but the code wasn't finished when I took it over:
Initialize and alter the object in the presentation layer:

Pass the altered object to a service layer method() and apply the changes:

The code that invokes the named query:

Here is the stack trace. What I find interesting is that the error pertains to an AddressBlock, but no AddressBlock object is being altered; the IpAddress is being altered and then saved which should update the references inside it's AddressBlock, right?


[ December 10, 2008: Message edited by: Heather Garvin ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic