I'm trying to use entitySave() and am finding a weird behavior. My parent object links to the child object as such:
<cfproperty name="focusareas" singularname="focusarea"
fieldtype="one-to-many" type="array" cfc="FocusArea"
fkcolumn="parentid" cascade="delete" />
When I save the parent, I am using an Ajax call and the service proxy uses an entityNew() to create the child, sets its id and other variables and then calls entitySave().
var parent = entityLoadByPK('Parent', arguments.id);
The logical behavior is that entitySave() determines if the record should be inserted or updated. What happens is pretty strange though. Check out the Hibernate log:
The wackiness is that entitySave() does indeed perform an update as opposed to an insert as expected, but then disconnects itself from the child record. If I instead do an entityLoadByPK() and then set all values, everything works as expected. The issue with this is I should not have to check and see if the parent is new and perform an entityNew() or entityLoadByPK() explicitly. This is what ORM does for you. Bug? Thoughts?
First it would be good for others to know there is a google discussion group for this. http://groups.google.com/group/cf-orm-devReplyDelete
I am just skimming my feeds quick before meeting but repost there and will try to get an answer if you don't get one here.