ORM relationships Link Tables

I have 2 tables. User and Company.

     /* link tables */
     property name="comp" fieldtype="many-to-many" CFC="user"
linktable="user2company" FKColumn="com_id"
     inversejoincolumn="user_id" lazy="true" cascade="all"
orderby="user_id";

on ORM reload a new table in my database appears now called
"user2company". which is cool and correct. however I now want to
search this link table, but as it does not have a cfc of its own i
dont see how its possible so the follow error is shown

A CFC with entityname user2Company could not be found.

this is correct as user2Company link table does not have its own cfc.

my question is how to you search link tables in CB when link tables
dont have there own cfc?

You have to use the service’s query executions via HQL in order to query it since there are no CFCs for you to load on the m2m tables. Have you done any HQL via the executeQuery() method or some other query taking methods on the service layer.

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks for the quick responses. You must be a busy guy so taking the
time to answer questions is really appreciated

quote: You have to use the service's query executions via HQL

nope not yet, new to hibernate all together.

so I now get to use my service, cool so far CB and hibernate has done
everything. I will now lookup executeQuery(). so just like a normal
join, anything I should know about it in CB?

Not really, the CB service layer just abstracts a little the intricacies of Hibernate but is not without you understanding what goes on behind the scenes. I suggest reading some of this: http://docs.jboss.org/hibernate/core/3.3/reference/en/html/queryhql.html

It will really help you out. But apart from that the CB’s service layers really try to do as much as they can, the rest is up to you!

Luis F. Majano
President
Ortus Solutions, Corp

ColdBox Platform: http://www.coldbox.org
Linked In: http://www.linkedin.com/pub/3/731/483
Blog: http://www.luismajano.com
IECFUG Manager: http://www.iecfug.com

Thanks for the link and info, thats my Sunday reading sorted :slight_smile: