below I have a many-to-many relationship. however when I add records
to the linking table via ORM it lets me add duplicated keys when I
should get an error, but I don't!
When creating many-to-many with link-table and no duplicate record
then you have to compose link-table with composite primary key
HERE is simple CFC based solution. Orm will generate a link-table
with composite primary key.
component entityname="UserMonster" persistent="true" accessors="true"
table="monstersCollected"
{
property name="Users"
fieldtype="id,many-to-one"
cfc="User"
cascade="all"
fkcolumn="user_id";
It does, but ORM creates this link table for me from
linktable="monstersCollected" are you saying that I would also create
the entity cfc for link table or that I remove the property from both
these cfcs i.e. users and monsters and create a new cfc linking these
up in your example UserMonster and let that create the relationships
and linktabke.