Use these 2 persistent CFCs for example:
// Cat.cfc
component persistent="true" {
property name="id" fieldtype="id" generator="native";
property name="name";
}
// Owner.cfc
component persistent="true" {
property name="id" fieldtype="id" generator="native";
property name="cats" type="array" fieldtype="one-to-many" cfc="cat" cascade="all";
}
When one-to-many (unidirectional) Note: inverse=true on unidirectional will yield undesired result:
insert into cat (name) values (?)
insert into Owner default values
update cat set Owner_id=? where id=?
When one-to-many/many-to-one (bi-directional, inverse=true on Owner.cats):
insert into Owner default values
insert into cat (name, ownerId) values (?, ?)
Does that mean setting up bi-directional o2m/m2o relationship is preferred 'cause the SQL for inserting the entities is more efficient?