rss
twitter
Find out what I'm doing, Follow Me :)

mappedsuperclass and one-to-one mapping error

2
 

ORM drove me nuts today. After hrs and hrs of frustation, finally I was able to find the issue. It seems to be an error with use of one-to-one relationship with mappedsuperclass. Consider this simple example:

Data.cfc

 

component persistent="true" {	


	property name="dataID" ormtype="int" fieldtype="id" generator="identity" unsavedvalue="0" default="0" ; 


	property name="extraData" fieldtype="one-to-one" cfc="ExtraData" cascade="all"  ;


}


 

ExtraData.cfc

component persistent="true" extends="ExtraDataBase" {


}

 

ExtraDataBase.cfc

 

component mappedsuperclass="true" {


	property name="dataID" ormtype="int" fieldtype="id" generator="foreign" params="{property='data'}" ;


	property name="data" fieldtype="one-to-one" cfc="Data" constrained="true"  ;


}


 

Really straight forward setup. If you run this ORM won't be able to create the database tables. It throws the error:

"Error while resolving the relationship extraData in cfc Data. Check the column mapping for this property."

If I create the the ExtraData table manually everything works just fine. If I remove the one-to-one relationship everything works fine too. Once the table is created ORM is able to "manage" it and add new properties (fields) without issue.

What threw me for a loop is it didn't generate any DDL error. In fact it wasn't even running DDL!

I must say, other than few of these hickup, that will make you scream at the top of your voice, ORM is AWESOME! I love it. Specially with 9.0.1 multiple database support and proper transaction handling, it rocks!

 

Comments

Sumit Verma

Hi Marc,

It certainly sounds related issue as it is related to DDL creation with mappedsuperclass.

But, seems like the issue you reported is fixed now. I was able to get it to work with your setup. In fact it even works for one-to-one relationship with Foreign key mapping. It just doesn't work with primary key constrained mapping.

I did reported it as a bug. I will update the post once I have a bug number. (which I don't understand why I don't get when I create the bug!!)

August 6, 2010, 7:44 AM
Reply
marc esher

Hey Sumit,

It sounds an awful lot like it's related to this bug: http://cfbugs.adobe.com/cfbugreport/flexbugui/cfbugtracker/main.html#bugId=83442

In my experience, using mappedSuperclass works nicely if you're not generating DDL. But the DDL creation is half-baked, IMO.

One can only hope for an updater.

August 6, 2010, 4:35 PM
Reply
Post a Comment
  1. Leave this field empty

Required Field