-->
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.  [ 10 posts ] 
Author Message
 Post subject: newbie - best approach for code generation
PostPosted: Tue Mar 30, 2004 1:16 pm 
Newbie

Joined: Tue Mar 30, 2004 1:06 pm
Posts: 4
Hi,
I would like to know which is the most stable and solid approach for code generation in Hibernate.
I have widely used XDoclet in the past for EJB code generation, but from some tests that I have conducted with Hibernate, I guess that XDoclet it is not the best approach.
I tried the following with Ant:
1 - Generate mapping files (hbm.xml) using Middlegen 2 with Hibernate plugin
2 - Generate the Java domains object using the Hibernate hbm2java
3 - Generate the Hibernate config file (hibernate.cfg.xml) using the BeanShell script provided here: http://www.hibernate.org/72.html (a little bit cumbersome)

Is this a good approach or are you guys using different tools?

Thanks
Luciano


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 2:13 pm 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
I'm using xdoclet and I'm quite happy with it. Any particular reason why you think xdoclet is not good?


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 2:29 pm 
Newbie

Joined: Tue Mar 30, 2004 1:06 pm
Posts: 4
Actually I did not make myself clear. I decided not to use XDoclet for xml and classes generation mainly because I've read some negative feedback about using XDoclet with version 2 of Hibernate.
But I'm happy to know that XDoclet works ok.
How do you exactly use XDoclet for Hibernate? Do you generate only domain classes on the fly?

Luciano


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 2:54 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
in fact there are some advanced used of hibernate which limitates the xdoclet uses:
- formula
- joined-subclasses with composite id
- management of components
- maybe others

... but if you don't need these features, xdoclet is easy to use


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 7:38 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
The best approach is what works best for you. Hibernate has support/tools for top-down, middle-out and bottom-up development.
Many users use bottom-up (Middlegen->hbm2java), equally many users (possibly the most popular) apply top-down (XDoclet) while the power users tend to use middle-out (Hand writting (with the help of validating XML editors) ). The last approach avoids any limitations in the tools (or delays of tools catching up with new features). I use all three approaches from time to time.

I suggest you try them all and see what best fits with your development style.

BTW: We completed a tools example that demonstrated the various approaches.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Mar 30, 2004 7:48 pm 
Hibernate Team
Hibernate Team

Joined: Mon Aug 25, 2003 9:11 pm
Posts: 4592
Location: Switzerland
It can be found here:

http://www.hibernate.org/159.html

_________________
JAVA PERSISTENCE WITH HIBERNATE
http://jpwh.org
Get the book, training, and consulting for your Hibernate team.


Top
 Profile  
 
 Post subject: Re: newbie - best approach for code generation
PostPosted: Mon Apr 05, 2004 3:24 am 
Beginner
Beginner

Joined: Fri Apr 02, 2004 3:34 am
Posts: 40
I like to bottom-up. For larger and more serious applications, the database rules, so that's where I build my domain, then I use Middlegen and h2bm to get my POJOs.


koevet wrote:
Hi,
I would like to know which is the most stable and solid approach for code generation in Hibernate.
I have widely used XDoclet in the past for EJB code generation, but from some tests that I have conducted with Hibernate, I guess that XDoclet it is not the best approach.
I tried the following with Ant:
1 - Generate mapping files (hbm.xml) using Middlegen 2 with Hibernate plugin
2 - Generate the Java domains object using the Hibernate hbm2java
3 - Generate the Hibernate config file (hibernate.cfg.xml) using the BeanShell script provided here: http://www.hibernate.org/72.html (a little bit cumbersome)

Is this a good approach or are you guys using different tools?

Thanks
Luciano


Top
 Profile  
 
 Post subject:
PostPosted: Wed Apr 07, 2004 10:51 am 
Newbie

Joined: Tue Dec 09, 2003 8:31 am
Posts: 17
For those of you that are using the bottom up approach. Do you use the bottom up tools like Middlegen and hbm2java for one time code generation and then modify the hbm.xml files and the classes as needed. I have heard this called passive generation. The opposite would be active generation which xdoclet is a good example. The deployment descriptors are constantly generated during your build process and you never physically change that file . Plus since the file is generated it is never added to source control.

For hibernate I have been using the bottom-up approach using active genaration of code. But recently I am seeing where passive generation might be more flexible in the long term. So the idea would be that you can start with a data model, then generate the classes and hbm.xml file once. Check those files into version control (CVS) and begin editing them by hand, if needed. The obvious downside is that if the database changes then you would have to incorporate those changes by hand.

Just wanted to get an idea of how others are using these tools.

Thanks,

Craig


Top
 Profile  
 
 Post subject:
PostPosted: Mon Apr 12, 2004 10:29 pm 
Beginner
Beginner

Joined: Fri Mar 05, 2004 11:14 am
Posts: 38
Location: Houston, Texas
Yea - it's like a religion what you are using. Like the discussion around which text editor is the best ... the best answere is like David is saying - try them all with a little test example. Than try it out on teh worse case cenario in your database - i..e don't take the simple tables/views relation - find a "nasty" example.

For me the bottom up, approach Middlegen -> Hbm files -> check those in and maintain. Use hbm2java to generate the java files for each hourly/nightly build works fine. Currently we have not have had the need to store some of the java files in the source control - but it may become necessary due to some special situations where methods needs to be added.

Bests and thax for all you out there - it's a great product
B-)


Top
 Profile  
 
 Post subject:
PostPosted: Tue Apr 13, 2004 12:02 am 
Beginner
Beginner

Joined: Thu Jan 08, 2004 4:40 am
Posts: 48
Location: Bangkok, Thailand
I'm using Xdoclet, because not only Hibernate but also some other things like Castor, EJB, DAO....... can be generated automatically.......
but sometime you need to modified x-doclet jelly script by yourself.

http://xdoclet.sourceforge.net/

and lastly no need to worry about Genderate Table, Relation....

Roofimon

_________________
<name>arin</name>
<at>netplus software</at>


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