-->
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.  [ 33 posts ]  Go to page 1, 2, 3  Next
Author Message
 Post subject: Where to put common meta info and other questions...
PostPosted: Fri Feb 03, 2006 1:58 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
Dear Members,

I am using the 3.1 beta hibernatetool, nevertheless I din't get the generated files I expected.

On the 6.1. The <meta> attribute section from the documentation:
http://www.hibernate.org/hib_docs/tools ... ml_single/

There is a comment about the meta key in order to have the same generated information for ALL file without putting at each *.hbml.xml file. It talks about a particular hbm.xml file (without the *, so they are talking about this particular file). If I add the meta information on this file there the generated *.java file don't include meta information.

¿So, where I have to put this meta information in order to have the same generated information for ALL *.java files? Following the DTD definition for the files: hibernate.cfg (http://hibernate.sourceforge.net/hibern ... on-3.0.dtd) and hibernate.reveng.xml (http://hibernate.sourceforge.net/hibern ... ng-3.0.dtd), it is not possible to add the hibernate-mapping element and therefore the meta key information.

¿Why Middlegen (even the beta version) is ussing a hibernate 2.* version? Is there any technical reason?

It is a bit confusing for me because there are two tools for making a similar task but you find some features on Middlegen can be done and it is not posibble with hibernatetool a vice versa.

When I invoke the <hbm2hbmxml/> task it doesn't really takes into account the information on the file given by the property: revengfile. I want to rename some column and primary keys name, but I get the same output, as if a weren't used this file.

Middlegen use apache common lang in order to generate the toString, equals and hashcode. Why Hibernate doesn't take this approach (you safe a lot of line code)?

Thanks in advance,

David

_________________
David Leal


Top
 Profile  
 
 Post subject: Re: Where to put common meta info and other questions...
PostPosted: Sat Feb 04, 2006 3:55 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dleal wrote:
On the 6.1. The <meta> attribute section from the documentation:
http://www.hibernate.org/hib_docs/tools ... ml_single/

There is a comment about the meta key in order to have the same generated information for ALL file without putting at each *.hbml.xml file. It talks about a particular hbm.xml file (without the *, so they are talking about this particular file). If I add the meta information on this file there the generated *.java file don't include meta information.


I do not really understand what you are talking about ;)

The current way to include the same tags in all files is to use xml entity includes.

If you want something more generic go and see if it is reported in jira, if not then report it as a feature request.

Quote:
¿Why Middlegen (even the beta version) is ussing a hibernate 2.* version? Is there any technical reason?


i think the latest middlegen in cvs supports v3.

Quote:
It is a bit confusing for me because there are two tools for making a similar task but you find some features on Middlegen can be done and it is not posibble with hibernatetool a vice versa.


We just don't want to maintain 2 different tools for doing the same thing.
If something is missing in hibernatetool (and it makes sense to add it) then report it in jira or even better come by with a patch.

Quote:
When I invoke the <hbm2hbmxml/> task it doesn't really takes into account the information on the file given by the property: revengfile. I want to rename some column and primary keys name, but I get the same output, as if a weren't used this file.


well hard to fix issues if they are not reported. noone has yet to come by with a reproducable testcase in jira. Only "issue"/gotcha i know is that case matters and it is handled different on each db.

Again, report it in jira with a test case so i can fix it.

Quote:
Middlegen use apache common lang in order to generate the toString, equals and hashcode. Why Hibernate doesn't take this approach (you safe a lot of line code)?


We do not want to impose not-so-great libraries into your pojo's. If you want that you can easily customize the templates to support it. You just need to redefine the PojoEqualsHashCode template file for your needs.

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where to put common meta info and other questions...
PostPosted: Sat Feb 04, 2006 6:16 am 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
Quote:
I do not really understand what you are talking about ;)


Ok, I am try to explain it again. I have Tables A, B, and I want to generate the corresponding A.hbm.xml and B.hbm.xml files using <hbm2hbmxml>. For example I want to generate on both files a meta information for example for generating the toString, equals, hascode methods, I know in order to get such methods on the A.java and B.java files I have to put on the corresopnding A.hbm.xml and B.hbm.xml files the following meta tags:

Code:
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>


but I don't want to insert MANUALLY on each generated file A.hbml.xml and B.hbml.xml such meta information.

Me question is if there is a way to specify on the generation process with <hbm2hbmxml> or just to inform on any configuration file for <hbm2java> task in order to specify this meta information common to ALL generated file: A.java, B.java.

Quote:
The current way to include the same tags in all files is to use xml entity includes.


Now I don't understand you, please could you be more clear.

Quote:
If you want something more generic go and see if it is reported in jira, if not then report it as a feature request.


before to report some in Jira I prefer to ask on the forum, probably I am understanding some wrong and some people could help without putting a new issue on Jira.

I think that the documentation about meta keys on the manual is a bit confusing, but it could be a personal opinion and other people from the forum understand exactly what the user manual want to say (I am talking about the user manual for Hibernate Tools)

Quote:
We just don't want to maintain 2 different tools for doing the same thing.
If something is missing in hibernatetool (and it makes sense to add it) then report it in jira or even better come by with a patch.

When I invoke the <hbm2hbmxml/> task it doesn't really takes into account the information on the file given by the property: revengfile. I want to rename some column and primary keys name, but I get the same output, as if a weren't used this file.


well hard to fix issues if they are not reported. noone has yet to come by with a reproducable testcase in jira. Only "issue"/gotcha i know is that case matters and it is handled different on each db.


I just wanted from people of the forum to get information in the sense if they have the same problem. It is not a database problem, I just have the feeling that the property: revengfile="hibernate.reveng.xml" on <jdbcconfiguration> is not taked into account on the inverse process. I just want before to send something to Jira to be sure it is a bug or I am doing something wrong. I hope the Hibernate software is well tested so such simple mistake I shouldn't expect even from a beta version.

From this beta version, there is no log information when invoking ant with -v option for this task.

If all of this are possible bugs I open a issue on Jira.

Quote:
We do not want to impose not-so-great libraries into your pojo's. If you want that you can easily customize the templates to support it. You just need to redefine the PojoEqualsHashCode template file for your needs.


Ok, but is there any way to just say for this template use mine?, but for other tamples use the default that comes with hibernatetool?

Thanks max,

David Leal

_________________
David Leal


Top
 Profile  
 
 Post subject: Re: Where to put common meta info and other questions...
PostPosted: Sun Feb 05, 2006 12:58 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dleal wrote:
Quote:
I do not really understand what you are talking about ;)


Code:
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>


but I don't want to insert MANUALLY on each generated file A.hbml.xml and B.hbml.xml such meta information.




Quote:
Me question is if there is a way to specify on the generation process with <hbm2hbmxml> or just to inform on any configuration file for <hbm2java> task in order to specify this meta information common to ALL generated file: A.java, B.java.


i think there is an issue open for it in jira, otherwise create one.

Quote:
Quote:
The current way to include the same tags in all files is to use xml entity includes.


Now I don't understand you, please could you be more clear.


Code:
<ENTITY include commonstuff "metatags.xml"> ]>

&commonstuff;


Quote:

I think that the documentation about meta keys on the manual is a bit confusing, but it could be a personal opinion and other people from the forum understand exactly what the user manual want to say (I am talking about the user manual for Hibernate Tools)



the newly updated one in 3.1.0.b4 or some previous one ? Doc has changed alot in the latest release.

Quote:
I just wanted from people of the forum to get information in the sense if they have the same problem. It is not a database problem, I just have the feeling that the property: revengfile="hibernate.reveng.xml" on <jdbcconfiguration> is not taked into account on the inverse process. I just want before to send something to Jira to be sure it is a bug or I am doing something wrong. I hope the Hibernate software is well tested so such simple mistake I shouldn't expect even from a beta version.


of course reveng is taking into account, the unit tests would/should fail massively if they were'nt ;)

A beta release exists so our users can provide feedback and jira reports - so please do ;)

Quote:
From this beta version, there is no log information when invoking ant with -v option for this task.


I get alot of logging in my log files if i follow the docs about logging ;)

Quote:
Quote:
We do not want to impose not-so-great libraries into your pojo's. If you want that you can easily customize the templates to support it. You just need to redefine the PojoEqualsHashCode template file for your needs.

Ok, but is there any way to just say for this template use mine?, but for other tamples use the default that comes with hibernatetool?


yes set templatepath and add that single file into it and it will be picked up.

David Leal

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Where to put common meta info and other questions...
PostPosted: Sun Feb 05, 2006 3:49 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
Code:
<ENTITY include commonstuff "metatags.xml"> ]>

&commonstuff;


Please could you be more precisly. Where should I have to put this information? into hibernate-mapping.dtd?, do I have to put this on each *.hbm.xml file?, so there is no so master file where to get such common configuration for all files?

Quote:

I think that the documentation about meta keys on the manual is a bit confusing, but it could be a personal opinion and other people from the forum understand exactly what the user manual want to say (I am talking about the user manual for Hibernate Tools)


the newly updated one in 3.1.0.b4 or some previous one ? Doc has changed alot in the latest release.


I am refering to the beta 3.1.0.b4, it seems there is a configuration file where to define such common setting for the generated files?, but meta attribute are not allowed on the revengfile property (following the DTD definition file for this case)

Quote:
From this beta version, there is no log information when invoking ant with -v option for this task.

I get alot of logging in my log files if i follow the docs about logging ;)



I am not talking about the hibernate logging process, I am talking about ANT TASK, when I invoke ant with -v there is no information about this task. Probably on the log output of my application, but I am talking about diferent thing.

Thanks again Max for your time,

David

_________________
David Leal


Top
 Profile  
 
 Post subject: Re: Where to put common meta info and other questions...
PostPosted: Mon Feb 06, 2006 1:49 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
dleal wrote:
Code:
<ENTITY include commonstuff "metatags.xml"> ]>

&commonstuff;


Please could you be more precisly. Where should I have to put this information? into hibernate-mapping.dtd?, do I have to put this on each *.hbm.xml file?, so there is no so master file where to get such common configuration for all files?
Quote:

it is (unfortunately) required to put in top of each mapping file. Still you can get it in there pretty easily by customizing the hbm.xml template.

Quote:
I think that the documentation about meta keys on the manual is a bit confusing, but it could be a personal opinion and other people from the forum understand exactly what the user manual want to say (I am talking about the user manual for Hibernate Tools)


the newly updated one in 3.1.0.b4 or some previous one ? Doc has changed alot in the latest release.

I am refering to the beta 3.1.0.b4, it seems there is a configuration file where to define such common setting for the generated files?, but meta attribute are not allowed on the revengfile property (following the DTD definition file for this case)


yes, it is not possible in there. at some point i tried to get it in hibernate.cfg.xml but that were turned down since it creates some inconscistencies in the api....

Quote:
From this beta version, there is no log information when invoking ant with -v option for this task.

I get alot of logging in my log files if i follow the docs about logging ;)

I am not talking about the hibernate logging process, I am talking about ANT TASK, when I invoke ant with -v there is no information about this task. Probably on the log output of my application, but I am talking about diferent thing.


the ant task it self prints a line for every exporter it runs.
And since it is hibernate that is used to run it other logging information is available via normal log configuration (E.g. via log4j) ...so just put a log4j.properties/xml into classpath to get more verbose information.


_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 9:40 am 
Beginner
Beginner

Joined: Tue Jan 24, 2006 1:48 pm
Posts: 20
Location: Stevenage, UK
dleal
As I understand it, you're trying to do roughly the same stuff as I was doing, so you may find the following useful:

Templates:
You only need to provide your own versions of templates you want to change - you don't need to provide a complete set (although it is often easier, when editing, to start with a complete set and then throw away any you didn't change once you've finished editing).
You might well need to preserve relative paths, however - I've got ".../templates/pojo", ".../templates/dao" and ".../templates/hbm" directories, and tell the tools to find my templates in ".../templates/". Works for me.

2 stage generation:
You'll need to do the reverse-engineering in 2 stages - one to generate the hbm.xml files, and a second stage to generate the Java from the hbm.xml files.
If you tell it to do everything in one go, the Java is generated as if you'd never customised the hbm.xml templates and hence the <meta ...> tags you've had inserted in the hbm.xml files have no effect on the Java code.


max
It would be really nice if it were possible to insert <meta> tags into the generated hbm.xml files without editing templates, ideally by putting something into the hibernate.reveng.xml file to say "for this table, add this meta attribute to that column".


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 9:51 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes...probably will add it but i also don't want the reveng.xml to grow to be a replica of the mapping files ;)

...but i guess meta tags makes good sense.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 10:03 am 
Beginner
Beginner

Joined: Tue Jan 24, 2006 1:48 pm
Posts: 20
Location: Stevenage, UK
The way I thought of it is that the reveng.xml file should be able to contain over-rides for pretty much everything that can go into the hbm.xml files - I expected the reveng.xml file to basically say "you use what the database says is there, and use the defaults, except for the following special cases" - i.e. the file says what the special cases are - that's what it's there for.

So, if you're not doing anything fancy, the reveng.xml file is mostly empty (it'll just say what tables to do, most probably "all the non-system tables"), the tools will use the defaults for everything, and that'll be fine.

If the code you need to be generated is far less consistent and you need lots of special case behavior (e.g. "don't include this password attribute in any toString method"), the reveng.xml file is the best place for that. The alternative would be to have some really ugly templates that know to do different things according to table name.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Feb 07, 2006 10:07 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
yes, reveng.xml is for "configure exceptions".....but only a subset of what is in hbm.xml make sense to have here ( i think ) ....but again that subset is still bigger than what we have now ;)

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:22 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
Max,

About using our own templates via hbmtemplate it is only for configuring the generated java files, but what about the *.hbm.xml file???, there is no way to customize the genered process setting via a given attribute the particular template. The example on the User Manual is just for the case we want to modify the generated *.java classes.

I am trying to modify the way the *.hbm.xml are generated by hand, because there is no other way for the moment. For example in order to generate the meta information for generating the toString and equal methods. I was looking into the file hbm/persistentclass.hbm.vm file and I just added the following lines at the end of the file:

Code:
<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>


before the symbol >, so on the line 61

but it doesn't work, I get the following error:

Code:
P:\LRA\build.xml:632: org.hibernate.tool.hbm2x.ExporterException: Tidy was unable to process file

using ant task, so I am doing something wrong, please do you have any idea about the syntax to use on this file?, I know it is velocity syntax, but I think that this is accepted by velocity, so I don't understand why it gives me such error.

Thanks in advance,

David

_________________
David Leal


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:35 pm 
Beginner
Beginner

Joined: Tue Jan 24, 2006 1:48 pm
Posts: 20
Location: Stevenage, UK
you need to append those lines after the final >

e.g. my hbm/persistentclass.hbm.vm finishes as follows:
Code:
#if ($clazz.table.rowId)
    rowid="$clazz.table.rowId"
#end
>
   <meta attribute="class-description">
Plain old Java object that maps onto the $clazz.table.quotedName
#if ($clazz.table.schema)
table in the $clazz.table.quotedSchema schema.
#else
table.
#end
&lt;br&gt;
It was auto-generated on $date by Hibernate Tools $version.
   </meta>


The first 4 lines I've quoted came from the original file. The remainder I added on myself.
The thing with this file is that it isn't XML - the < and > don't match within this file - this file represents the start of things, not the entire lot, hence you don't see the final closing > in this file (hence the confusion).


Top
 Profile  
 
 Post subject:
PostPosted: Wed Feb 08, 2006 1:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
you are doing it correctly, you just need to ensure the tags are placed correctly.

im surprised we actually halts if tidy can't process it - please report that in jira, we shouldn't.

finally, this stuff have been changed in the current cvs.

1. We are using freemarker now (see our blog and thread here in the forum)

2. the hbm templates follow a similar structure as the pojo.vm's does now. e.g. driving the generation of one file from a master with includes instead of the old behavior with an exporter calling out to many templates (which made sense when velocity were the template engine that did not tell about errors consistently)

/max

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: It works!!!
PostPosted: Wed Feb 08, 2006 2:45 pm 
Beginner
Beginner

Joined: Mon Nov 28, 2005 11:03 am
Posts: 39
Location: Madrid
pjdarton, following your indication and modifying the file as you said it works, now I have finally toString() methods and equals for all my generated *.hbm.xml and *.java files.

So there is no need to add a request on JIRA Max.

Thanks to all of you,

David Leal

_________________
David Leal


Top
 Profile  
 
 Post subject: meta attributes
PostPosted: Mon Feb 13, 2006 9:34 pm 
Regular
Regular

Joined: Fri Mar 04, 2005 1:33 pm
Posts: 65
Location: U.K.
Hi

I have found a way to insert 'use-in-equals' and 'use-in-tostring' in *.hbm.xml. I have spent numerous hours finding it, so be generous and award some points ...

Your hbm2hbmxml task need to look like this inside hibernatetool tag:

<hbm2hbmxml templatepath="${hibernate.cfg.dir}" destdir="${gen.hibernate.mapping.dir}"/>

Under hibernate.cfg.dir make a directory called 'hibernate' and underneath hibernate create a directory called 'hbm'. Unzip hibernate-tools.jar and extract property.hbm.vm and add following:

<meta attribute="use-in-tostring">true</meta>
<meta attribute="use-in-equals">true</meta>


A check on boolean is required as we can call toString() function on boolean primitive. Hope it helps and saves your time.

PS: I wish we have more documentation on tasks like hbm2hbm and hbm2java, it will make everybody's life easier. I know what is your reply going to be, so spare it ...

Take it easy,

-- Ron


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 33 posts ]  Go to page 1, 2, 3  Next

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.