• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Trouble running example in Hibernate Made Easy, page 95

 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Randy,
Welcome to JavaRanch!

Thanks for posting the solution for those who forget the same thing.
 
author and cow tipper
Posts: 5009
1
Hibernate Spring Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
reply
    Bookmark Topic Watch Topic
  • New Topic