Apologies for the cross post - wasn't really sure which list this fell
under.
I have two entities, defined as thus:
Parent:
component persistent="true" entityname="ParentEntity"
table="PARENT_TABLE" output="false" {
property name="id" column="PARENT_ID" fieldtype="id"
generator="increment" sqltype="integer" precision="0" ;
property name="name";
property name="children" singularname="child" type="array"
fieldtype="one-to-many" cfc="ChildEntity" inverse="false"
fkcolumn="CHILD_ID";
Child:
component persistent="true" entityname="ChildEntity"
table="CHILD_TABLE" output="false" {
property name="id" column="CHILD_ID" fieldtype="id"
generator="increment" sqltype="integer" ;
property name="parent" fieldtype="many-to-one" fkcolumn="PARENT_ID"
cfc="ParentEntity" sqltype="integer" ;
I have a form in a view which has parent information at the top of the
page and a way to add children below that. I would like to create and
save the children in the same handler that I create and save the
parent.
the snippet of my handler code looks like:
rc.parent = courseparentService.new();
beanFactory.populateBean(rc.parent);
formUtil.buildFormCollections(rc);
parentService.save(rc.parent);
parentService.refresh(rc.parent);
for(var i = 1; i <= rc.numberOfChildren; i++)
{
var child = childService.new();
child.setParent(rc.parent);
beanFactory.populateFromStruct(child,evaluate("rc.child"&i));
rc.parent.addChild(child);
childService.save(child);
}
The error thrown is:
Error Messages: org.hibernate.exception.ConstraintViolationException:
Could not execute JDBC batch update
The beginning of the stack trace is:
coldfusion.runtime.CustomException:
org.hibernate.exception.ConstraintViolationException: Could not
execute JDBC batch update
at coldfusion.tagext.lang.ThrowTag.doStartTag(ThrowTag.java:142)
at coldfusion.runtime.CfJspPage._emptyTcfTag(CfJspPage.java:2722)
at cfBaseORMService2ecfc842935831$funcSAVE.runFunction(F:\workspace
\tracker_bb\wwwroot\coldbox\system\orm\hibernate\BaseORMService.cfc:
669)
I wouldn't have thought this was uncommon..
can anyone point me in the right direction?
Cheers
Steve