model mappings + ORM = cant find the entity

ORM settings:

this.ormEnabled = true;
this.datasource = "MYDSN";
this.ormSettings = {useDBForMapping = true,dialect =
"MicrosoftSQLServer", logSQL = true};

entity:

component accessors=true table="mytest" entityname="test"
persistent=true{
  property name="ID" fieldtype="id" generator="identity" setter=false;

  public test function init(){return this;}
}

entity service:

component singleton=true accessors=true
extends="coldbox_3_1.system.orm.hibernate.VirtualEntityService"{
  public testservice function init()
{super.init(entityName="test");return this;}
}

model mapping:

addModelMapping(alias="testService",path="test.testService");

my tests:

<cfdump var="#getModel("testService")#"> = dumps the VES w/ all the
methods. can return queries. all looks good.

<cfdump var="#new model.test.Test()#"> = dumps the entity. all looks
good.

<cfdump var="#getModel("testService").new()#"> = gives the error
"Could not find the ColdFusion component or interface Test. Ensure
that the name is correct and that the component or interface exists."

it seems that hibernate cant find the entity cause its using a short
name? although, hibernate seems to know where the entity lives
because it does create the table "mytest".

Are you on Mac

I am on windows 7 pro, iis 7.5, cf 9.01.

I installed the application using the Coldbox Tools for CF Builder. I
used the Advanced application type install.

coldbox.cfc:

<cfcomponent output="false" hint="My App Configuration">
  <cfscript>
    // Configure ColdBox Application
    function configure(){
      coldbox = {
        appName = "test",
        eventName = "event",

        debugMode = true,
        handlersIndexAutoReload = true,
        configAutoReload = false,

        defaultEvent = "General.index",
        requestStartHandler = "Main.onRequestStart",
        applicationStartHandler = "Main.onAppInit",

        handlerCaching = false,
        eventCaching = false,
        proxyReturnCollection = false,
        flashURLPersistScope = "session"
      };
    }
  </cfscript>
</cfcomponent>

application.cfc:

<cfcomponent extends="coldbox.system.Coldbox" output="false">
  <cfsetting enablecfoutputonly="yes">

  <cfscript>
    this.name = "test" & hash(getCurrentTemplatePath());
    this.sessionManagement = true;
    this.sessionTimeout = createTimeSpan(0,0,45,0);
    this.setClientCookies = true;

    COLDBOX_APP_ROOT_PATH =
getDirectoryFromPath(getCurrentTemplatePath());

    this.ormEnabled = true;
    this.datasource = "MYDSN";

    this.ormSettings = {
      useDBForMapping = true,
      dialect = "MicrosoftSQLServer",
      logSQL = true
    };
  </cfscript>

  <!--- on Request Start --->
  <cffunction name="onRequestStart" returnType="boolean" output="true">
    <!--- *************************************************************
--->
    <cfargument name="targetPage" type="string" required="true" />
    <!--- *************************************************************
--->

    <!--- Process A ColdBox Request Only --->
    <cfif findNoCase('index.cfm', listLast(arguments.targetPage, '/'))>
      <!--- Reload Checks --->
      <cfset reloadChecks()>
      <!--- Process Request --->
      <cfset processColdBoxRequest()>
    </cfif>

    <!--- WHATEVER YOU WANT BELOW --->
    <cfreturn true>
  </cffunction>

</cfcomponent>

I had the same on about the same system just the other day…

added in Application.cfc:
this.mappings["/"] = COLDBOX_APP_ROOT_PATH;

And things are working now. Used to be MAC only issue… I hope that works for you

Cheers,
Tom

Tom... thanks! your fix works.

Yes, I do that on all myu ORM projects now that are not on the root.

Luis F. Majano
President
Ortus Solutions, Corp
www.ortussolutions.com

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Social: twitter.com/lmajano facebook.com/lmajano

good to know.