tracker issue : CF-3122013

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

Mapping a many-to-one ignores the column attribute

| View in Tracker

Status/Resolution/Reason: Closed/Withdrawn/

Reporter/Name(from Bugbase): Dave DuPlantis / Dave DuPlantis (Dave DuPlantis)

Created: 02/23/2012

Components: ORM Support

Versions: 9.0.1

Failure Type: Incorrect w/Workaround

Found In Build/Fixed In Build: 9.0.1 /

Priority/Frequency: Normal / Some users will encounter

Locale/System: English / Windows 7

Vote Count: 0

Problem Description: When creating a many-to-one relationship between objects, the column attribute is not passed from ColdFusion to Hibernate, so it is not possible to map anything on the many side other than the foreign key.

Steps to Reproduce: 
Create Product.cfc with productID (from column product_ID) as primary key. Create RecommendedProduct.cfc with an auto-generated ID and two properties, parentID (from column product_ID) and recommendedProductID (from column recommendedProduct_ID). 

Create two relationships in Product:
	property name="recommendedProducts"    
		 fieldtype="one-to-many" 
		 cfc="RecommendedProduct"
		 lazy="true"
		 orderby="ranking";
		 
	property name="recommendedBy"    
		 fieldtype="one-to-many" 
		 cfc="RecommendedProduct"
		 lazy="true"
		 fkcolumn="RecommendedProduct_ID";

Create two relationships in RecommendedProduct: 
	property name="parentProduct"    
		 fieldtype="many-to-one" 
		 cfc="Product"
		 lazy="true"
		 inverse="true" insert="false" update="false";

	property name="relatedProduct"    
		 fieldtype="many-to-one" 
		 cfc="Product"
		 lazy="true"
		 inverse="true" insert="false" update="false"
		 column="recommendedProductID";

Add records to the Product table with IDs 1, 2, 3, and 4. Add records to the RecommendedProduct table with product_ID/recommendedproduct_ID pairs of (1,2), (1,3) and (1,4).

Load a Product object from ID 1. Dump the value of getRecommendedProducts().

Actual Result:
parentProduct and relatedProduct return the same object for each element returned by getRecommendedProducts().

Expected Result:
relatedProduct should return the object with the ID from recommendedProduct_ID, not product_ID.

Any Workarounds:
Set saveMapping to true and manually edit the hbmxml file for RecommendedProduct, changing the column attribute in the relatedProduct relationship to RecommendedProduct_ID.

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

Watson Bug ID:	3122013

External Customer Info:
External Company:  
External Customer Name: Dave DuPlantis
External Customer Email:  
External Test Config: My Hardware and Environment details:

Attachments:

Comments:

this is not Windows 7, but Windows Vista; not sure why that's not available in the Platform select box
Comment by External U.
20621 | February 23, 2012 01:10:57 PM GMT
Please use fkcolumn instead of column. <cfproperty name="recommendedProducts" fieldtype="one-to-many" cfc="RecommendedProduct" fkcolumn="product_ID" > <cfproperty name="recommendedBy" fieldtype="one-to-many" cfc="RecommendedProduct" fkcolumn="recommendedProduct_ID"> <cfproperty name="parentProduct" fieldtype="many-to-one" cfc="Product" inverse="true" insert="false" update="false" fkcolumn="product_ID"> <cfproperty name="relatedProduct" fieldtype="many-to-one" cfc="Product" inverse="true" insert="false" update="false" fkcolumn="recommendedProduct_ID">
Comment by Himavanth R.
20622 | February 29, 2012 08:48:32 AM GMT