-->
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.  [ 3 posts ] 
Author Message
 Post subject: Don't create Set for one-to-many
PostPosted: Thu Jun 21, 2007 10:57 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
Hello,

I have a problem using Hibernate Tools for reverse engineering. The one-side of a one-to-many-relation should not have a "Set<ManySideType>" inside.

Every entityA class that is generated has a Set of entitiyB that reference entityA. Have a look at these example tables:

Code:
---------------------------
Person
id    name     fk_car_id
---------------------------

---------------------------
Car
id    name
---------------------------


My Person entity hast an attribute "Car car;" that is exactly what I want. But on the other side the Car entity has a "Set<Person> person" in that case I don't want the Set inside.

How do I tell Hibernate Tools to leave out the Sets of the one-side in a one-to-many-relation?

Overwriting (one of) the following methods in the ReverseEngineeringStrategy doesn't help. This has side effects:

Code:
   @Override
                      // removes ALL Sets
   public boolean excludeForeignKeyAsCollection(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
      return super.excludeForeignKeyAsCollection(arg0, arg1, arg2, arg3, arg4);
   }
   
   @Override
                    // doesn't work either
   public boolean excludeForeignKeyAsManytoOne(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
      return super.excludeForeignKeyAsManytoOne(arg0, arg1, arg2, arg3, arg4);
   }


The most improtant part of my ant-build (I am using a template as well):

Code:
           <jdbcconfiguration configurationfile="${src}/hibernate.cfg.xml"
            reversestrategy="org.revengstrategy.MyReverseEngineeringStrategy"
              revengfile="${buildconfig}/hibernate.reveng.xml"
              packagename= "org.entity"/>

         <!-- Generate entities -->
            <hbmtemplate
                templateprefix=""
               filepattern="../entity/{class-name}.java"
               templatepath="${templatepath}/entity"
               template="Pojo.ftl"  >
               <property key="jdk5" value="true" />
               <property key="ejb3" value="false" />
            </hbmtemplate>


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jun 21, 2007 11:46 am 
Regular
Regular

Joined: Wed Nov 01, 2006 2:17 pm
Posts: 78
This does not work either ... although I would strongly expect this to work:

Code:
   @Override
   public boolean excludeForeignKeyAsCollection(String arg0, TableIdentifier arg1, List arg2, TableIdentifier arg3, List arg4) {
      return isForeignKeyCollectionInverse(arg0,arg1,arg2,arg3,arg4);
   }


The collection in the Car class would be inverse, it is excluded, but every other Set is excluded as well?!


Top
 Profile  
 
 Post subject:
PostPosted: Fri Jun 22, 2007 3:25 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 6:10 am
Posts: 8615
Location: Neuchatel, Switzerland (Danish)
why don't you just return true ?

_________________
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.  [ 3 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.