TechnoBuzz

A Techno Blog, mainly about Java

Combo Meal: Hibernate 3 with Derby

I have been getting familiar with the Derby  open source database  which was contributed by IBM (Cloudscape).

As a learning exercise, I decided to integrate the use of Derby in sampling Hibernate 3.

I have read parts of Pro Hibernate 3 and Hibernate Quickly. I liked both books, but I think the Manning book was more what I was looking for. I needed a book that covered the X-Doclet with Hibernate 3.

Hibernate3 needed from what i can tell these Jars: cglib-2.1.3, dom4j-1.6.1, ehcache-1.1, hibernate3, jta, asm

I start off using an ANT build file schema-export target to invoke the schema generator:

<target name="schema-export">
    <taskdef name="schemaexport"
             classname="org.hibernate.tool.hbm2ddl.SchemaExportTask">
         <classpath refid="runtime.classpath"/>
    </taskdef>
     <schemaexport
         config="${src.java.dir}/hibernate.cfg.xml"
         quiet="no"
         text="no"
         drop="no"
         delimiter=";"
         output="${build.classes.dir}/schema-export.sql">
     </schemaexport>
    </target>

My hibernate property values to use Derby as the database looked like this (note: you can also specify these values in the hibernate config xml file):

hibernate.dialect=org.hibernate.dialect.DerbyDialect
hibernate.connection.driver_class=com.ibm.db2.jcc.DB2Driver
hibernate.connection.username=user1
hibernate.connection.password=user1
hibernate.connection.url=jdbc:derby:net://localhost:1527/test;create=true

Connecting to the derby database:

ij> connect ‘jdbc:derby:net://localhost:1527/test’ user ‘user1’ password ‘user1’;

ij> select tablename from sys.systables where tabletype = ‘T’;

I did not do the upgrade, but this was helpfull.

Advertisements

January 8, 2006 - Posted by | Hibernate & ORM

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: