Weird issue.

11 views
Skip to first unread message

Bill Davidson

unread,
Jun 27, 2011, 9:54:29 PM6/27/11
to cf-or...@googlegroups.com
I am having a really weird problem..... hoping I am missing something stupid.  Here's the ORM CFC:

component persistent="true" table="timeSheetEntries"  schema="dbo" output="false"
{
/* properties */

property name="ID" column="ID" type="numeric" ormtype="int" fieldtype="id"  insert="false" update="false" generator="identity";
property name="inTime" column="inTime" type="date" ormtype="timestamp";
property name="outTime" column="outTime" type="date" ormtype="timestamp";
property name="notes" column="notes" type="string" ormtype="string";

property name="User"  fieldtype="many-to-one" cfc="com.x.common.ORM.entity.user"  fkcolumn="userID";
property name="Client"  fieldtype="many-to-one" cfc="com.x.common.ORM.entity.company"  fkcolumn="clientID";
property name="TaskType"  fieldtype="many-to-one" cfc="timeSheetTaskType"  fkcolumn="taskTypeID";

public function getDuration() {
   return dateDiff('n', getOutTime(), getInTime());
    }

    public function getClientName() {
    return getClient().getName();
    }

public function getTaskType() {
return getTaskType().getName();
}

}

I can instantiate, populate, and save an object, but I cannot load one.  I can't even just instantiate with entityNew() and dump it.   I get nothing. 

I tried removing the many-to-one related object properties, but no difference.   This is the first time I have seen anything like this before so I am totally stumped.

Appreciate any ideas!

-Bill

Bill Davidson

unread,
Jun 27, 2011, 10:07:36 PM6/27/11
to cf-or...@googlegroups.com
Ok - so I tried again after sandboxing this thing for a second time and if I remove the 3 'custom' public functions, it dumps a new entity ok.  I have no idea why that matters.. 

Brian Kotek

unread,
Jun 28, 2011, 2:00:30 AM6/28/11
to cf-or...@googlegroups.com
It looks like the problem is that your associations aren't populated when you create a new instance, so these custom getters have nothing to return. What happens if you add if( variables.client ), etc. to your methods so that in cases where the associations are null they just return empty strings?

--
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.

Marc Esher

unread,
Jun 28, 2011, 6:53:08 AM6/28/11
to cf-or...@googlegroups.com
For what it's worth, I always initialize O2M collections as empty
arrays in an init function.

Bill Davidson

unread,
Jun 28, 2011, 10:11:41 AM6/28/11
to cf-or...@googlegroups.com
Brian - thanks.  I don't understand why this is needed, but it seems to be working for the moment.  Does writeDump/cfdump actually try to invoke all the methods in an object?  So strange....

Also the other problem I was having, was I was trying to the set the User, Client, and TaskType objects directly like setClient(entityLoadByPk('company', 9).  That doesn't seem to work so much... If I put them in a intermediate variable, it seems to work.

Thanks for getting me off in the right direction.

-B

Tony Nelson

unread,
Jun 28, 2011, 1:55:26 PM6/28/11
to cf-orm-dev
FYI, it looks like your getTaskType() method calls itself.

On Jun 28, 9:11 am, Bill Davidson <billdavids...@gmail.com> wrote:
> Brian - thanks.  I don't understand why this is needed, but it seems to be working for the moment.  Does writeDump/cfdump actually try to invoke all the methods in an object?  So strange....
>
> Also the other problem I was having, was I was trying to the set the User, Client, and TaskType objects directly like setClient(entityLoadByPk('company', 9).  That doesn't seem to work so much... If I put them in a intermediate variable, it seems to work.
>
> Thanks for getting me off in the right direction.
>
> -B
>
> On Jun 28, 2011, at 2:00 AM, Brian Kotek wrote:
>
>
>
>
>
>
>
> > It looks like the problem is that your associations aren't populated when you create a new instance, so these custom getters have nothing to return. What happens if you add if( variables.client ), etc. to your methods so that in cases where the associations are null they just return empty strings?
>
> > For more options, visit this group athttp://groups.google.com/group/cf-orm-dev?hl=en.

Bill Davidson

unread,
Jun 28, 2011, 2:13:58 PM6/28/11
to cf-or...@googlegroups.com
Embarrassingly so. I can't believe I didn't see that before, but I picked up on it this morning. Renamed the method getTaskTypeName().

Walking away in shame....

-B

Reply all
Reply to author
Forward
0 new messages