Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Can CF9 ORM use non-root package/directory structures?

New Here ,
Apr 08, 2010 Apr 08, 2010

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

  • My entity is located at C:/ColdFusion9/wwwroot/MyApp/com/foo/PersonVO.cfc
  • In my DAO, returnType="PersonVO" or "PersonVO[]" works just fine so long as the DAO is in the same directory as the VO
    • When having them in the same directory, it can be any directory (not just root).
    • 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 won't work.

    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.

    605
    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    New Here ,
    Apr 08, 2010 Apr 08, 2010

    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")>

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    New Here ,
    Apr 08, 2010 Apr 08, 2010
    LATEST

    I think it's fixed!

    Explanation:

    • Standard CF functions, type declarations, etc all require fully qualified class names and generally don't recognize just class names
    • All ORM functions (without a specified entityName) require that you use ONLY the class name and don't recognize fully-qualified class names


    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

    Translate
    Report
    Community guidelines
    Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
    community guidelines
    Resources