Skip to main content
Participating Frequently
June 30, 2011
Question

entityNew results in error

  • June 30, 2011
  • 1 reply
  • 415 views

Hi! I started to learn CF9 and wanted to  try the ORM features, but i am getting an error when

calling the entityNew() - methode

So i enabled ORM in my application.cfc by using the line

<cfset this.ormenabled = "true">

then i create the entity cfc in package components/orm/abteilung.cfc, which looks like this:

<cfcomponent persistent="true">
    <cfproperty name="abteilung_id" fieldType="id" generator="native">
    <cfproperty name="bezeichnung" ormtype="string">
    <cfproperty name="abtnr" ormtype="string">
</cfcomponent>

I tried the to get the data using <cfQuery> and it works fine. But when i try to create a new entity

using (ColdfusionBuilder presents me 'abteilung' for selection when i type the command)

<cfset abt = entityNew("abteilung")>

this results in an error.

I already tried to create the entity after setting the path to the cfc folder and defining the dialect

<cfset this.ormsettings.cfclocation = "components/orm/">

<cfset this.ormsettings.dialect = "Informix">

The error appearing is:

onRequest: coldfusion.runtime.EventHandlerException: Event handler exception

and the code calling is as following:

<h1>Print Abteilungen</h1>

<cfquery name="test">
     SELECT * FROM abteilung
</cfquery>

<cfdump var="#test#" >

<cfset a=entityNew("abteilung") >

<cfdump var="#a#" >

Everything works fine until i added the entityNew - call

As i found out on google entityNew does only create an instance of the passed cfc name, and doesn't use the database

or hibernate/Orm methodes... so i have no idea how to solve that.

Can anyone help? Would be much appriciated!

All the best Florian

    This topic has been closed for replies.

    1 reply

    NewFloAuthor
    Participating Frequently
    June 30, 2011

    I get rid of the error, but i don't really know how...

    I started to create a new CF project and made the simplest orm application possible.

    Just setting:

        <cfset this.name = "ormtest">
        <cfset this.dataSource = "b2b">
        <cfset this.ormEnabled=true>

    in Application.cfc

    Using abteilung.cfc from the past example and following index.cfm:

    <h1>Test</h1>
    <cfset fluffy = entityload("abteilung",1)>
    <cfdump var="#fluffy#" >

    It worked on first call...

    Now i tried to find out why the old page wasn't working... but, dada... everything works fine.

    I noticed that my static client pagecount (in the old application) variable was set back.

    I guess that means the server got restarted?

    Do i have to restart CF before first using the orm features?

    mfg florian