-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 
Author Message
 Post subject: Hibernate, hibernatetool, hbm2java, MySQL, Annotated POJOs
PostPosted: Tue Feb 24, 2009 10:13 pm 
Newbie

Joined: Tue Feb 24, 2009 9:03 am
Posts: 4
Hello,

I spent a long, long time today sorting out how to use Hibernate, hbm2java (generating Annotated POJOs), and the hibernatetools Ant tasks against MySQL. In my travels I found that my problems weren't unique to me, so in an effort to help future generations, I am posting this to help people. Hopefully Google indexes this place.

This is a sort of 'hello world' for the mentioned technologies, and doesn't do anything interesting (unless you consider "working" to be interesting).

First: I put all my source code here:
http://code.google.com/p/sketching-games/source/browse/#svn/trunk/schmoo

You may browse or check it out if you want.

Now, the README with the snarky bits cut out.

This source code might help you in your quest to generate Java objects
directly from a database schema. It is essentially "Hello, World" for
using the following things in a sort of belligerent cooperation:

- mysql

- hibernatetool (the Hibernate Ant Task)

- hbm2java (Generate Java code based on DB Schema(s))

- using hbm2java to generation Annotated Java code (rather than XML
files)

- The funky and disfunctional relationship between them, starring
hibernate.cfg.xml.

-*- =-------= -*-

** Easy steps to Hibernation Zen! This took me about two days of **
** headbanging so you don't have to. **

------

(1) Read this file. So far so good.

(2) Create the database using webapps/config/create_db.sql:

$ mysql -u root -p < webapps/config/create.db.sql

(3) Generate the plain old Java objets (POJOs, as they say):

$ ant hiber

(4) Compile the source code (my code in org.six11.schmoo.*, and the
generated stuff in schmoo.*):

$ ant compile

(5) Run it!

$ ./run

$ ./run Bob Sue Franklin Patricia

$ ./run Robokitty Karolina


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.