tracker issue : CF-3038668

select a category, or use search below
(searches all categories and all time range)
Title:

Bug 77402:Possibly related to 75999

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Darron Schall / Darron Schall (darronschall)

Created: 05/21/2009

Components: ORM Support

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 9,0,0,233019 /

Priority/Frequency: Normal / Unknown

Locale/System: English / Mac 10 All

Vote Count: 0

Duplicate ID:	CF-3037896

Problem:

Possibly related to 75999.

When using mappedby in a one-to-many relationship, the generated .hbm.xml file contains an invalid property-ref in the <key/> node for the property.  Hibernate thinks the property-ref in the key node relates back to original CFC, and not the referenced CFC that the mappedby column is for.  An example of the error being thrown is: [warehouse] not found on entity [Warehouse] 

See the steps to reproduce for more detail.
Method:

Warehouse.cfc
~~~~~~~~~~~~~
<cfproperty name="warehouseID" column="WAREHOUSE_ID" 
			fieldType="id" generator="increment" 
			type="numeric" datatype="integer" length="10"  />

<cfproperty name="products" fieldtype="one-to-many" 
		cfc="WarehouseProduct" mappedby="warehouse"
		collectiontype="array" 
		lazy="false" cascade="all" inverse="false">


WarehouseProduct.cfc
~~~~~~~~~~~~~~~~~~~
<cfproperty name="warehouseProductID" column="WAREHOUSE_PRODUCT_ID" fieldtype="id" type="numeric" datatype="integer" length="10" />
	
<cfproperty name="warehouse" fieldtype="one-to-one" cfc="Warehouse" fkcolumn="WAREHOUSE_ID" />
	
<cfproperty name="unitsInStock" column="UNITS_IN_STOCK" type="numeric" datatype="integer" length="10"  />


I've omitted a few other properties that aren't really relevant in the CFCs.  The general setup here is that a Warehouse has a list of WarehouseProducts.  The WAREHOUSE_PRODUCTS table has a WAREHOUSE_ID foriegn key that links back to the primary key WAREHOUSE_ID of the WAREHOUSES table.

From the above Warehouse.cfc, the following hibernate mapping is generated:

<hibernate-mapping>
    <class entity-name="Warehouse" lazy="false"
        name="cfc:Warehouse" table="WAREHOUSES">
        <id name="warehouseID" type="integer">
            <column length="10" name="WAREHOUSE_ID"/>
            <generator class="increment"/>
        </id>
        
        <bag cascade="all" lazy="false" name="products">
            <key column="WAREHOUSE_ID" property-ref="warehouse"/>
            <one-to-many class="cfc:WarehouseProduct"/>
        </bag>
        
    </class>
</hibernate-mapping>

When I try to run an application, I get the following CF Error:
property [warehouse] not found on entity [Warehouse] 


If I manually edit the mapping file and remove the property-ref on the key node (so it just comes):

<bag cascade="all" lazy="false" name="products">
            <key column="WAREHOUSE_ID" />
            <one-to-many class="cfc:WarehouseProduct"/>
        </bag>

Then it works fine.

The only way you can actually work around this bug is if you save the mapping files to disk and then manually edit the mapping by hand.
Result:

----------------------------- Additional Watson Details -----------------------------

Watson Bug ID:	3038668

Deployment Phase:	Release Candidate

External Customer Info:
External Company:  
External Customer Name: Darron Schall
External Customer Email: 65E53F91439B07610AAC0C15
External Test Config: 05/21/2009

Attachments:

Comments: