-->
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: Issues with reverse engineering
PostPosted: Fri Aug 08, 2008 5:18 am 
Newbie

Joined: Fri Aug 08, 2008 4:37 am
Posts: 5
Hibernate version:
3.1.3
Hibernate tools version:
3.2.2 beta 1

This is not an error rather I am asking for suggestions on how to work around manual changes.

I have the following setup which is running in production right now.
Around 60 tables with diverse contents.
From these tables are generated hbm files and POJO's.
But I have a number of issues which I have not been able to configure when generating hbm files. The issues are concerned with having to manually change the hbm files after database generation.

    1. I do not want my hbm files to contain the name of the catalog and schema. The reasone for this is that I have a number of different databases both in production and test which have different names. Is there a way to specify that we do not want these attributes in the hbm files?
    2. I have been able to set the generated class attribute for all tables, using a CustomRevengStrategy and meta attributes. This does not work for classes with composite id's however . Here I have to specify manually the name of the composite id's base class in the meta attribute. Is there anyway to do this automatically?
    3. I have a number of property fields which are based on formulas in the hbm files. These would be nice to write in the hibernate reverse engineering file like in some way like; "....
    <table name="XXX>
    <column name="xxx" type="xxx" formula="xxxx"/>
    </table>
    But unfortunately this is not supported... Is there some other way to do this?
    4. On some of the tables is a <timestamp> property.
    These are generated from hibernate as a <property name="xxx" type="timestamp">... instead of <timestamp name="xxx" coloumn="Xxx" />. Is there some way to control this?


Top
 Profile  
 
 Post subject: Re: Issues with reverse engineering
PostPosted: Sun Aug 10, 2008 5:43 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
4nd3r5 wrote:
    1. I do not want my hbm files to contain the name of the catalog and schema. The reasone for this is that I have a number of different databases both in production and test which have different names. Is there a way to specify that we do not want these attributes in the hbm files?


set default_schema and default_catalog and if the catalog/schema matches it won't end up in the mapping files.

Quote:
    2. I have been able to set the generated class attribute for all tables, using a CustomRevengStrategy and meta attributes. This does not work for classes with composite id's however . Here I have to specify manually the name of the composite id's base class in the meta attribute. Is there anyway to do this automatically?


Please report with instructions on how to reproduce in jira - sounds like a bug.

Quote:
    3. I have a number of property fields which are based on formulas in the hbm files. These would be nice to write in the hibernate reverse engineering file like in some way like; "....
    <table name="XXX>
    <column name="xxx" type="xxx" formula="xxxx"/>
    </table>
    But unfortunately this is not supported... Is there some other way to do this?


hmm..ever considered writing mapping files ? :)

reveng.xml is mostly about the relational info, but I guess we could add this in...just not sure sure how yet. Put it in jira.

p.s. you can always add it to the templates manually.,,
Quote:
    4. On some of the tables is a <timestamp> property.
    These are generated from hibernate as a <property name="xxx" type="timestamp">... instead of <timestamp name="xxx" coloumn="Xxx" />. Is there some way to control this?


you can write a custom revengstrategy that identifies xxx as the optimistic lock column.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject: Re: Issues with reverse engineering
PostPosted: Sun Aug 10, 2008 6:22 pm 
Newbie

Joined: Fri Aug 08, 2008 4:37 am
Posts: 5
max wrote:
4nd3r5 wrote:
    1. I do not want my hbm files to contain the name of the catalog and schema. The reasone for this is that I have a number of different databases both in production and test which have different names. Is there a way to specify that we do not want these attributes in the hbm files?


set default_schema and default_catalog and if the catalog/schema matches it won't end up in the mapping files.


Where do you set this? Which file?
Quote:
Quote:
    2. I have been able to set the generated class attribute for all tables, using a CustomRevengStrategy and meta attributes. This does not work for classes with composite id's however . Here I have to specify manually the name of the composite id's base class in the meta attribute. Is there anyway to do this automatically?


Please report with instructions on how to reproduce in jira - sounds like a bug.


This is not a bug, it works fine, but i just cant create the second meta attribute in the below hbm file.
My hbm files look like this;
<class name="XXX1" table="XXX1">
<meta attribute="generated-class">XXX1Base</meta>
<composite-id name="XXX2" class="XXX2">
<meta attribute="generated-class">XXX2Base</meta>
.....

The first meta attibute is constructed by using a custom reveng strategy class where the method tableToMetaAttributes() is overwritten.
But can i do the same with the composite id meta attributes?

Quote:

Quote:
    3. I have a number of property fields which are based on formulas in the hbm files. These would be nice to write in the hibernate reverse engineering file like in some way like; "....
    <table name="XXX>
    <column name="xxx" type="xxx" formula="xxxx"/>
    </table>
    But unfortunately this is not supported... Is there some other way to do this?


hmm..ever considered writing mapping files ? :)

reveng.xml is mostly about the relational info, but I guess we could add this in...just not sure sure how yet. Put it in jira.

p.s. you can always add it to the templates manually.,,



The thing is we really want the mapping files and pojos to be genererated automatically by reverse enginering and that is why i would like this ;-).

How would you do it with a template? I havent used these before...
Quote:
Quote:
    4. On some of the tables is a <timestamp> property.
    These are generated from hibernate as a <property name="xxx" type="timestamp">... instead of <timestamp name="xxx" coloumn="Xxx" />. Is there some way to control this?


you can write a custom revengstrategy that identifies xxx as the optimistic lock column.

OK so I just override the method "getOptimisticLockColumnName" and return i.e. modifiedDate as a string if that is the name of our timestamp coloumn?

Thanks for you reply btw...
/Anders


Top
 Profile  
 
 Post subject: Re: Issues with reverse engineering
PostPosted: Mon Aug 11, 2008 7:08 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
4nd3r5 wrote:
max wrote:
4nd3r5 wrote:
    1. I do not want my hbm files to contain the name of the catalog and schema. The reasone for this is that I have a number of different databases both in production and test which have different names. Is there a way to specify that we do not want these attributes in the hbm files?


set default_schema and default_catalog and if the catalog/schema matches it won't end up in the mapping files.


Where do you set this? Which file?
Quote:


in persistence.xml or cfg.xml or hibernate.properties depending on what you are using.

Quote:
    2. I have been able to set the generated class attribute for all tables, using a CustomRevengStrategy and meta attributes. This does not work for classes with composite id's however . Here I have to specify manually the name of the composite id's base class in the meta attribute. Is there anyway to do this automatically?


Please report with instructions on how to reproduce in jira - sounds like a bug.


This is not a bug, it works fine, but i just cant create the second meta attribute in the below hbm file.
My hbm files look like this;
<class name="XXX1" table="XXX1">
<meta attribute="generated-class">XXX1Base</meta>
<composite-id name="XXX2" class="XXX2">
<meta attribute="generated-class">XXX2Base</meta>
.....

The first meta attibute is constructed by using a custom reveng strategy class where the method tableToMetaAttributes() is overwritten.
But can i do the same with the composite id meta attributes?
Quote:


ah...we might not have that covered...not sure where to put that info in reveng.xml either...anyway report it in jira - we might need a compoentToMetaAttributes or something.

Quote:
Quote:
    3. I have a number of property fields which are based on formulas in the hbm files. These would be nice to write in the hibernate reverse engineering file like in some way like; "....
    <table name="XXX>
    <column name="xxx" type="xxx" formula="xxxx"/>
    </table>
    But unfortunately this is not supported... Is there some other way to do this?


hmm..ever considered writing mapping files ? :)

reveng.xml is mostly about the relational info, but I guess we could add this in...just not sure sure how yet. Put it in jira.

p.s. you can always add it to the templates manually.,,



The thing is we really want the mapping files and pojos to be genererated automatically by reverse enginering and that is why i would like this ;-).
[/quote]

well...come contribute patches for the missing usecases then ;)

Quote:
How would you do it with a template? I havent used these before...
Quote:

customize the .ftl files to do different things depending on the content of the mappings....you can do anything / which is its power and weakness ;)

Quote:
    4. On some of the tables is a <timestamp> property.
    These are generated from hibernate as a <property name="xxx" type="timestamp">... instead of <timestamp name="xxx" coloumn="Xxx" />. Is there some way to control this?


you can write a custom revengstrategy that identifies xxx as the optimistic lock column.

OK so I just override the method "getOptimisticLockColumnName" and return i.e. modifiedDate as a string if that is the name of our timestamp coloumn?


yes, that is one way.

_________________
Max
Don't forget to rate


Top
 Profile  
 
 Post subject:
PostPosted: Thu Aug 28, 2008 9:13 am 
Newbie

Joined: Fri Aug 08, 2008 4:37 am
Posts: 5
As a result of this thread i have opened two Jira issues:

http://opensource.atlassian.com/project ... e/HBX-1081
http://opensource.atlassian.com/project ... e/HBX-1082


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.