• Post Reply Bookmark Topic Watch Topic
  • New Topic

TransientObjectException  RSS feed

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 ]
Doody calls. I would really rather that it didn't. Comfort me wise and sterile tiny ad:
Rocket Oven Kickstarter - from the trailboss
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!