ORM EXPERTS: How to insert a record into a linking table
I have table called TrainingArchives and a table called TrainingCategories. They are both modeled in ORM and both have a FK property referencing a linking table.
This is the assignedCategory property in TrainingArchive.cfc (ORM object):
property name="assignedCategory" type="array" displayname="assignedCategory" hint="This is the assigned categories for the training archive."
fieldtype="many-to-many" linktable="trainingArchiveCategory" FKColumn="trainingArchiveID" inversejoincolumn="trainingCategoryID" cfc="TrainingCategory"
orderby="trainingCategoryID";
This is the assignedTrainingArchive property in TraningCategory.cfc (ORM object)
property name="assignedTrainingArchive" type="array" displayname="assignedTrainingArchive" hint="This is the assigned training archives for the topic."
fieldtype="many-to-many" linktable="trainingArchiveCategory" FKColumn="trainingCategoryID" inversejoincolumn="trainingArchiveID" cfc="TrainingArchive"
orderby="trainingArchiveID";
If I prepopulate the linking table with data, I am able to use ORM and Hibernate to get the data from the linking table. However, I don't know how to INSERT a record into the linking table using ORM. So, I have a form where a user can enter data to create a training archive record, one of the fields is a select element where the user can select multiple categories. When the user hits the 'Save' button, I can easily save the data by using the built-in set methods on the other properties of the training archive object. But I don't know how to get the data into the assignedCategory property. I've tried just passing in the selected values as an array but that doesn't work as in setAssignedCategory(myArray).
I'd be happy to provide more info if necessary but I think you get the gist of what I'm asking.
Thanks!
