Read the rules before posting!
http://www.hibernate.org/ForumMailingli ... AskForHelp
Hibernate version: 2.1.2
Mapping documents: <?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 2.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd" >
<hibernate-mapping>
<!--
Created by the Middlegen Hibernate plugin 2.1
http://boss.bekk.no/boss/middlegen/
http://www.hibernate.org/
-->
<class
name="com.mcm.sw.model.ReportCalculation"
table="REPORT_CALCULATIONS"
>
<meta attribute="class-description" inherit="false">
@hibernate.class
table="REPORT_CALCULATIONS"
</meta>
<id
name="ReportCalculationId"
type="java.lang.Long"
column="REPORT_CALCULATION_ID"
>
<meta attribute="field-description">
@hibernate.id
generator-class="sequence"
type="java.lang.Long"
column="REPORT_CALCULATION_ID"
@hibernate.generator-param
name="sequence"
value="REPORT_CALCULATION_SEQ"
</meta>
<generator class="sequence">
<param name="sequence">REPORT_CALCULATION_SEQ</param>
</generator>
</id>
<property
name="CreatedBy"
type="java.lang.String"
column="CREATED_BY"
length="32"
>
<meta attribute="field-description">
@hibernate.property
column="CREATED_BY"
length="32"
</meta>
</property>
<property
name="CreateDate"
type="java.sql.Timestamp"
column="CREATE_DATE"
length="7"
>
<meta attribute="field-description">
@hibernate.property
column="CREATE_DATE"
length="7"
</meta>
</property>
<property
name="AccountNumber"
type="java.lang.String"
column="ACCOUNT_NUMBER"
not-null="true"
length="10"
>
<meta attribute="field-description">
@hibernate.property
column="ACCOUNT_NUMBER"
length="10"
not-null="true"
</meta>
</property>
<property
name="Status"
type="java.lang.String"
column="STATUS"
not-null="true"
length="1"
>
<meta attribute="field-description">
@hibernate.property
column="STATUS"
length="1"
not-null="true"
</meta>
</property>
<!-- Associations -->
<!-- bi-directional one-to-many association to ReportVariableInstances -->
<set
name="ReportVariableInstances"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="REPORT_CALCULATION_ID"
@hibernate.collection-one-to-many
class="com.mcm.sw.model.ReportVariableInstance"
</meta>
<key>
<column name="REPORT_CALCULATION_ID" />
</key>
<one-to-many
class="com.mcm.sw.model.ReportVariableInstance"
/>
</set>
<!-- bi-directional one-to-many association to ReportCalcMessage -->
<set
name="ReportCalcMessages"
lazy="true"
inverse="true"
cascade="none"
>
<meta attribute="field-description">
@hibernate.set
lazy="true"
inverse="true"
cascade="none"
@hibernate.collection-key
column="REPORT_CALCULATION_ID"
@hibernate.collection-one-to-many
class="com.mcm.sw.model.ReportCalcMessage"
</meta>
<key>
<column name="REPORT_CALCULATION_ID" />
</key>
<one-to-many
class="com.mcm.sw.model.ReportCalcMessage"
/>
</set>
</class>
</hibernate-mapping>
Code between sessionFactory.openSession() and session.close():
public int saveReportCalculationGraph(ReportCalculation reportCalculation,
Goal[] goals,
HashMap intermediaryValMap)throws DataAccessException{
if(log.isDebugEnabled())
log.debug("Method"+this+"SmartwatchDAOImpl.saveReportCalculationGraph(ReportCalculation,Goal[],Map)"+
"entered with ReportCalculation = "+reportCalculation.toString());
Session session = null;
Transaction t = null;
try {
session = HibernateUtil.currentSession();
t = session.beginTransaction();
//Make a Save call to get the Key
Long reportCalculationId = (Long)session.save(reportCalculation);
reportCalculation.setReportCalculationId(reportCalculationId);
//Get the associations
Set reportCalcMessages = extractReportCalcMessages(reportCalculation, goals, session);
if(null!=reportCalcMessages)
reportCalculation.setReportCalcMessages(reportCalcMessages);
Set reportVariableInstances = extractReportVariableInstances(reportCalculation,intermediaryValMap,session);
if(null!=reportVariableInstances)
reportCalculation.setReportVariableInstances(reportVariableInstances);
t.commit();
return 0;
} catch (Exception ex) {
log.error(this+"Exception thrown during SmartWatchDAOImpl" +
": method saveReportCalculation(ReportCalculation reportCalculation): and param passed:swCalculation: "+ reportCalculation,ex);
try{
t.rollback();
}catch(HibernateException e){
log.fatal("Fatal Error in rolling back session, would leave inconsistent data in DB for reportCalculation accountnumber:"
+reportCalculation.getAccountNumber());
throw new HibernateDataAccessException(getErrorMessage(ErrorMessageEnum.BATCH_DATA_SAVE_ACCESS_ERROR.getName()),
ex,HibernateDataAccessException.BATCH_DATA_SAVE_ACCESS_ERROR);
}
throw new HibernateDataAccessException(getErrorMessage(ErrorMessageEnum.BATCH_DATA_SAVE_ACCESS_ERROR.getName()),
ex,HibernateDataAccessException.BATCH_DATA_SAVE_ACCESS_ERROR);
}finally{
try{
HibernateUtil.closeSession();
}catch(HibernateException ex){
log.error("Error in closing Session",ex);
throw new HibernateDataAccessException(getErrorMessage(ErrorMessageEnum.HIBERNATE_OPEN_CLOSE_ERROR.getName()),
ex,HibernateDataAccessException.HIBERNATE_OPEN_CLOSE_ERROR);
}
}
}
Full stack trace of any exception that occurs:[ERROR ] com.mcm.sw.hibernate.dao.SmartWatchDAOImpl.saveReportCalculationGraph: Error in closing Session - 03/17/05 10:16:29|642(3251727440)
net.sf.hibernate.JDBCException: could not insert: [com.mcm.sw.model.ReportCalculation#172569]
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:478)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:442)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:29)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2407)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2360)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2229)
at com.mcm.sw.hibernate.HibernateUtil.closeSession(HibernateUtil.java:79)
at com.mcm.sw.hibernate.dao.SmartWatchDAOImpl.saveReportCalculationGraph(SmartWatchDAOImpl.java:346)
at com.mcm.sw.interfaceimpl.RulesInterfaceImpl.logIntermediariesToDB(RulesInterfaceImpl.java:695)
at com.mcm.sw.interfaceimpl.RulesInterfaceImpl.applyBusinessRules(RulesInterfaceImpl.java:191)
at com.mcm.sw.engine.SmartWatchEngine.process(SmartWatchEngine.java:85)
at com.mcm.sw.ejb.SmartWatchBean.getInitialSmartWatch(SmartWatchBean.java:81)
at com.mcm.sw.ejb.SmartWatch_ssbgis_EOImpl.getInitialSmartWatch(SmartWatch_ssbgis_EOImpl.java:202)
at sun.reflect.GeneratedMethodAccessor421.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at weblogic.webservice.component.slsb.SLSBInvocationHandler.invoke(SLSBInvocationHandler.java:88)
at weblogic.webservice.core.handler.InvokeHandler.handleRequest(InvokeHandler.java:104)
at weblogic.webservice.core.HandlerChainImpl.handleRequest(HandlerChainImpl.java:143)
at weblogic.webservice.core.DefaultOperation.process(DefaultOperation.java:531)
at weblogic.webservice.server.Dispatcher.process(Dispatcher.java:204)
at weblogic.webservice.server.Dispatcher.doDispatch(Dispatcher.java:176)
at weblogic.webservice.server.Dispatcher.dispatch(Dispatcher.java:96)
at weblogic.webservice.server.WebServiceManager.dispatch(WebServiceManager.java:98)
at weblogic.webservice.server.servlet.WebServiceServlet.serverSideInvoke(WebServiceServlet.java:298)
at weblogic.webservice.server.servlet.ServletBase.doPost(ServletBase.java:485)
at weblogic.webservice.server.servlet.WebServiceServlet.doPost(WebServiceServlet.java:268)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at weblogic.servlet.internal.ServletStubImpl$ServletInvocationAction.run(ServletStubImpl.java:971)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:402)
at weblogic.servlet.internal.ServletStubImpl.invokeServlet(ServletStubImpl.java:305)
at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.run(WebAppServletContext.java:6350)
at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:317)
at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:118)
at weblogic.servlet.internal.WebAppServletContext.invokeServlet(WebAppServletContext.java:3635)
at weblogic.servlet.internal.ServletRequestImpl.execute(ServletRequestImpl.java:2585)
at weblogic.kernel.ExecuteThread.execute(ExecuteThread.java:197)
at weblogic.kernel.ExecuteThread.run(ExecuteThread.java:170)
Caused by: java.sql.SQLException: ORA-01400: cannot insert NULL into ("SWO"."REPORT_CALCULATIONS"."ACCOUNT_NUMBER")
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.ttc7.TTIoer.processError(TTIoer.java:289)
at oracle.jdbc.ttc7.Oall7.receive(Oall7.java:582)
at oracle.jdbc.ttc7.TTC7Protocol.doOall7(TTC7Protocol.java:1983)
at oracle.jdbc.ttc7.TTC7Protocol.executeFetch(TTC7Protocol.java:1002)
at oracle.jdbc.driver.OracleStatement.executeNonQuery(OracleStatement.java:2155)
at oracle.jdbc.driver.OracleStatement.doExecuteOther(OracleStatement.java:2032)
at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:2894)
at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:608)
at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:94)
at net.sf.hibernate.impl.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:22)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:468)
... 38 more
[ERROR ] com.mcm.sw.interfaceimpl.RulesInterfaceImpl.applyBusinessRules: Failed to log the request information to Report tables. The loan number is: the exception::com.mcm.sw.hibernate.HibernateDataAccessException: Error in opening/closing Hibernate Session handle - 03/17/05 10:16:29|645(3251727443)
Name and version of the database you are using:Oracle 9
The generated SQL (show_sql=true):
Debug level Hibernate log excerpt: