Win a copy of Mastering Corda: Blockchain for Java Developers this week in the Cloud/Virtualization forum!
  • 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Jj Roberts
  • Carey Brown
Bartenders:
  • salvin francis
  • Frits Walraven
  • Piet Souris

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: 40359
820
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: 5000
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
 
I like tacos! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic