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.  [ 1 post ] 
Author Message
 Post subject: Reverse Engineering many-to-many problem
PostPosted: Fri Aug 01, 2008 5:28 am 
Newbie

Joined: Thu May 15, 2008 10:04 am
Posts: 7
Location: uk
Hibernate version: 3.2.2.ga
Hibernate Tools version: 3.2.0.ga

Name and version of the database you are using: Oracle 9

Hi

Im trying to reverse engineer my db and have run into a problem with some of my tables.

The tables in question have two columns, one column defined as a PK and FK, the other as a FK. The reverse engineering process doesn't generate a mapping file for these tables. Looking in the logs it appears as though these tables are viewed as many-to-many tables.

Message in logs: Ignoring org.hibernate.mapping.Table(TABLEA) as class since rev.eng. says it is a many-to-many.

My understanding was that for it to be a many-to-many then both columns should be primary keys, not just foreign keys. If that's the case then the code below should be looping around the primary keys (not the foreign keys) and removing them from the set. Is that right? If so, is this a known issue?

The following code is in DefaultReverseEngineeringStrategy.isManyToMany()

Code:
         Set columns = new HashSet();
         Iterator columnIterator = table.getColumnIterator();
         while ( columnIterator.hasNext() ) {
            Column column = (Column) columnIterator.next();
            columns.add(column);
         }
      
         foreignKeyIterator = table.getForeignKeyIterator();
         while ( !columns.isEmpty() && foreignKeyIterator.hasNext() ) {
            ForeignKey element = (ForeignKey) foreignKeyIterator.next();            
            columns.removeAll( element.getColumns() );            
         }
         // what if one of the columns is not the primary key?
         return columns.isEmpty();


Cheers
Al


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 1 post ] 

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.