Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6560447
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:27:39+00:00 2026-05-25T13:27:39+00:00

I have three tables, with the following structure: http://dl.dropbox.com/u/2586403/ORMIssues/TableLayout.png The three objects I’m dealing

  • 0

I have three tables, with the following structure:

http://dl.dropbox.com/u/2586403/ORMIssues/TableLayout.png

The three objects I’m dealing with are here:

http://dl.dropbox.com/u/2586403/ORMIssues/Objects.zip

I need to be able to get a PartObject, and then pull all of its Attributes, sorted by the AttributeName in the Types table. Here are the problems I’m running into:

  1. I can’t sort the Attributes property in PartObject by its
    Attribute.AttributeName property

  2. I can’t add the Attribute.AttributeName property to the ObjectAttribute entity because I get an error regarding column names. Hibernate is putting the ID on the wrong side of the join

Here’s the hibernate log file showing the bad query

10/14 16:36:39 [jrpp-12] HIBERNATE DEBUG - select objectattr0_.ID as ID1116_, objectattr0_.AttributeValue as Attribut2_1116_, objectattr0_.AttributeID as Attribut3_1116_, objectattr0_1_.AttributeName as Attribut2_1117_ from ObjectAttributes objectattr0_ inner join Attributes objectattr0_1_ on objectattr0_.ID=objectattr0_1_.AttributeID 
10/14 16:36:39 [jrpp-12] HIBERNATE ERROR - [Macromedia] [SQLServer JDBC Driver][SQLServer]Invalid column name 'AttributeID'. 
10/14 16:36:39 [jrpp-12] HIBERNATE ERROR - [Macromedia] [SQLServer JDBC Driver][SQLServer]Statement(s) could not be prepared. 

Here’s the offending section of the query:

from ObjectAttributes objectattr0_ 
inner join Attributes objectattr0_1_ on objectattr0_.ID=objectattr0_1_.AttributeID 

It should be:

from ObjectAttributes objectattr0_ 
inner join Attributes objectattr0_1_ on objectattr0_.AttributeID=objectattr0_1_.ID 

The AttributeName property on the ObjectAttribute.cfc is the one causing the problem:

component  output="false" persistent="true" table="ObjectAttributes" 
{ 
        property name="ID" column="ID" generator="native" type="numeric" ormtype="int" fieldtype="id" unsavedvalue="0" ; 
        property name="AttributeValue" type="string" ; 
        property name="Attribute" fieldtype="many-to-one" cfc="Attribute" fkcolumn="AttributeID" fetch="join"; 
        property name="AttributeName" table="Attributes" joincolumn="AttributeID" ; 
} 

I’ve also tried using a formula to get the AttributeName on the ObjectAttribute entity, like so:

component  output="false" persistent="true" table="ObjectAttributes"
{
    property name="ID" column="ID" generator="native" type="numeric" ormtype="int" fieldtype="id" unsavedvalue="0" ;
    property name="AttributeValue" type="string" ;
    property name="Attribute" fieldtype="many-to-one" cfc="Attribute" fkcolumn="AttributeID" fetch="join";
    property name="AttributeName" type="string" formula="(SELECT A.AttributeName FROM Attributes A WHERE A.ID = AttributeID)";
}

This works, but I can’t sort by that computed column. If I then adjust PartObject.cfc like so:

property name="Attributes" cfc="ObjectAttribute" type="array" fkcolumn="ObjectID" fieldtype="one-to-many" orderby="AttributeName";

I get the following errors in the hibernatesql log:

10/17 16:51:55 [jrpp-0] HIBERNATE DEBUG - select attributes0_.ObjectID as ObjectID2_, attributes0_.ID as ID2_, attributes0_.ID as ID244_1_, attributes0_.AttributeValue as Attribut2_244_1_, attributes0_.AttributeID as Attribut3_244_1_, ((SELECT A.AttributeName FROM Attributes A WHERE A.ID = attributes0_.AttributeID)) as formula25_1_, attribute1_.ID as ID246_0_, attribute1_.AttributeName as Attribut2_246_0_ from ObjectAttributes attributes0_ left outer join Attributes attribute1_ on attributes0_.AttributeID=attribute1_.ID where attributes0_.ObjectID=? order by attributes0_.AttributeName
10/17 16:51:55 [jrpp-0] HIBERNATE ERROR - [Macromedia][SQLServer JDBC Driver][SQLServer]Invalid column name 'AttributeName'.
10/17 16:51:55 [jrpp-0] HIBERNATE ERROR - [Macromedia][SQLServer JDBC Driver][SQLServer]Statement(s) could not be prepared.

Here’s a dump without that property to show that the rest of the relationships are working properly:

http://dl.dropbox.com/u/2586403/ORMIssues/Dump.pdf

I have no idea how to fix this issue. Any help you can provide would be greatly appreciated.

Thanks,

Dan

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T13:27:40+00:00Added an answer on May 25, 2026 at 1:27 pm

    I solved this one with Sam’s help, by setting up a method in my Service that returned the items in the order I wanted. I just used ORMExecuteQuery to get the items in the right order, and if there were no items, just returned an empty array.

    The final method looked like this, where specifications are set directly in the object in the order I want them:

    /**
    @hint Gets a SpecGroups object based on ID. Pass 0 to retrieve a new empty SpecGroups object
    @ID the numeric ID of the SpecGroups to return
    @roles Admin, User
    */
    remote ORM.SpecGroups function getSpecGroup(required numeric ID){
        if(Arguments.ID EQ 0){
            return New ORM.SpecGroups();
        }else{
            LOCAL.SpecGroup = EntityLoadByPK("SpecGroups", Arguments.ID);
            LOCAL.SpecsInGroup = ORMExecuteQuery("SELECT Spec FROM SpecInGroup G WHERE G.SpecGroupID = :GroupID ORDER BY SpecLabel, SpecName", {GroupID = LOCAL.SpecGroup.getID()});
            LOCAL.SpecGroup.setSpecifications(LOCAL.SpecsInGroup);
            return LOCAL.SpecGroup;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following three tables: alt text http://img16.imageshack.us/img16/5499/linqtosqlquery.jpg With LinqToSql I would like
I have a following tables/classes structure in Linq to entities. Books { bookId, Title
Suppose I have the following three tables expressing a relationship where posts are given
I have two tables Product having following structure: ProductID,ProductName, IsSaleTypeA, IsSaleTypeB, IsSaleTypeC 1, AAA,
I have two mysql tables that have the following structure: Table 1: ---ID---------NAME------- ---1-----
I have the following tables and cannot edit their structure... Person ------ Id PK
I have three tables that have the following relationships between them: Account { public
I have three tables: page, attachment, page-attachment I have data like this: page ID
I have three tables tag , page , pagetag With the data below page
I have three tables in the many-to-many format. I.e, table A, B, and AB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.