In several data structures with my application I have an attribute named “IsPrimary”. One issue I am having is that with for each User they can only have 1 primary address but have multiple address. What I am trying to figure out is with in cf9’s implementation of hibernate how can I update any existing record that has the attribute IsPrimary as true to false if a new record or updated record is saved with IsPrimary being true.
This is my existing save method
public UserAddress function save(required UserAddress)
{
var userAcc = entityLoadByPK('UserAccount', arguments.UserAddress.getUserID());
arguments.UserAddress.setUserID(userAcc);
entitySave(arguments.UserAddress);
return arguments.UserAddress;
}
you may do it at
preInsert()if you like.