Copy link to clipboard
Copied
Hi all,
I can't seem to make any persistent entity CFCs recognize others in different directories or pacakge structures. Even virtual mappings don't seem to do the trick. I posted part of this question yesterday (thread 2719488), althought the central focus there was was on parameter passing problems (which I'm hoping are independent!).
Looking through all the official documentation along with various online blog examples, I couldn't find a single one where non-root directory structures were used. This sounds like a crazy question, but do CF9 ORM objects support directories?!
Here's the short version of my setup and the various things I've tried to resolve it:
- PersonDAO.cfc -
<cffunction name="getAll" access="remote" returnType="PersonVO[]">
<cfscript>
return entityLoad("PersonVO");
</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>
I can only get EntityLoad to work when the DAO and VOs are in the same directory, and they're referenced by their class name alone (not package name or alias name).
Non-ORM objects have been working just fine, so I don't think it's confuguration. 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? I've tried this on a local CF server and on a QA server that's being well-used and has no known configuration issues.
Copy link to clipboard
Copied
Some follow up on the strangeness between instantiating components using ORM and not using ORM. createObject seems to require absolute class name, entityLoad seems to require that you don't use it. Are these results typical?
<!--- Works --->
<cfset bar = entityLoad("PersonVO", {employeeId=1}), true>
<!--- Doesnt Work: "Mapping for component com.foo.PersonVO not found" --->
<cfset bar = entityLoad("com.foo.PersonVO", {employeeId=1}, true)>
<!--- Doesnt Work: "Could not find the ColdFusion component or interface PersonVO" --->
<cfset baz = createObject("component", "PersonVO")>
<!--- Works --->
<cfset baz = createObject("component", "com.foo.PersonVO")>
Copy link to clipboard
Copied
I think it's fixed!
Explanation:
Fixed code:
- 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>
More on the entityName property available in the CF docs. Further descriptions available in another thread from Mark Mandel
http://groups.google.com/group/cf-orm-dev/browse_thread/thread/3aab5291b1cd6104
Follow-up edits in added in italics 4/13