"Object passed is not a valid entity" DAO cffunction can't recognize cfargument type of ORM VO
Question about seemingly simple issue that's been confounding me for days. I can't call a function to save a VO (a CFC using CF9 ORM).
Here's my setup
- PersonDAO.cfc -
<cffunction name="getAll" access="remote" returnType="PersonVO[]">
<cfscript>
return entityLoad("PersonVO");
</cfscript>
</cffunction>
<cffunction name="save" access="remote">
<cfargument name="person" type="any" required="true">
<cfscript>
entitySave("person");
</cfscript>
</cffunction>
-PersonVO.cfc-
<cfcomponent alias="com.foo.PersonVO" persistent="true" table="PERSON">
<cfproperty name="pk" fieldtype="id" ormtype="long" column="PERSON_PK">
<cfproperty name="employeeId" column="EMP_ID">
<cfproperty name="userLoginId" column="USR_LOGIN_ID">
</cfcomponent>
When I call getAll() either through another test.cfm file or through Flex 3 remoting, everything works just fine, and a list of strongly-typed objects is returned. I can even manipulate the persistent objects within test.cfm and they automatically save to the DB without issue. This implies that my Application.cfc, ORM settings, datasource settings, and CFCs are configured correctly.
But save does not work! When calling it from test.cfm, I get "Object passed is not a valid entity". When calling from Flex I get a "coldfusion.runtime.CfJspPage$NoSuchTemplateException" saying it couldn't find the object. Why won't this function accept an entity as a parameter? I tried specifying the type, but it can never find that type. Although I can create new ones, and factory.getAllClassMetadata() lists the class I'm trying to reference. What gives?!
-- Likely Related Issue (but I don't care if this one is solved) --
Something funky is going on with my path/package structures. I can only get EntityLoad to work when the DAOs and VOs are all in the same directory, and they're referenced by their class name alone (not package name or alias name).
- So my entity is located at C:/ColdFusion9/wwwroot/MyApp/com/foo/PersonVO.cfc
- In my DAO, returnType="PersonVO" works just fine so long as the DAO is in the same directory as the VO
- The DAO cannot find the object type when it is in another directory
- The DAO cannot find the object type when it is in another directory
- The following return types on the DAO cffunction above don't recognize the object
- com.foo.PersonVO
- MyApp.com.foo.PersonVO
- Even if I created a mapping with a virtualName of "cfcs" and point it at "C:/ColdFusion9/wwwroot/MyApp/com/foo", the following won't work
- cfcs.PersonVO
- MyApp.cfcs.PersonVO
- Every combination of the above, where PersonVO.cfc is in placed in wwwroot, then when PersonVO.cfc is placed in wwwroot/MyApp
I spent almost a week troubleshooting this with no success. This sounds like a crazy question, but does CF9 ORM object support directories?! Non-ORM objects work just fine. I tried altering every possible cfcomponent and Application.cfc property that makes sense, but could not find a way to reference VOs in another directory. Any help? Especially if this is related to the first issue.
