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!