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

Trouble running example in Hibernate Made Easy, page 95

 
Randy Scarberry
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I run the example from Cameron McKenzie's book, the User objects are successfully added to the database, but I get the stack shown below. As you can see, this was from the seventh run. Looks like after the commit, the DefaultFlushEntityEventListener looks at the id of the User object, sees that it's still the default null value, and complains.

I'm using hibernate 3.5.2-Final set up with a maven project. I won't post my pom.xml just yet, since I'm hoping this turns out to be something simple to fix.

Randy




This is a snippet of code from the program. The trace is triggered by the commit on line 17.

 
Randy Scarberry
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, turned out that this was a very simple problem... I forgot to precede "id" in setId() with "this". So setId(Long id) didn't actually do a thing.

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35279
384
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Randy,
Welcome to JavaRanch!

Thanks for posting the solution for those who forget the same thing.
 
Cameron Wallace McKenzie
author and cow tipper
Saloon Keeper
Posts: 4968
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And more to the point, thanks for picking up a copy of my book!

Some errata for the Hibernate Made Easy book is here, at the bottom of the page:

http://www.hiberbook.com/HiberBookWeb/learn.jsp?tutorial=26errorfreecodechallenge

and here:

http://jpa.ezhibernate.com/Javacode/learn.jsp?tutorial=26errorfreecodechallenge

-Cameron McKenzie
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic