-->
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.  [ 13 posts ] 
Author Message
 Post subject: HbmToJava Or Javadoc
PostPosted: Wed Nov 10, 2004 11:10 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Hi.
I'm writing a tool to generate hibernate mapping and classes from a UML model.
I started by generating Hbm files from UML model and them I run Hibernate Synchronizer to generate code. Or I could also generate the code using hbm2java, that may be better (i have not tried hbm2java).
The first test runs very well, it's a one day test, but I can generate some associations and classes w/o generalization from a model.
But I'm thinking in a different way: I could generate the classes with javadoc and them generate the HBM files.
What do you think is the more usefull way to do that?
AndroMda uses the XDoc way. But I read somewhere that the intention behind the HBM files is concentrate all the information needed.

So what's the standart way to think in a new Application?
1)UML->HBM->Class
2)UML->anotated Class->HBM

Or maybe, keep it 2 way :)
Or maybe another way :)


Well, it's intended to be a free tool that will support Argo and maybe other tools.

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 10, 2004 3:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i'm kinda biased, but i prefer generating the hbm and then let other tools go from there..

Note that you can actual make hbm2java include javadocs part - thus having it generate xdoclet compliant java files (if you include the tags in javadoc)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Nov 10, 2004 7:32 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Although its less flexible in someways, I prefer the XDoclet approach (which is funny when I wrote Middlegen Plugin that generate the HBMs :-) ). Although its some time away in terms of common usage, Annotations are the next step and XDoclet is a closer model of development than HBMs. In reality, it a personnel thing so I suggest tool is flexible enough so you can change (or do either) as your user base suggests.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 8:30 am 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Max: It generates javadoc that can generate back the hbm ? :o
How ? :)
Or you mean that I can write de javadoc down the meta javadoc, and if I write it correclty, I will have a .java that can generate the same hbm back?
It's a double job write the hbm and xdoclet instead of writing just xdoclet (but I ask myself if xdoclet can express all the information in hbm).

-If I define a HBM for non persistent java and interfaces (by hidding the table attribute of class) what happens in hibernate?

David: Good point. Although I can't understand why everybody loves to mix the generation source (metadata in anotaded file) with the source generated (code). You end up with two times the number of needed interfaces and classes. I'm not a Xdoclet fan, but if everybody uses it what can I do... and it works so well! :)

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 11:24 am 
Senior
Senior

Joined: Wed Aug 27, 2003 4:08 am
Posts: 178
Location: Wiesbaden, Germany
Maybe anndroMDA is what you are writing :)

AFAIR, Matthias Bohlen tried ( and maybe succeedded )
to create tool which processed xmi and generated
xdoclet-marked java sources out of it.

_________________
Got new hibernate xdoclet plugin? http://www.sourceforge.net/projects/xdoclet-plugins/
... Momentan auf der Suche nach neuen Projekt ode Festanstellung....


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 12:19 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
atorres wrote:
Max: It generates javadoc that can generate back the hbm ? :o
How ? :)


How ? by doing its job well ;)

Quote:
Or you mean that I can write de javadoc down the meta javadoc, and if I write it correclty, I will have a .java that can generate the same hbm back?


That is how middlegen does it.
In the future we will probably add support to hbm2java where it will generate JDK 1.5 annotations in the source code (and then if someone cares, also add xdoclet support)

Quote:
It's a double job write the hbm and xdoclet instead of writing just xdoclet


Why is it that ? AFAIK the hbm.xml is easier to generate than a solid .java implementation.

Quote:
(but I ask myself if xdoclet can express all the information in hbm).


It can't.

Quote:
-If I define a HBM for non persistent java and interfaces (by hidding the table attribute of class) what happens in hibernate?


What do you mean here ?

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 3:02 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Max:
Let me see if I understood: There is no automatic way to generate de xdoclet from hbm, it may be added in a near future (annotation/jdk1.5/etc). I can generate the hbm with the javadoc metatag. Hbm2java will generate the code for xdoclet.

>AFAIK the hbm.xml is easier to generate than a solid .java >implementation.
Thats true ! :) and if xdoclet can't represent all information on hbm ...
My prototype is generating hbm. And surprisingly I'm generating normal classes too using hbm2java. Damn good tool.

>>-If I define a HBM for non persistent java and interfaces (by hidding >>the table attribute of class) what happens in hibernate?

>What do you mean here ?
I mean, imagine that there is a class Person, and a specialization Citizen.
If I want to generate Citizen as specialization of Person in one hbm, by using the <meta> extends.
Them I generate Person hbm file too, but with no table attribute.
Hbm2java will generate both classes.
What will happen I run this "thing" ?
My first test works if I use Person.hbm only for generation. Becouse to use Person.hbm in hibernate as mapping I need to identify a valid ID.

As for AndroMDA: I got a lot of problems with andromda, and I give up it. Does not read Argo anyway.

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 3:46 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
atorres wrote:
Max:
Let me see if I understood: There is no automatic way to generate de xdoclet from hbm, it may be added in a near future (annotation/jdk1.5/etc). I can generate the hbm with the javadoc metatag. Hbm2java will generate the code for xdoclet.


yes.

Quote:
>>-If I define a HBM for non persistent java and interfaces (by hidding >>the table attribute of class) what happens in hibernate?

>What do you mean here ?
I mean, imagine that there is a class Person, and a specialization Citizen.
If I want to generate Citizen as specialization of Person in one hbm, by using the <meta> extends.
Them I generate Person hbm file too, but with no table attribute.
Hbm2java will generate both classes.
What will happen I run this "thing" ?
My first test works if I use Person.hbm only for generation. Becouse to use Person.hbm in hibernate as mapping I need to identify a valid ID.


hmm...if you are breaking the rules in the DTD you are just lucky hbm2java does not caugh up upon this....(also if you are breaking some hibernate specific rule)...

It will be a "hack" which you cannot rely on forever ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 4:13 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
Quote:
hmm...if you are breaking the rules in the DTD you are just lucky hbm2java does not caugh up upon this....(


no, table is implied! Look at the DTD:

Code:
<!ELEMENT class (
  meta*,
  (cache|jcs-cache)?,
  (id|composite-id),
  discriminator?,
  (version|timestamp)?,
  (property|many-to-one|one-to-one|component|dynamic-component|any|map|set|list|bag|idbag|array|primitive-array)*,
  ((subclass*)|(joined-subclass*))
)>
  <!ATTLIST class name CDATA #REQUIRED>
  <!ATTLIST class table CDATA #IMPLIED>       


ID is not implied, but the Name and Type are !
Code:
<!ELEMENT id (meta*, column*, generator)>
  <!ATTLIST id name CDATA #IMPLIED>
  <!ATTLIST id access CDATA #IMPLIED>
  <!ATTLIST id column CDATA #IMPLIED>
  <!ATTLIST id type CDATA #IMPLIED>
  <!ATTLIST id length CDATA #IMPLIED>
  <!ATTLIST id unsaved-value CDATA "null">   

so I can create a void ID... well I supposed that the intention was just map non persistent classes too :)
Do you think I'm forcing Hibernate ? Them I will consider building a template for file+Xdoclet too :'(

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 4:26 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
i know table is not required and in some cases the same case go for id.

But it was you who stated your "non-persistent" mapping did not work with hibernate, but it did work with hbm2java...

I was just pointing out that hbm2java might be less strict on some validations, but i cannot promise it will be so forever..

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Nov 11, 2004 5:18 pm 
Regular
Regular

Joined: Mon Jun 14, 2004 1:42 pm
Posts: 80
Location: Brazil
it has not worked, it claims an ID field should have Type. But only if I include the HBM file for superclass in the configuration, otherwise all works.
How can I know for sure that's not an hibernate rule ? :)
...humm... I may post it on the hibernate generic list.
Thank you very much for the ideas.

_________________
Alexandre Torres
--------------------


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 1:50 am 
Newbie

Joined: Wed Nov 10, 2004 6:34 am
Posts: 7
If you plan to support different databases for your app, how does one use XDoclet tags for generating mapping files to deal with different data types for different databases?

eg. a column of type "text" in postgres must be of type "next" in SQL Server. In Oracle you have a choice of "Long" or "Clob".


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 15, 2004 2:12 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Yes it is harder - this is also a limitation of annotations (atleast from what I have seen so far). Since the HBMs are externally (generated by Xdoclet) you can post process the HBMs. This is how I normally manage it. Alternatively, abstract the types into User-type(s) which has the logic to operate appropriately.


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