Weird ColdFusion 9 ORM Error

I'm trying to get a feel for the new ColdFusion 9 ORM setup, and I ran into an error message that I'd not seen before stating that "[Macromedia][SQLServer JDBC Driver][SQLServer]'FK3498A0CE621DF1' is not a constraint." This isn't too daunting, since I'm used to weird SQL errors, but when I refreshed the error I got back "[Macromedia][SQLServer JDBC Driver][SQLServer]Cannot find the object "post" because it does not exist or you do not have permissions." instead.Take a look at the particulars, and see if you can help me out.

The Code

Right now I have an Application.cfc, and two persistent CFCs, User.cfc, and Post.cfc, which look like the following:

Application.cfc
<cfcomponent output="false">
    <cfscript>
        this.ormenabled = true;
        this.datasource = "test";
        
        this.ormsettings.cfclocation = "objects";
        this.ormsettings.dialect = "MicrosoftSQLServer";
        this.ormsettings.dbcreate = "dropcreate";
        this.ormSettings.logSQL = true;
        
     this.developmentServer = true;
    
     if ( this.developmentServer ) {
            this.ormsettings.dbcreate = "dropcreate";
            this.ormsettings.logSQL = true;
     }
    
</cfscript>
    
    <cffunction name="onRequestStart" access="public" hint="Request start processing" returnType="boolean" output="false">
     <cfargument name="targetPage" type="string" hint="The page requested" required="true"/>
    
     <cfif StructKeyExists(URL, "reload")>
     <cfset ApplicationStop() />
    
     <cflocation url="#arguments.targetPage#">
     <cfreturn false />
     </cfif>
    
     <cfif IsDefined("url.logout")>
            <cflogout />
        </cfif>
    
     <cflogin>
            <cfif IsDefined("cflogin")>
                <cfset user = EntityLoad("User", {
                    email        = cflogin.name,
                    password    = Hash(cflogin.password)    
                }, true) /
>

                
                <cfif NOT IsNull(user)>
                    <cfloginuser name="#cflogin.name#" password="#cflogin.password#" roles="admin" />
                </cfif>
            </cfif>
        </cflogin>
    
     <cfreturn true />
    </cffunction>
</cfcomponent>

User.cfc
<cfcomponent hint="User Record" output="false" persistent="true">

    <cfproperty name="userID" hint="The id for the user" type="numeric" fieldtype="id" datatype="integer" generator="identity" />
    <cfproperty name="email" hint="Email address of the user" type="string" length="150" />
    <cfproperty name="password" hint="Hash of the user's password" type="string" length="255" />
    
    <!--- Relationships --->
    <cfproperty name="poast" type="array" fieldtype="one-to-many" cfc="Post" fkcolumn="userID">
    
</cfcomponent>

Post.cfc
<cfcomponent hint="User Record" output="false" persistent="true">

    <cfproperty name="postID" type="numeric" fieldtype="id" datatype="integer" generator="identity" />
    <cfproperty name="content" type="text" />
    <cfproperty name="userID" type="numeric" length="255" />
    <cfproperty name="dateCreated" type="date" />
    
    <!--- Relationships --->
    <cfproperty name="user" fieldtype="many-to-one" fkcolumn="userID" cfc="User" />
    
</cfcomponent>

The Error(s)

So the system should drop and create new tables if the specification is off, and I've tried to define a relationship between posts and users (yes, this is a bit of blog code). The two errors I get are:

Error 1

Error 2

And whats weird is they just seem to alternate (not really random, just alternating). I'm assuming that its something to do with the relationship I defined (worked fine before that), but I'm not really seeing whats wrong. Any one know what to do?

 

Comments

James Brown's Gravatar I'm certainly not an ORM expert, but have you tried not issuing the

this.ormsettings.dbcreate = "dropcreate";

command every request? Maybe try commenting it out and see if your error stops.
Henry Ho's Gravatar my experience told me that if you refresh and see another error message, keep refreshing. Your DB is still building your tables. If there's no error in your metadata, u should eventually refresh and see no error. Sometimes CF might help problem dropping certain table, so you might wanna try dropping all tables yourself and try an ormreload().
Bash's Gravatar <!--- Relationships --->
&lt;cfproperty name="poast" type="array" fieldtype="one-to-many" cfc="Post" fkcolumn="userID"&gt;

Is that a typo in the name attribute?
Jon Hartmann's Gravatar @James: While I could switch it out for "update" my understanding is that "dropcreate" only does the drop & create bit when the ORM setup is reinitialized. Basically, it shouldn't be happening every single request any way.

@Henry: See, I thought about both of those things as well. I tried just refreshing a few times, but I just keep getting the same two messages alternating back and forth. I also tried clearing out the tables in the database, but that didn't seem to help anything.

@Bash: Yeah, you're right that is a typo. It was actually in the code I was running as well, but correcting it to "post" didn't change there resulting error message.
Henry Ho's Gravatar remove the <cfproperty name="userID" type="numeric" length="255" /> in your Post.cfc
Jon Hartmann, July 2011

I'm Jon Hartmann and I'm a Javascript fanatic, UX/UI evangelist and former ColdFusion master. I blog about mysterious error messages, user interface design questions, and all things baffling and irksome about programming for the web.

Learn more about me.

Post a job. Find one. authenticjobs.com

Interested in becoming a sponsor? Contact me.