[ColdBox 4.0.0-be] Module onload fills database with dummy record

I’m trying to create a module in ColdBox 4.0.0. In my module I have an orm that I’m trying to fill with dummy record onload.

my module has this config:

// Module Entry Point
this.entryPoint = “security”;
// Model Namespace
this.modelNamespace = “security”;
// CF Mapping
this.cfmapping = “security”;
// AutoMap
this.autoMapModels = true;

Then in my Onload

public void function onLoad(){
var setupPath = getDirectoryFromPath(getCurrentTemplatePath()) & “config\setup.xml”;
var installService = binder.getInjector().getInstance(“Install@security”);

// if a file named setup.xml exists in the config folder lets install some default data
if( fileExists(setupPath) ){

In my install.cfc I have this:

property name=“userService” inject=“userService@security”;

public void function setup(){
var f = fileRead(getConfigPath());

try {
setConfigXML( xmlParse(f) );
} catch(any e){
log.error(“There was an error parsing the xml config file.”);

// we only want to add this data if there are no records
// this is only to add some dummy data to the database
if( userService.count() == 0 ){ //THIS ROW GENERATE ERRROR


I got this error:

User is not mapped [select count(*) from User]
Cause org.hibernate.hql.ast.QuerySyntaxException

User is not mapped would indicate that the path is not in the cfclocation.

I think this is probably because the table user is not created when install try to check if there are record in that table.

Is User a reserved word in hibernate? Try either changing your table name or putting it in brackets [User]

Just an early morning guess.


Which means the path is not in the cfclocation sigh

I think User is not reserved word.

I think the path is in the cfclocation because if I dump Install@security

Component (security.models.install.Install)
Only the functions and data members that are accessible from your location are displayed

Component security.models.users.UserService

Component coldbox.system.logging.Logger



If I add

this.mappings[ “/area51” ] = COLDBOX_APP_ROOT_PATH & “modules/area51”;

in my application.cfc it works. So I think probably it’s the way the automapmodels works.

Yeah I think that is the case, I haven’t looked at CB4.0 as yet, so I am going to assume that what you say is correct.

What about that object dump makes you think that the ORM entity is in the CFCLocation? CFCLocation is part of the ORM settings that are defined in your Application.cfc in the root of your site.

> From my understanding autoMapModels automap all orm without using mappings.

No, the autoMapModels flag has nothing to do with ORM. It simply means that WireBox maps all the models in your module’s /models folder as “CFCName@ModuleName”. You can customize the “ModuleName” portion of that with the “this.modelNamespace” setting.

This is documented here in our What’s New guide for ColdBox 4.0

As for your issue, make sure this.ormSettings.CFCLocation includes the directory (or parent directory) where your ORM entity lives. Also, you may need to do an ORMReload when the module is installed to pick up new entities.

Also, note that ColdBox 4 is capable of adding app-specific ColdFusion mappings automatically that point to the root of your module. However, you probably can’t rely on those in your CFCLocation since they don’t get added until ColdBox starts processing each request so they don’t exist yet when Application.cfc is looking for ORM entities on startup.



ColdBox Platform Evangelist
Ortus Solutions, Corp

E-mail: brad@coldbox.org
ColdBox Platform: http://www.coldbox.org
Blog: http://www.codersrevolution.com

As for your issue, make sure this.ormSettings.CFCLocation includes the directory (or parent directory) where your ORM entity lives

So I should also add

cfclocation = [“models.orm”,"/area51/models"],


I have misunderstood the automapmodels functionality.

However also by simply adding

this.mappings[ “/area51” ] = COLDBOX_APP_ROOT_PATH & “modules/area51”;

all works great.

I think this is the point: