I am working on mapping our java classes to legacy DB. There are two tables. Both tables use composite id's. To make matters worse, TableB's foreign key reference to table A  references one column in the primary key and another column that is not part of Table A's primary key. (I know this is a bad relational model, unfortunately, changing the schema is not an option). In order to work around this problem, I decided to use the property-ref in my mapping. Unfortunately, when I excecute I get a ClassCastException. (See stack trace below) I also noticed that other people were having problem similar to this as recently as version 3.1. Is this a case of an incorrect mapping document, or is it possible this is due to the bug mentioned here:  
http://opensource.atlassian.com/project ... se/HB-1526
Any help would be appreciated.
Hibernate version: 
3.0
Mapping documents:
<hibernate-mapping package="com.idfbins.adp">
    <class name="InsuranceMaster" table="INMAST" schema="fbmtstdta" catalog="FBMAS270">
        <composite-id name="inKey" class="InsuranceMasterKey">
        	<key-property name="company" column="INMCMPY" type="string"/>
        	<key-property name="policy" column="INMPRFX" type="string"/>
        	<key-property name="suffix" column="INMSUFX" type="string"/>
        </composite-id>
        
        <property 
        	name="fedSuffix"
        	column="INMFEDSX"
        	type="long"
        />
        
		<properties name="FBAltKey" insert="false" update="false">
			<component name="fbKey" class="FederationMasterKey">
				<property name="policy"  column="INMPRFX" insert="false" update="false"></property>
			</component>
			<property name="fedSuffix" column="INMFEDSX" update="false" insert="false"></property>
		</properties>
	
		<set name="fedRecords"
			lazy="false"
			
			>
		<key property-ref="FBAltKey">
			<column name="FBPRFX"></column>
			<column name="FBSUFX"></column>
		</key>
		<one-to-many class="FederationMaster" />
		</set>	
        
	</class>	
</hibernate-mapping>
<hibernate-mapping package="com.idfbins.adp">
    <class name="FederationMaster" table="FBMAST" schema="fbmtstdta" catalog="FBMAS270">
        <composite-id name="fbKey" class="FederationMasterKey">
        	<key-property name="policy" column="FBPRFX" />
        	<key-property name="suffix" column="FBSUFX" />
        	<key-property name="sequence" column="FBSEQ" />
        </composite-id>
        
        <property 
        	name="firstName"
        	column="FBFNAME"
        	type="string"
        />
        
        <property 
        	name="lastName"
        	column="FBLNAME"
        	type="string"
        />
        
        
        
	</class>	
</hibernate-mapping>
Full stack trace of any exception that occurs:
14:33:54,772 DEBUG LongType:86 - returning '1' as column: INMFEDSX5_0_
14:33:54,772 DEBUG StringType:86 - returning '76829' as column: INMPRFX5_0_
14:33:54,772 DEBUG LongType:86 - returning '1' as column: INMFEDSX5_0_
14:33:54,772 DEBUG Loader:429 - done processing result set (1 rows)
14:33:54,788 DEBUG AbstractBatcher:313 - about to close ResultSet (open ResultSets: 2, globally: 2)
14:33:54,788 DEBUG AbstractBatcher:298 - about to close PreparedStatement (open PreparedStatements: 2, globally: 2)
14:33:54,788 DEBUG AbstractBatcher:416 - closing statement
14:33:54,788 DEBUG Loader:528 - total objects hydrated: 1
14:33:54,788 DEBUG TwoPhaseLoad:96 - resolving associations for [com.idfbins.adp.InsuranceMaster#component[company,policy,suffix]{policy=76829, suffix=1, company=1}]
Exception in thread "main" java.lang.ClassCastException: com.idfbins.adp.InsuranceMaster
	at org.hibernate.type.CollectionType.getKeyOfOwner(CollectionType.java:313)
	at org.hibernate.type.CollectionType.resolve(CollectionType.java:326)
	at org.hibernate.engine.TwoPhaseLoad.initializeEntity(TwoPhaseLoad.java:105)
	at org.hibernate.loader.Loader.initializeEntitiesAndCollections(Loader.java:530)
	at org.hibernate.loader.Loader.doQuery(Loader.java:436)
	at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:218)
	at org.hibernate.loader.Loader.loadEntity(Loader.java:1345)
	at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:116)
	at org.hibernate.loader.entity.EntityLoader.load(EntityLoader.java:101)
	at org.hibernate.persister.entity.BasicEntityPersister.load(BasicEntityPersister.java:2471)
	at org.hibernate.event.def.DefaultLoadEventListener.loadFromDatasource(DefaultLoadEventListener.java:351)
	at org.hibernate.event.def.DefaultLoadEventListener.doLoad(DefaultLoadEventListener.java:332)
	at org.hibernate.event.def.DefaultLoadEventListener.load(DefaultLoadEventListener.java:113)
	at org.hibernate.event.def.DefaultLoadEventListener.onLoad(DefaultLoadEventListener.java:75)
	at org.hibernate.impl.SessionImpl.immediateLoad(SessionImpl.java:643)
	at org.hibernate.proxy.AbstractLazyInitializer.initialize(AbstractLazyInitializer.java:59)
	at org.hibernate.proxy.AbstractLazyInitializer.getImplementation(AbstractLazyInitializer.java:84)
	at org.hibernate.proxy.CGLIBLazyInitializer.intercept(CGLIBLazyInitializer.java:134)
	at com.idfbins.adp.InsuranceMaster$$EnhancerByCGLIB$$1e70e55f.getFbKey(<generated>)
	at com.idfbins.adp.MyTest.main(MyTest.java:26)
Name and version of the database you are using:
DB2 UDB