Okay, so here’s my entity definitions (paired down to the relevant) to help with the story…
component entityname=“Product” table=“products” persistent=“true” {
property name=“id” column=“id” fieldtype=“id” generator=“assigned” length=“35” notnull=“true”;
property name=“name” column=“name” ormtype=“string” length=“255” notnull=“true”;
// one Product can belong to many Product2Category
property name=“product2categories”
fieldtype=“one-to-many”
cfc=“Product2Category”
fkcolumn=“productID”
type=“array”
singularname=“product2category”";
public function init() {
variables.id = createUUID();
variables.name = “”;
return this;
}
}
component entityname=“Product2Category” table=“product2categories” persistent=“true” {
property name=“id” column=“id” fieldtype=“id” generator=“assigned” length=“35”;
// many Product2Categories have one Product
property name=“product” fieldtype=“many-to-one” cfc=“Product” fkcolumn=“productID”;
// many Product2Categories have one Category
property name=“category” fieldtype=“many-to-one” cfc=“Category” fkcolumn=“categoryID”;
public function init() {
variables.id = createUUID();
return this;
}
}
component entityname=“Category” table=“categories” persistent=“true” {
property name=“id” column=“id” fieldtype=“id” generator=“assigned” length=“35” notnull=“true”;
property name=“name” column=“name” ormtype=“string” length=“255” notnull=“true”;
// one Category can belong to many Product2Category (uni-directional)
property name=“product2Categories”
fieldtype=“one-to-many”
cfc=“Product2Category”
fkcolumn=“categoryID”
type=“array”
singularname=“product2Category”;
public function init() {
variables.id = createUUID();
variables.name = “”;
return this;
}
}
HTH