11 Replies Latest reply on Apr 18, 2011 9:44 AM by mw_scitent

    Reserved word "component"?

    mw_scitent

      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?

        • 1. Re: Reserved word "component"?
          Owain North Level 4

          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.

          • 2. Re: Reserved word "component"?
            editcorp

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

            • 3. Re: Reserved word "component"?
              mw_scitent Level 1

              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?

              • 4. Re: Reserved word "component"?
                Owain North Level 4

                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

                • 5. Re: Reserved word "component"?
                  mw_scitent Level 1

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

                  • 6. Re: Reserved word "component"?
                    Adam Cameron. Level 5

                    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

                    • 7. Re: Reserved word "component"?
                      mw_scitent Level 1

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

                      • 8. Re: Reserved word "component"?
                        mw_scitent Level 1

                        Oh, and of course:

                         

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

                        <cfdump var="#getSection#">

                        • 9. Re: Reserved word "component"?
                          Adam Cameron. Level 5

                          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

                          • 10. Re: Reserved word "component"?
                            mw_scitent Level 1

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

                            • 11. Re: Reserved word "component"?
                              mw_scitent Level 1

                              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!