Hi Guys,
I'm trying to save an object (application) with a child object (appAfterMarketOption) through setting cascade="save-update"
I'm getting an error because when it tries to save the child object (after the parent has been saved), it's not updating the foreign key to the parent within the object.
org.springframework.dao.DataIntegrityViolationException: Hibernate operation: could not insert: [com.lp.ebus.common.pojo.AppAfterMarketOption]; SQL [insert into APP_AFTER_MARKET_OPTION (OPTION_NAME, OPTION_COST, OPTION_FITMENT_DATE, APPLICATION_ID, APP_AFTER_MARKET_OPTION_ID) values (?, ?, ?, ?, default)]; Assignment of a NULL value to a NOT NULL column "TBSPACEID=2, TABLEID=3, COLNO=4" is not allowed.; nested exception is com.ibm.db2.jcc.b.SQLException: TBSPACEID=2, TABLEID=3, COLNO=4
at org.springframework.jdbc.support.SQLStateSQLExceptionTranslator.translate(SQLStateSQLExceptionTranslator.java:91)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.translate(SQLErrorCodeSQLExceptionTranslator.java:257)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.springframework.orm.hibernate3.HibernateAccessor.convertJdbcAccessException(HibernateAccessor.java:424)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.springframework.orm.hibernate3.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:411)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.springframework.orm.hibernate3.HibernateTemplate.execute(HibernateTemplate.java:361)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.springframework.orm.hibernate3.HibernateTemplate.save(HibernateTemplate.java:593)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.lp.ebus.common.host.dao.hibernate.ApplicationDAOHibernate.create(ApplicationDAOHibernate.java:105)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.lp.ebus.common.service.ApplicationManager.create(ApplicationManager.java:84)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.lp.ebus.nla.web.action.PrintAndAcceptanceAction.execute(PrintAndAcceptanceAction.java:61)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.ibm.wps.portlets.struts.WpsRequestProcessor.processActionPerform(WpsRequestProcessor.java:251)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.ibm.wps.portlets.struts.WpsStrutsPortlet.processActionPerformed(WpsStrutsPortlet.java:1536)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.ibm.wps.portlets.struts.WpsStrutsPortlet.actionPerformed(WpsStrutsPortlet.java:1254)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at com.ibm.wps.pe.pc.legacy.SPIPortletInterceptorImpl.handleEvents(SPIPortletInterceptorImpl.java:438)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.apache.jetspeed.portlet.Portlet._dispatch(Portlet.java:794)
[28/02/06 14:15:38:906 EST] 82beed4 SystemErr R at org.apache.jetspeed.portlet.Portlet.access$100(Portlet.java:88)
the field it's refering to is ApplicationId with in AppAfterMarketOption table.
i've played around with my mapping files a bit but can't see anything wrong.
within Application.hbm.xml
<!-- bi-directional one-to-many association to AppAfterMarketOption -->
<set
name="appAfterMarketOptions"
lazy="true"
inverse="true"
cascade="save-update"
>
<key>
<column name="APPLICATION_ID" />
</key>
<one-to-many
class="com.lp.ebus.common.pojo.AppAfterMarketOption"
/>
</set>
within AppAfterMarketOption.hbm.xml
<!-- bi-directional many-to-one association to Application -->
<many-to-one
name="application"
class="com.lp.ebus.common.pojo.Application"
not-null="true"
>
<column name="APPLICATION_ID" />
</many-to-one>
Any help would be greatly appreciated.... i'm completely stuck on this.
Thanks
David
|