• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Reserved word "component"?

Guest
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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?

TOPICS
Advanced techniques

Views

1.2K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 14, 2011 Apr 14, 2011

Copy link to clipboard

Copied

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2011 Apr 15, 2011

Copy link to clipboard

Copied

<!---- 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 --->

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2011 Apr 15, 2011

Copy link to clipboard

Copied

Oh, and of course:

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

<cfdump var="#getSection#">

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 15, 2011 Apr 15, 2011

Copy link to clipboard

Copied

Cheers.

I don't have CF9 where I am currently, and won't be in front of a computer again until Sunday, but will try to look @ it then.

--

Adam

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 15, 2011 Apr 15, 2011

Copy link to clipboard

Copied

Thanks Adam.  I am eager to hear what you experience is!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 18, 2011 Apr 18, 2011

Copy link to clipboard

Copied

LATEST

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!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation