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.  [ 6 posts ] 
Author Message
 Post subject: How to enable my tiny database to work with Hibernate?
PostPosted: Tue Feb 06, 2007 9:25 pm 
Newbie

Joined: Tue Feb 06, 2007 9:14 pm
Posts: 4
Hello everyone,


I have developed a tiny database and implemented several JDBC functions. It is for mobile (J2ME) application/device to store/manage address book, SMS, pictures, Notes, ...

I am wondering what else should I do to enable it to work with Hibernate? Currently, the only external interface is JDBC functions that I have implemented, like connect, prepare statement, execute, ...

Anyway, what I have done is very simple and just something like a simple file manager -- and give it a JDBC standard interface wrapper. I just want to enable it with Hibernate to simplify application (Demo) development.

Does anyone have any ideas? Any reference documents?


regards,
George


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 4:22 am 
Beginner
Beginner

Joined: Mon Jan 22, 2007 1:16 pm
Posts: 21
After creating a JDBC driver for your database, you will have to create a hibernate dialect by extending the Dialect.java class that can be found in the Hibernate sources. Look for the dialect folder. In that folder you will also find examples of other dialects like for MySQL, Oracle, etc.

The other Hibernate class that might help you is Configuration.java. It can be found in the cfg source folder.

Not sure if this info is what you were looking for, but this is what hibernate needs to work with a database with a JDBC driver.

here is some info i found on creating a JDBC driver
http://www.javaworld.com/javaworld/jw-0 ... river.html

good luck

-mark


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 7:23 am 
Newbie

Joined: Tue Feb 06, 2007 9:14 pm
Posts: 4
Thanks mark!


fizzbananafrance wrote:
After creating a JDBC driver for your database, you will have to create a hibernate dialect by extending the Dialect.java class that can be found in the Hibernate sources. Look for the dialect folder. In that folder you will also find examples of other dialects like for MySQL, Oracle, etc.

The other Hibernate class that might help you is Configuration.java. It can be found in the cfg source folder.

Not sure if this info is what you were looking for, but this is what hibernate needs to work with a database with a JDBC driver.

here is some info i found on creating a JDBC driver
http://www.javaworld.com/javaworld/jw-0 ... river.html

good luck

-mark


I have got a self-made JDBC driver now -- it is simple and stupid sometimes, anyway it works. :-)

I am a little confused about your reply. Could you indicate what should I do/follow after I have a JDBC driver please? Any reference articles/documents?


thanks in advance,
George


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 07, 2007 8:17 am 
Newbie

Joined: Tue Feb 06, 2007 9:14 pm
Posts: 4
Hi mark,


fizzbananafrance wrote:
After creating a JDBC driver for your database, you will have to create a hibernate dialect by extending the Dialect.java class that can be found in the Hibernate sources. Look for the dialect folder. In that folder you will also find examples of other dialects like for MySQL, Oracle, etc.

The other Hibernate class that might help you is Configuration.java. It can be found in the cfg source folder.

Not sure if this info is what you were looking for, but this is what hibernate needs to work with a database with a JDBC driver.

here is some info i found on creating a JDBC driver
http://www.javaworld.com/javaworld/jw-0 ... river.html

good luck

-mark


I have done some exercises to make my hands dirty. I think if I have a JDBC driver, I need to implement a Dialect, and then add the Dialect to
Hibernate configuration file hibernate.cfg.xml. Is that correct? Anything else should I do?

I am wondering what is the usage of Configuration.java? Do I need to modify it?


regards,
George


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 4:06 am 
Beginner
Beginner

Joined: Mon Jan 22, 2007 1:16 pm
Posts: 21
For sure you will need to tell Hibernate which dialect to use when interacting with your database. And you are correct that you do this inside of the hibernate.cfg.xml file. Since you probably can't use one of the provided dialects, you need to extend Dialect.java to create your own.

Aside from analyzing Dialect.java and looking at the other dialects in the same folder, there aren't any other reference documents.

You probably won't need to do anything with Configuration.java, but it couldn't hurt to take a look inside it. In example, the database I am trying to use is SQLBase. It is not supported by hibernate by default, but there is a JDBC driver for it. After creating my dialect, there were still things that hibernate could not do correctly with SQLBase. In example, SQLBase requires that you explicitly create an index on primary keys after creating a table. To acheive this, I had to patch Configuration.java and rebuild hibernate source.

I saw somewhere that you can get Hibernate to work with Excel, you might want to try to find out how they do that(see what the dialect looks like). Here is a link to HXTT, the folks who have created a dialect to work with Hibernate.
http://www.hxtt.com/hibernate.html

good luck!
mark


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 08, 2007 5:09 am 
Newbie

Joined: Tue Feb 06, 2007 9:14 pm
Posts: 4
Thanks mark,


fizzbananafrance wrote:
For sure you will need to tell Hibernate which dialect to use when interacting with your database. And you are correct that you do this inside of the hibernate.cfg.xml file. Since you probably can't use one of the provided dialects, you need to extend Dialect.java to create your own.

Aside from analyzing Dialect.java and looking at the other dialects in the same folder, there aren't any other reference documents.

You probably won't need to do anything with Configuration.java, but it couldn't hurt to take a look inside it. In example, the database I am trying to use is SQLBase. It is not supported by hibernate by default, but there is a JDBC driver for it. After creating my dialect, there were still things that hibernate could not do correctly with SQLBase. In example, SQLBase requires that you explicitly create an index on primary keys after creating a table. To acheive this, I had to patch Configuration.java and rebuild hibernate source.

I saw somewhere that you can get Hibernate to work with Excel, you might want to try to find out how they do that(see what the dialect looks like). Here is a link to HXTT, the folks who have created a dialect to work with Hibernate.
http://www.hxtt.com/hibernate.html

good luck!
mark


The information you provided above is very informative. I have a quick question. I read through the document you referred in JavaWorld before about how to create a JDBC Type 3 driver.

I am wondering whether a type 3 is a must requirement? Could I use type 2 driver -- I only implemented very simple local functions, and the JAR has to be used locally in CLASSPATH or BOOT CLASSPATH. I am wondering whether it is feasible to implement into Hibernate?


regards,
George


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

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.