views:

190

answers:

4

I have been scouring the intertubes for working somewhat recent Hibernate examples. I understand it well on a conceptual level, but I'm having trouble throwing together a "hello world" program, because every one I find doesn't build for me. I should be able to adapt to different entity relationships after that, but I would settle for an example with just one or two entities, with all files where they need to be, without depending on a blac-box-build IDE like Eclipse (I like ant, and am learning Maven), ideally configured for MySQL.

  • The tutorial from the jboss site wouldn't build for me (sorry, I got frustrated and rm -r'ed the directory, but if you tell me it does build, I'll try again).
  • The tutorial that comes with Hibernate didn't even work, and isn't even consistent with its own documentation. The HTML documentation that comes with the "web" project shows different file contents than the files that came with it. And when I got it all compiled with mvn compile and tried to run it, it couldn't find the EventManager class. It even contains the wrong command to start the hsqldb.
  • The tutorial at http://www.allapplabs.com/hibernate/hibernate_comlete_example.htm contain an ant script that can't find some of the jar files it comes with.

And so on. I just got laid off, so while I see references to some good books, I can't dump $50 on one right now. I appreciate any pointers. Thanks.

+1  A: 

look into appfuse lite, choose a hibernate configuration and start poking around. A fully functional web app will help you learn whatever framework you want.

mkoryak
+2  A: 

https://www.hibernate.org/400.html is the source code page for Java Persistence/ Hibernate in Action books. It has a 'Hello, World' example. There is also a sample chapter that walks you through the example.

Maggie
+1  A: 

Look at this article, a detailed step by step example

n002213f
I had to create my own ant script to build and run it, but I got this working!!! Thank you.I want to try the others before I rate the answers, but thanks again.
dj_segfault
+1  A: 

Maybe look at the hibernate / JPA tutorial as part of the netbeans documentation. These tend to work well with examples from the IDE.

Karl

Karl
I am trying to stay away from IDE-specific examples because (1)It hides the build process, which is part of what I need to learn, and (2) I believe in automated unit tests, so I tend not to build software in IDE's even if I'm using one to develop.
dj_segfault