ColdFusion 9 ORM : newbie error - component not found

I'm tinkering with a little project and having moved my blog to HostmediaUK I've decided to have more of a play with ColdFusion 9 features.

I've looked at ColdFusion 9's ORM stuff a couple of times, but I've never actually used it properly, so I thought I'd write the database access functionality using ORM.

  1. Create a couple of CFCs for my datatypes.
  2. Tell the Application CFC that the application is ORMEnabled.
  3. Tell ColdFusion to generate my database tables
  4. Add some data
  5. Save my object

Job done... ummm no.

"Error Occurred While Processing Request Could not find the ColdFusion component or interface user"

In Application.cfc I have :

view plain print about
1this.ormsettings.cfclocation = "/com/nil/orm";
2        this.ormsettings.dialect = "MySQLwithMyISAM";
3        this.ormsettings.logSQL = true;
4        this.ormsettings.dbcreate ="dropcreate";

In my application page I have :

view plain print about
2    user = new user();
3    user.setUser_ID(session.user_id);
4    user.setName(;
5    EntitySave(user);

Why can't I find my "user" component? I changed my code to user = EntityLoad("user"). Now I'm getting method not found.

I go through a bunch of iterations based around this and even get a "Mapping for component user not found" error before I start to talk through my rubbish code with John Whish.

There were two things I was doing wrong.

The first thing is that I should be using EntityNew() not EntityLoad(). I've got so used to Transfer-ORM and just getting a data object ie. Loading it whether I want a new or an existing data record.

Secondly, the reason why user = new user(); doesn't work is because its looking for my component in the root path. My user cfc actually lives in /com/nil/orm as I specified in my Application.cfc.

The entity functions such as EntityNew() and EntityLoad() work using simple names because Hibernate basically creates a "bean factory" of the data components. When I do EntityNew("user") it looks in the pot for a component of the same name and uses that.

If I want to use the "new user()" style of instantiation I have to give the full path to the component.

view plain print about
1user = new com.nil.orm.user();

Its a silly error that I'm entirely embarrassed about making, but its important distinction that might be missed when you first start out playing with ColdFusion's ORM features.

By the way, the "Mapping for component not found" error was caused by moving the user.cfc to the root of my application and then calling EntityLoad("user"). Hibernate was looking in my cfc location and couldn't find the "user" component.