Copy link to clipboard
Copied
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).
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.
Copy link to clipboard
Copied
This problem was half-solved in another thread (2722116)
Here's the clarification of why the code was breaking on parameter input:
Here's the other half of the problem (and the cause of the 'not a valid entity' error):
Here's the fixed code (with changes bolded😞
- PersonDAO.cfc -
<cffunction name="getAll" access="remote" returnType="com.foo.PersonVO[]">
<cfscript>
return entityLoad("PersonVO");
</cfscript>
</cffunction>
<cffunction name="save" access="remote">
<cfargument name="person" type="com.foo.PersonVO" required="true">
<cfscript>
entitySave(person);
</cfscript>
</cffunction>
Message was edited by: NickMatelli to add the part about there being quotes around the variable name