Composite-id with multi-column foreign key woes

Jeremy Hanna <[email protected]> Wed, 15 Jun 2005 14:31:02 -0600
Newsgroups gmane.comp.java.ejb.middlegen.user
Message-ID <[email protected]>
I have searched through books and documentation and maybe because I'm  
cramming so much, I can't figure out why a middlegen created mapping  
and subsequent Java file are not loaded by hibernate.
I am trying to map a table that has three columns in its primary  
key.  The first is simply a number to order the user's preferences.   
The second and third columns in the primary key make up a foreign key  
to another table.  Middlegen creates a composite-id and using the:
<key-many-to-one...>
tag, creates the foreign key many-to-one relationship within the  
composite-id definition.  When hbm2java does its thing, the class  
constructor takes 2 parameters - the preferences order number, and an  
object that maps to the foreign keyed table.
I've tried to use a simple composite id and then do the many-to-one  
association separately in the mapping file by hand (though we're  
supposed to be using the generated mappings), but that gives me the  
same problem.
The error that I'm getting is:
identifier mapping has wrong number of columns:
which is a MappingException.

So is there something I need to do when I put the mappings into the  
hibernate.cfg.xml file to indicate that it needs to handle it  
specially?  Is there some configuration option I need to specify with  
the table in the MiddleGen gui?

I am using Middlegen2.0 and Hibernate 2.1.  I can't use Middlegen2.1  
because it didn't work with Oracle 10g correctly, it kept giving me  
problems when I tried to specify the schema.
Also I have to purge the recyclebin each time I want to run  
Middlegen, just as a sidenote to those who may have trouble with  
Oracle 10g and don't know what to do.

Any help on this will be heroic for me :)
Jeremy