ColdFusion ORM: coldfusion.orm.PersistentTemplateProxy cannot be cast to java.util.Collection

396 views
Skip to first unread message

Sparky

unread,
Apr 19, 2011, 6:01:35 AM4/19/11
to cf-orm-dev
Having a issue with ORM. I think what I am doing below correct. Forget
the fact I am creating an entity for the join table myself, I know ORM
'can' create this for you.

My issue is as follows....

when saving I get the following error...

**coldfusion.orm.PersistentTemplateProxy cannot be cast to
java.util.Collection**

Take a look at the code below. schedule ---> linktable <---- session

any help is appreciated, thanks.

rc.details = getscheduleService().getByID(ID=rc.scheduleID);
var session = getsessionService().getNewEntity();
var session = getsessionService().getByID(ID=rc.sessionToAddID);
rc.details.setschedulesToSessions(session);
entitySave(rc.details);

schedule


// Persistant Properties
property name="scheduleID" type="string" fieldtype="id"
generator="guid";
property name="scheduleTracks" type="numeric" default=1
persistent=true displayname="Tracks" hint="How Many Tracks does this
schedule have";
property name="scheduleTitle" type="string" default=""
persistent=true displayname="schedule Name" hint="The human name of
the Venue";
property name="scheduleActive" type="boolean" default=true
persistent=true displayname="Active" hint="";
property name="scheduleEditedBy" type="string" default=""
persistent=true displayname="Last Edited By" hint="So we can see who
last edited a record";
property name="scheduleEditedDate" type="date" default=""
persistent=true displayname="Last Edited By Date" hint="So we can see
who last edited a record";
property name="siteID" type="string" default="" persistent=true
displayname="Site ID" hint="Mura Site ID to which the Venue belongs
to";


// Related Object Properties



/* link tables */
property name="schedulesToSessions" fieldtype="many-to-many"
CFC="pEventManager_session" FKColumn="scheduleID"
singularname="sessions"
inversejoincolumn="sessionSID"
linktable="pEventManager_schedulesToSessions";

linktable


// Persistant Properties
property name="scheduleID" fieldtype="id,many-to-one"
cfc="pEventManager_schedule" cascade="all" fkcolumn="scheduleID";
property name="sessionSID" fieldtype="id,many-to-one"
cfc="pEventManager_session" cascade="all" fkcolumn="sessionSID";


sessions



// Persistant Properties
property name="sessionSID" type="string" fieldtype="id"
generator="guid";
property name="sessionTitle" type="string" default=""
persistent=true displayname="Agenda Name" hint="The human name of the
Venue";
property name="sessionStatus" type="string" default=true
persistent=true displayname="Status" hint="";
property name="sessionActive" type="boolean" default=true
persistent=true displayname="Active" hint="";
property name="sessionEditedBy" type="string" default=""
persistent=true displayname="Last Edited By" hint="So we can see who
last edited a record";
property name="sessionEditedDate" type="date" default=""
persistent=true displayname="Last Edited By Date" hint="So we can see
who last edited a record";
property name="siteID" type="string" default="" persistent=true
displayname="Site ID" hint="Mura Site ID to which the Venue belongs
to";


/* link tables */
property name="sessionsToSchedules" fieldtype="many-to-many"
CFC="pEventManager_schedule" FKColumn="sessionSID"
singularname="Schedules"
inversejoincolumn="scheduleID"
linktable="pEventManager_schedulesToSessions";




Marc Esher

unread,
Apr 19, 2011, 6:40:12 AM4/19/11
to cf-or...@googlegroups.com
I believe the problem is that you're setting a single object instance
into that collection property.

the "schedulesToSession" is an array. But you're doing
setSchedulesToSession( object_not_array );

Since your singular name for that property is "sessions", you'd
instead do: addSessions( object )

Marc

> --
> You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
> To post to this group, send email to cf-or...@googlegroups.com.
> To unsubscribe from this group, send email to cf-orm-dev+...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/cf-orm-dev?hl=en.
>
>

Sparky

unread,
Apr 19, 2011, 6:58:50 AM4/19/11
to cf-orm-dev
Hi Marc Esher,

Yes, before you posted this I realised that was the issue. I dumped
out all the methods and found addsessions() dow!!!!!

Thanks, and well spotted. :)
Reply all
Reply to author
Forward
0 new messages