-->
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.  [ 5 posts ] 
Author Message
 Post subject: Hibernate Code Generation Tool bummer
PostPosted: Tue Feb 06, 2007 3:01 pm 
Newbie

Joined: Tue Feb 06, 2007 11:00 am
Posts: 1
eclipse IDE : Release 3.2.1
Hibernate : Release 3.2
HSQLDB : version 1.8.0.7

Since i am new to the hibernate tools, i read the hibernate tools overview and even seen the demo located at :
http://www.hibernate.org/hib_docs/tools ... t_swf.html

However, i just can't get the hibernate code generation tool to work inside my eclipse IDE. Below is my hibernate.cfg.xml file details :


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.bytecode.use_reflection_optimizer">false</property>
<property name="hibernate.connection.driver_class">org.hsqldb.jdbcDriver</property>
<property name="hibernate.connection.url">jdbc:hsqldb:db/revenge</property>
<property name="hibernate.connection.username">sa</property>
<property name="hibernate.dialect">org.hibernate.dialect.HSQLDialect</property>
</session-factory>
</hibernate-configuration>


Do i need to start HSQLDB first? I was thinking of using an in memory DB with all the details in the db.script file. No idea how to proceed. I am lost in the concept behind HSQLDB and Hibernate. Any1 can point me in the right direction?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 06, 2007 6:43 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
My personal view for starting off follows in this general order:
1) Create a simple project (no tools) using a simple database (maybe only one table) and hibernate mappings all by hand. Get it to create, read and delete a simple object. HSQL etc are excellent for this. This al means you get basic configuration etc working and understand the basic concepts. There are many tutotials to help with this phase.

2) As above with a few relationships involved.

3) Now its time to try the tools. Max has done a great job with the eclipse integration. Having said that, I would start first with the Ant tools. Its just a matter of involving less items before you find success. So, first try generating java code from XML mapping (if you started with XML in the first place), then reverse engineering from the database you setup in step 1 and 2. The tools documentation has information on the Ant tools.

4) Once you get the feel of Ant then the full GUI is your oyster. To me, its important to learn whats under all the wrappers, eg, how does this thing work, even if it is just for the insurance of knowing that if the wrapper does not work correctly you can fix the problem directly. You will also understand the design of the GUI and goals alot better.

This process will not take long. Its definately worth doing.


Top
 Profile  
 
 Post subject: Just a few simple facts.
PostPosted: Thu Feb 22, 2007 1:26 pm 
Newbie

Joined: Thu Feb 22, 2007 12:36 pm
Posts: 4
On the other hand it should be pretty simple to describe somewhere, what the "expected" Eclipse project structure.

I am in the middle of building something in Spring and found the Hibernate tools for Eclipse.
They look pretty interesting and seem to be pretty straightforward to use but seem to have a view of the universe that conflicts with mine.
The Hibernate console seems to be able to find the main configuration file but I had trouble getting the references to the mapping files to be relative to some shared understanding with the Hibernate plug-in.

1) If the Hibernate main configuration hibernate.cfg.xml file is stored under src and the mapping files are under src/com/mycompany/myapp/model
What do I put in the hibernate.cfg.xml as the mapping resource="...?
I currently have src/src/com/mycompany/myapp/model/table1.hbm.xml

This does seem to be working but now it has trouble finding the classes that it is looking for. It also seemed to be caching the *.hbm.xml files so that my corrections in the src directory were not having any effect on the error messages.

Spring, Java and Eclipse seem to conspire to put the Java .class files under a top level .classes directory. Probably since that is where build.xml says they should go. This came from the Spring guys but I could change it.

Hibernate seems to want to create a bin tree (at least I think that it is Hibernate that keeps trying to put things there).

It can not seem to find the class files when loading the console. It would be helpful if the error message actually said where it was looking when it could not find them.


2) What is the correct way to get the Hibernate plug-in and the other Eclipse children to play nicely together? Can I tell the Hibernate console where all of the things that it needs are found? Or can I change my Spring structure to match what Hibernate thinks that I sould be doing.


This should not be that hard to specify but I did not find it in my readings so far.
I am sure that I can do without this tool but it looks really great and I think that it will find errors in my mappings and database creation scripts (if I still need them once I get the tools working) with a lot less pain than trial and error.

Thanks for any thoughts on this.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Feb 22, 2007 2:58 pm 
Newbie

Joined: Thu Feb 22, 2007 12:36 pm
Posts: 4
Thanks to a post in another topic, I found that Hibernate is using the the output directory setting on the Project Preference page that I had been to a dozen times to set classpaths and libraries.

Not exactly prominent and the Spring guys were overriding the setting in the their build so I had never worried about what it said nor really cared where the class files were going.

Now that they match, I am getting a whole new class of errors.
Real Hibernate and database errors that I made myself :-)
Fixing these at this stage will save me hours of grief and aggravation and log reading.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Mar 19, 2007 10:50 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
Just to check....what did hibernate tools require (besides having the mappings in the classpath like normal hibernate or spring would expect) that made your life hard ? ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 5 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.