The Artima Developer Community
Sponsored Link

Java Buzz Forum
Watch out for Hibernate unsaved-value

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
dion

Posts: 5028
Nickname: dion
Registered: Feb, 2003

Dion Almaer is the Editor-in-Chief for TheServerSide.com, and is an enterprise Java evangelist
Watch out for Hibernate unsaved-value Posted: Nov 7, 2004 9:42 PM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by dion.
Original Post: Watch out for Hibernate unsaved-value
Feed Title: techno.blog(Dion)
Feed URL: http://feeds.feedburner.com/dion
Feed Description: blogging about life the universe and everything tech
Latest Java Buzz Posts
Latest Java Buzz Posts by dion
Latest Posts From techno.blog(Dion)

Advertisement
I spent far too much time on a stupid bug of my making. Part of my model had a simple One to Many relationship. Everything was fine until when creating a new child in the many side of the house I would see an error: org.springframework.dao.InvalidDataAccessApiUsageException: object references an unsaved transient instance - save the transient instance before flushing: model.Item Why was it showing this from time to time? I studied my Hibernate mapping files. I was using an inverse="true" relationship, and the cascade options looked good. Next, I checked over the code, and all seemed well. It turned out that I had set the unsaved value in a past life: <id name="id" column="id" unsaved-value="0"> The problem was occuring ONLY on a parent with the id of 0! Duh! What I would give for top class error messages when writing apps. "Hey you idiot. You have set the unsaved-value to 0. Think that may be the problem?" :)

Read: Watch out for Hibernate unsaved-value

Topic: Things I wish I knew when I first started using SWT on a Mac Previous Topic   Next Topic Topic: Case Study: MyEclipse(R) J2EE IDE

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use