-->
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.  [ 12 posts ] 
Author Message
 Post subject: Problem with hbm2java, sub class generation and interfaces
PostPosted: Fri Oct 22, 2004 7:13 am 
Newbie

Joined: Fri Oct 22, 2004 6:55 am
Posts: 16
Location: Hamburg, Germany
I want to generate base and sub classes which implement a common interface with the hbm2java ant task (current version of hibernate-tools.jar). According to the Hibernate reference, I am using the following hbm2java config file:

<codegen>
<meta attribute="implements">com.kn.gvs.inv.integration.IModel</meta>
<generate prefix="Base" renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer"/>
<generate renderer="net.sf.hibernate.tool.hbm2java.BasicRenderer">
<param name="generate-concrete-empty-classes">true</param>
<param name="baseclass-prefix">Base</param>
</generate>
</codegen>

But, hbm2java only creates one class per table with no prefix and the classes do not implement my interface. I do not get any error messages.
The mapping files are created with the middlegen taks and I do not edit them.

Does anybody know what the problem is?

Best Regards
Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Fri Oct 22, 2004 10:14 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
those options just control how hbm2java reacts when it sees <meta attribute="generated-class"> tags in the code.

Look at the docs for that. I don't know if middlegen handles this tag yet - david ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Sun Oct 24, 2004 9:31 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Middlegen does not have builtin support for that tag at this stage.
I'll see what I can do.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 6:23 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
How about adding a "add your own meta tags" textfield/area to middlgen ? (then people can use all the metastuff no matter if the middlegen plugin has direct support for it ?)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Mon Oct 25, 2004 9:02 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Sure - generalising is a good idea.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 03, 2004 5:22 am 
Newbie

Joined: Fri Oct 22, 2004 6:55 am
Posts: 16
Location: Hamburg, Germany
Thank you for your answers. Is there any way to generate hbm files and classes based on an existing database scheme, where I can generate a sub and a base class per table and specify, that all classes should implement a certain interface?

Best regards,
Oliver


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 04, 2004 11:15 pm 
Newbie

Joined: Wed Nov 03, 2004 6:41 pm
Posts: 12
Location: Canberra/Sydney Australia
Hi, omisch,

If you look at the middlegen you may find the answer. But I am not sure then how well it would handle the complicated cascade style relationship....

I am thinking that it could be perfect if the sql2java (an open source tool doing well in the area of generating java classes directly based on database schema) could consider to provide the hibernate plugin for middlegen (well, middlegen can do more than just providing the interface for hibernate plugin as I know).


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 7:18 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
what does sql2java do that the current toolset does not do ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 05, 2004 11:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
You can include in the Middlegen Ant task for the hibernate plugin a implements attribute. All classes will then have this meta data tagged from which hbm2java can create the approrpriate class structure.


Top
 Profile  
 
 Post subject:
PostPosted: Fri Nov 12, 2004 8:46 am 
Newbie

Joined: Fri Oct 22, 2004 6:55 am
Posts: 16
Location: Hamburg, Germany
I forgot to mention: I tried the implements tag with the hibernate plugin of middlegen, but it does not work. I get the message that the hibernate plugin does not support this attribute.

md38, could you tell me exactly where at the middlegen I have to look, because I did not find a solution.

Instead of using hbm2java, I now use the Hibernate Synchronizer plugin (in addition with middlegen) for eclipse. It works fine. The only drawbacks are, that there is no ant task, and that it does not use the standard round trip tools but instead is implemented proprietary.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 13, 2004 2:15 am 
Newbie

Joined: Wed Nov 03, 2004 6:41 pm
Posts: 12
Location: Canberra/Sydney Australia
Hi, omisch,

So far I have done the basic run of the middlegen and it seems it can generates the persistence classes in a flash (with relationships)...

I am still on the learning curve on Hibernate at this stage (I have just got the Hibernate in Action from amazon yesterday) and I am reading those mapping tags on Hibernate.

What my previous posting was suggesting the middlegen can basically generate persistence classes and their relationship, however, regarding to your message of inheritance of Java classes, I am not really sure whether the middlegen can do that and this could probably to be done in the hibernate to java configuration file side, not to be in the middlegen side, which is focusing on the code generation based on database schema, but not too much on the Java aspect.

I will try to squeez my time as much as possible to study the Hibernate and its mapping tags at the moment.


Top
 Profile  
 
 Post subject:
PostPosted: Sat Nov 13, 2004 6:03 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
I have completed the documentation for the Tags on the Middlegen site. I did extend it (error in docs) and the Ant task for implements is working correctly in CVS. Check it out.


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