Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I add an array property to a CFC when using ORM?

I'm using Coldfusion ORM (Hibernate), and have a cfc mapped to a database table. Everything works fine, but now I want to add an array property to the CFC that does not exist in the database. What attributes do I need to add to the property so it will not cause ORM errors?

component extends="_base" persistent="true" accessors="true" table="foo" {

    // Primary Key
    property name='fooID' fieldtype='id' column='fooID' generator='native';

    // Properties  
    property name='fooTypeID' ormtype='int'; 
    property name='fooName' ormtype='string'; 

    // Properties that are not database columns or relationships
    property name='fooArray' type='array' <= causes error


    public array function $toString() output="false" {
        var toStringMessage = 'foo = [ 
        fooID: ' & getFooID() & ' 
        fooTypeID: ' & getfooTypeID() & ' 
        fooName: ' & getfooName() & ' 
            fooArray: ' & getfooArray() & ' 
        ]';

        return toStringMessage;
    }

}
like image 204
eterps Avatar asked Aug 10 '26 12:08

eterps


1 Answers

Turn persistent off for the property:

property name='fooArray' type='array' persistent='false';
like image 91
Sam Farmer Avatar answered Aug 12 '26 10:08

Sam Farmer