Skip to main content
April 14, 2011
Question

Reserved word "component"?

  • April 14, 2011
  • 5 replies
  • 1351 views

Hey everyone.

Running CF 9.0.1 on Win7.  I'm trying to get CF ORM to work, doing pretty well so far.  I have a problem that I am hoping is not a showstopper.

My client has an MSSQL database and one of the tables in their OO structure is named "component", and has a many-to-many relationship with two other tables.  When I try to define the relationship between this other table and "component":

<cfproperty name="components" type="array" fieldtype="many-to-many" cfc="component" linktable="xref"  fkcolumn="other_table" inversejoincolumn="component" />

This is throwing an error:

CFC component could not be initialized.

Check if the persistent attribute in component is set to "true".
ColdFusion cannot determine the line of the template that caused this error. This is often caused by an error in the exception handling subsystem.

When I comment out this cfproperty line, all the links work fine (except the one that the statement defines).  I'm thinking that "component" is a reserved word in this context.  The problem is, that is what the table and linktable fields are named, and I can't change it.

My question is: Am I screwed, or is there some sort of workaround I can do here?

This topic has been closed for replies.

5 replies

April 18, 2011

I was able to work around it today by defining the table name in a CFC that is not named the same as the table.

<!--- OtherComponent.cfc --->

<cfcomponent table="component" ...>

  ...

</cfcomponent>

<!--- Section.cfc --->

....

<cfproperty name="components" type="array" fieldtype="many-to-many" cfc="page" linktable="sectionxref"  fkcolumn="section" inversejoincolumn="component" >

Thank you to those of you who tried to help with this problem!  It is appreciated!

Inspiring
April 14, 2011

I'm thinking that "component" is a reserved word in this context.

Whatever it is, it's not that. I was able to create a component

Component.cfc, and create a one-to-many property in a

ComponentCollection.cfc which created.... well... a collection of Component

objects. Works fine.

CF's reporting of errors with the Hibernate subsystem is pretty rubbish, so

the errors you get can be misleading.

It'd be helpful if you posted a coupla CFCs and some calling code which

demonstrate your problem.

--

Adam

April 15, 2011

<!---- section.cfc - Section object, contains 1 to n Components ---->

<cfcomponent persistent="true" table="section"  schema="dbo" output="false">

<cfproperty name="id" column="id" type="numeric" ormtype="int" fieldtype="id"  />

<!--- other cfproperties --->
<!--- Client has a table sectionComponent where contains fields named "section" and "component" and defines the many-to-many relationship --->
<!--- When I comment this next line out, the ORM generates no error --->
<cfproperty name="components" type="array" fieldtype="many-to-many" cfc="component" linktable="sectionComponent"  fkcolumn="section" inversejoincolumn="component" >
</cfcomponent>
<!---- End Section.cfc ---->
<!---- component.cfc - Component object, may be contained by 1 to n Sections --->
<cfcomponent persistent="true" table="component"  schema="dbo" output="false">
<cfproperty name="id" column="id" type="numeric" ormtype="int" fieldtype="id"  />
<!--- other cfproperties --->
</cfcomponent>
<!--- End Component.cfc --->

April 15, 2011

Oh, and of course:

<cfset getSection = EntityLoad('Section',4, true)>

<cfdump var="#getSection#">

April 14, 2011

Thank you both for your responses.

Owen: I have a hard time believing that the folks who created CF ORM didn't think about how to allow users to use reserved words.  That sucks.

EditCorp: I actually did.  It is Hibernate that is throwing the exception, not SQL.  Good suggestion tho.

Anyone else have any ideas?

Owainnorth
Inspiring
April 14, 2011

mw_scitent wrote:

I have a hard time believing that the folks who created CF ORM didn't think about how to allow users to use reserved words.

Why so? Every language has words you can't use, that's what makes them reserved

April 14, 2011

Lulz.  Two phrases: "Escape characters" and "Regular Expressions"

Inspiring
April 14, 2011

MSSQL accepts named enclosed within square brackets, so you might try that.  Ex. [component]

Owainnorth
Inspiring
April 14, 2011

Almost certainly it's reserved, and almost certainly there's no CF-based workaround.

The only thing I can think is to create a view, which is simply a "select * from components" but with a different name, then work from that.