eterps
eterps

Reputation: 14208

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;
    }

}

Upvotes: 3

Views: 370

Answers (1)

Sam Farmer
Sam Farmer

Reputation: 4118

Turn persistent off for the property:

property name='fooArray' type='array' persistent='false';

Upvotes: 7

Related Questions