I think you're misunderstanding how Transfer works.

The snippet you've posted shows that the first thing you're doing is asking
your Service for a bean with an ID of 0.  I don't know what your Service
layer is doing to grab the bean and return it, but presumably it is asking
Transfer for a Client bean with an ID of 0.  Something like...

<cffunction name="getClient">
    <cfargument name="id" />

     <cfreturn transfer.get("client", arguments.id) />
</cffunction>

If that is essentially what is going on, then I would expect that you would
get a **new** Transfer object - that is, an empty object - back from
Transfer.  If a matching record is not found in the database, Transfer will
return a new object.

The next thing you're doing is populating the bean.  ColdBox's
populateBean() method from the IoC plugin simply populates the bean with
data that is found in the request collection.  It has nothing to do with
Transfer or your database at all.

Run this code:

oClientBean = oService.getClient(0);
getPlugin("beanFactory").populateBean(oClientBean);
t = getPlugin("ioc").getBean("transfer").getTransfer();
if ( NOT oClientBean.getIsPersisted() ) {
    dump("HOLY COW!  IT'S A HOME RUN!");
    abort();
}
t.save(oClientBean);

I'm betting that the code above will result in HOLY COW! IT'S A HOME RUN!
being displayed to your screen.  Why?  Because you asked Transfer for an ID
that does not exist, and you got a *new* object back from Transfer.  You can
populate that object with as much "real" data as you want, but it will
_always_ be a new (unpersisted) TransferObject.

Now then, presumably in your request collection you've got the ID for the
bean you're actually looking for.  If that's the case, note the subtle
differences in the following snippet, and give it a try.

oClientBean = oService.getClient(event.getValue("id", 0));
getPlugin("beanFactory").populateBean(oClientBean);
t = getPlugin("ioc").getBean("transfer").getTransfer();
if ( oClientBean.getIsPersisted() ) {
    dump("YAY!  I'M A REAL BOY!");
    abort();
}
t.save(oClientBean);

HTH

--~--~---------~--~----~------------~-------~--~----~
Before posting questions to the group please read:
http://groups.google.com/group/transfer-dev/web/how-to-ask-support-questions-on-transfer

You received this message because you are subscribed to the Google Groups 
"transfer-dev" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/transfer-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to