-->
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.  [ 2 posts ] 
Author Message
 Post subject: Bug in SchemaUpdate or HibernateTool - entity-name problem?
PostPosted: Thu Apr 09, 2009 11:04 am 
Newbie

Joined: Thu Apr 09, 2009 10:38 am
Posts: 3
I'm using the SchemaUpdate and HibernateTool tasks in Hibernate 3.1.2.

We use the tools to generate both POJOs and database schema from the mapping files i.e. HibernateToolTask and SchemaUpdateTask.

I am trying to map a class (FlowDetail) to 2 different tables using the entity-name attribute, however, I have a conflict when using/not using the entity-name attribute in a many-to-one entity.

I have a DisconD0132 object which has a one-to-one relationship with a FlowDetail object. These are mapped to DISCON_D0132 and DISCON_D0132_FD tables respectively. The FlowDetail object also has another mapping to a FLOW_DETAILS table.

If my mappings are as follows:
Code:
<many-to-one name="DisconD0132FlowDetail"
                 class="uk.co.formfill.dfcommon.domain.dfwv.FlowDetail"
                 column="DISCON_D0132_FLOW_DETAIL_ID"
                 cascade="all" unique="true" />

<class name="uk.co.formfill.dfcommon.domain.dfwv.FlowDetail"
          table="DISCON_D0132_FD"
          entity-name="DisconD0132FlowDetail">

this correctly generates the POJO containing a nested FlowDetail object and the correct tables, however, the foreign key generated in the DISCON_D0132 table references another table that the FlowDetail object is mapped to, FLOW_DETAILS.

If I change the many-to-one mapping to include the entity-name attribute i.e.
Code:
<many-to-one name="DisconD0132FlowDetail"
                 class="uk.co.formfill.dfcommon.domain.dfwv.FlowDetail"
                 entity-name="DisconD0132FlowDetail"
                 column="DISCON_D0132_FLOW_DETAIL_ID"
                 cascade="all" unique="true" />

this generates the correct foreign key reference, but the POJO is incorrectly generated containing a DisconD0132FlowDetail object which does not exist.

The only way I have found round this is to suppress the generation of the foreign key, but this is not really satisfactory. Could somebody tell me whether my mappings are incorrect or whether this is a bug?


Top
 Profile  
 
 Post subject: Re: Bug in SchemaUpdate or HibernateTool - entity-name problem?
PostPosted: Tue May 05, 2009 7:32 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
I cant fully follow your problem.

Could you please show the generated code you are having problems with ?

_________________
Max
Don't forget to rate


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