classical geek

Setting up Hibernate 2.x with McKoi

Set up and verify McKoi

  • unzip mckoi install zip to ${mckoi}

  • cd ${mckoi}
  • java -jar mckoidb.jar -create “admin_user” “aupass00″ to create a DB
  • java -jar mckoidb.jar to start the DB
  • test that it’s up using SQL squirrel or similar

Set up Hibernate to talk to McKoi

  • unzip hibernate to ${hibernate}
  • copy ${mckoi}/db.conf to ${hibernate}
  • copy ${mckoi}/*jar to ${hibernate}/lib
  • create a mckoi db in ${hibernate} as above
  • edit ${hibernate}/src/hibernate.properties to uncomment the McKoi SQL entry, alter location of db.conf to ${hibernate}/db.conf and uid/pwd to values set above, and comment out the HdbSQL entry
  • cd ${hibernate} and invoke ant to build the main jar

run the example to verify that hibernate and mckoi are talking to each other

  • The example contains unusual column names enclosed by backticks. The McKoi dialect of hibernate doesn’t like this, so fix it by editing ${hibernate}/eg/org/hibernate/auction/User.hbm.xml - I changed the column names to passwd and initl (to avoid sql reserved words) and the example program worked.

  • Invoke it by ant eg.
  • The ant script starts and stops the database. To restart it manually in order to see what it’s created, type java -jar lib/mckoidb.jar from ${hibernate}. Three tables should be there that weren’t before, called AuctionItem, AuctionUser and Bid, with a few values in each. The data is stored under ${hibernate}/data - you’ll also see files with names matching these tables. This is just out of interest really, if it can’t create the tables, you’ll see the errors in the ant trace.

hibernating your own objects manually

For each object that you wish to persist via hibernate, write a ${myclass}.hbm.xml file. Put this in the same location as the source file.

No Comments

No comments yet.

RSS feed for comments on this post. TrackBack URI

Sorry, the comment form is closed at this time.

Powered by WordPress, Supported by SaveOnRefinance.com