tracker issue : CF-3041877

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

Bug 83807:(Watson Migration Closure)When using a one-to-one relationship for a primary key association (as described here: http://help

| View in Tracker

Status/Resolution/Reason: Closed/Won't Fix/

Reporter/Name(from Bugbase): Gregory Jacobs / Bob Smith (Gjake6)

Created: 08/11/2010

Components: ORM Support

Versions: 9.0

Failure Type: Unspecified

Found In Build/Fixed In Build: 274733 /

Priority/Frequency: Normal / Unknown

Locale/System: Japanese / Win All

Vote Count: 0

Problem:

When using a one-to-one relationship for a primary key association (as described here: http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WS5FFD2854-7F18-43ea-B383-161E007CE0D1.html#WS606584AD-43B2-48c1-B9E6-69A670694BBB), there is a problem when the parent object is merged into the session before saving it with entitySave().  An error gets thrown on the entitySave() call saying:  org.hibernate.action.DelayedPostInsertIdentifier cannot be cast to java.lang.Integer.What happens is that when the parent object and the child object are originally created, both have a null ID property.  When the parent object is merged into the session using entityMerge(), the parent object's ID property remains null, but the child object's ID property gets an instance of org.hibernate.action.DelayedPostInsertIdentifier.  When the parent object is then persisted, the ORM cannot insert the cascaded child object because it cannot convert that DelayedPostInsertIdentifier object into an integer for the child object's ID property.  It seems to me that as soon as the parent object is inserted, the DelayedPostInsertIdentifier object in the child's ID property should be replaced with the actual ID of the parent object.  Then when the ORM inserts the child object, it will be inserting the correct ID.  Check out the URL for the error.
Method:

Using an application in 'dropcreate'  mode, try these files:Person.cfc:<cfcomponent output="no" persistent="true" entityName="Person" table="people"><cfproperty name="personID" type="numeric" fieldType="id" generator="native" ormtype="integer"><cfproperty name="firstName" type="string"><cfproperty name="lastName" type="string"><cfproperty name="address" fieldtype="one-to-one" cfc="Address" cascade="all"></cfcomponent>Address.cfc:<cfcomponent output="no" persistent="true" entityName="Address" table="addresses"><cfproperty name="personID" fieldType="id" generator="foreign" params="{property='person'}" ormtype="integer"><cfproperty name="person" fieldType="one-to-one" cfc="Person" constrained="true"><cfproperty name="street" type="string"><cfproperty name="city" type="string"><cfproperty name="state" type="string"><cfproperty name="zip" type="string"></cfcomponent>index.cfm:<cfset ORMReload()><cfset person = new Person()><cfset person.setFirstName( "John" )><cfset person.setLastName( "Smith" )><cfset address = new Address()><cfset address.setStreet( "123 Summersville Road" )><cfset address.setCity( "Summersville" )><cfset address.setState( "FL" )><cfset address.setZip( "12345" )><cfset address.setPerson( person )><cfset person.setAddress( address )><!--- Want to be able to merge the object into the ORM session first ---><cfset person = entityMerge( person )><cfdump var="#person#"><!--- But merging the object into the ORM session first causes this line to error ---><cfset entitySave( person )>
Result:

Error casting an object of type org.hibernate.action.DelayedPostInsertIdentifier cannot be cast to java.lang.Integer to an incompatible type. This usually indicates a programming error in Java, although it could also mean you have tried to use a foreign object in a different way than it was designed.

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

Watson Bug ID:	3041877

External Customer Info:
External Company:  
External Customer Name: Bob Smith
External Customer Email: 3C41504F4BF9A62E0A04B833
External Test Config: 08/11/2010

Attachments:

Comments: