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