I have the following mapping files..
<hibernate-mapping>
<class name="com.sbc.hrtech.loa.server.hibernate.LoaEmployeeLeave" table="LOA_EMPLOYEE_LEAVE">
<id name="id" type="java.lang.String" column="ID">
<generator class="assigned"/>
</id>
<property name="ssn" type="java.lang.String" column="SSN" length="9"/>
<property name="loaPhone" type="java.lang.String" column="LOA_PHONE" length="20"/>
<property name="creatorSsn" type="java.lang.String" column="CREATOR_SSN" length="9"/>
<property name="fromDate" type="java.sql.Timestamp" column="FROM_DATE" length="7"/>
<property name="toDate" type="java.sql.Timestamp" column="TO_DATE" length="7"/>
<property name="email" type="java.lang.String" column="EMAIL" length="50"/>
<property name="loaAction" type="java.lang.String" column="LOA_ACTION" length="1"/>
<property name="returnToWorkDt" type="java.sql.Timestamp" column="RETURN_TO_WORK_DT" length="7"/>
<property name="createDate" type="java.sql.Timestamp" column="CREATE_DATE" length="7"/>
<property name="status" type="java.lang.String" column="STATUS" length="25"/>
<!-- associations -->
<!-- bi-directional one-to-one association to LoaNot -->
<set name="loaNot" lazy="true" inverse="true">
<key>
<column name="EMPLOYEE_LOA_ID"/>
</key>
<one-to-many class="com.sbc.hrtech.loa.server.hibernate.LoaNot"/>
</set>
<!--one-to-one name="loaNot" class="com.sbc.hrtech.loa.server.hibernate.LoaNot" outer-join="auto" property-ref="loaEmployeeLeave"/-->
<!-- bi-directional one-to-many association to LoaEmplLeaveStatu -->
<set name="loaEmplLeaveStatus" lazy="true" inverse="true">
<key>
<column name="LOA_EMPL_LEAVE_ID"/>
</key>
<one-to-many class="com.sbc.hrtech.loa.server.hibernate.LoaEmplLeaveStatu"/>
</set>
<!-- bi-directional one-to-one association to LoaAddress -->
<one-to-one name="loaAddress" class="com.sbc.hrtech.loa.server.hibernate.LoaAddress" outer-join="auto"/>
<!-- bi-directional many-to-one association to LoaType -->
<many-to-one name="loaType" class="com.sbc.hrtech.loa.server.hibernate.LoaType" not-null="true">
<column name="LOA_TYPE_ID"/>
</many-to-one>
</class>
</hibernate-mapping>
<hibernate-mapping>
<class
name="com.sbc.hrtech.loa.server.hibernate.LoaNot"
table="LOA_NOTES"
>
<composite-id name="comp_id" class="com.sbc.hrtech.loa.server.hibernate.LoaNotPK">
<key-property
name="type"
column="TYPE"
type="java.lang.String"
length="10"
/>
<!-- bi-directional one-to-one association to LoaEmployeeLeave -->
<key-many-to-one
name="loaEmployeeLeave"
class="com.sbc.hrtech.loa.server.hibernate.LoaEmployeeLeave"
>
<column name="EMPLOYEE_LOA_ID" />
</key-many-to-one>
</composite-id>
<property
name="comments"
type="java.lang.String"
column="COMMENTS"
length="300"
/>
<!-- associations -->
</class>
</hibernate-mapping>
<hibernate-mapping>
<class name="com.sbc.hrtech.loa.server.hibernate.LoaEmplLeaveStatu" table="LOA_EMPL_LEAVE_STATUS">
<composite-id name="comp_id" class="com.sbc.hrtech.loa.server.hibernate.LoaEmplLeaveStatuPK">
<key-property name="dateCreated" column="DATE_CREATED" type="java.sql.Timestamp" length="7"/>
<!-- bi-directional many-to-one association to LoaEmployeeLeave -->
<key-many-to-one name="loaEmployeeLeave" class="com.sbc.hrtech.loa.server.hibernate.LoaEmployeeLeave">
<column name="LOA_EMPL_LEAVE_ID"/>
</key-many-to-one>
</composite-id>
<property name="status" type="java.lang.String" column="STATUS" length="10"/>
<property name="creatorSsn" type="java.lang.String" column="CREATOR_SSN" length="9"/>
<property name="nextSsn" type="java.lang.String" column="NEXT_SSN" length="9"/>
<property name="denialCode" type="java.lang.String" column="DENIAL_CODE" length="10"/>
<!-- associations -->
</class>
</hibernate-mapping>
And the following java code
boolean saveNote = true;
Session sess = LOAUtility.getLoaSession(req);
tx = sess.beginTransaction();
if(comments == null)
comments = "";
String noteType = LOAConstants.NOTES_SUPERVISOR;
if(role.indexOf("sm") != -1)
noteType = LOAConstants.NOTES_SN_MANAGER;
else if(role.indexOf("a") != -1)
noteType = LOAConstants.NOTES_ADMIN;
else if(role.indexOf("m") != -1)
noteType = LOAConstants.NOTES_ATT_MANAGER;
String query = "select loaNote from LoaNot loaNote where " +
" loaNote.comp_id.type='"+noteType+"' and" +
" loaNote.comp_id.loaEmployeeLeave='"+emplLv.getId()+"'";
Iterator notes = emplLv.getLoaNot().iterator();
LoaNot lnote = null;
while(notes.hasNext()){
LoaNot tmp = (LoaNot)notes.next();
String type = tmp.getComp_id().getType();
if(type != null && type.equalsIgnoreCase(noteType)){
lnote = tmp;
break;
}
}
if(lnote == null){
lnote = new LoaNot(new LoaNotPK(noteType, emplLv), comments);
}else{
String cmts = lnote.getComments();
if(cmts != null)
cmts += comments;
else
cmts = comments;
lnote.setComments(cmts);
saveNote = false;
}
emplLv.setStatus(ls.getStatus());
emplLv.getLoaNot().add(lnote);
emplLv.getLoaEmplLeaveStatus().add(ls);
sess.update(emplLv);
sess.save(ls);
if(saveNote == true)
sess.save(lnote);
else
sess.update(lnote);
tx.commit();
For some reason, ONLY SOMETIMES, hibernate throws a JDBCException on tx.commit() however the changes do get persisted. Any help appreciated.
Hibernate: insert into LOA_EMPL_LEAVE_STATUS (STATUS, CREATOR_SSN, NEXT_SSN, DEN
IAL_CODE, DATE_CREATED, LOA_EMPL_LEAVE_ID) values (?, ?, ?, ?, ?, ?)
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
WARNING: SQL Error: 1, SQLState: 23000
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
SEVERE: ORA-00001: unique constraint (LOA_UAT_NEW.PK_LOA_EMPL_LEAVE_STATUS) viol
ated
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
WARNING: SQL Error: 1, SQLState: 23000
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
SEVERE: ORA-00001: unique constraint (LOA_UAT_NEW.PK_LOA_EMPL_LEAVE_STATUS) viol
ated
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
WARNING: SQL Error: 1, SQLState: 23000
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
SEVERE: ORA-00001: unique constraint (LOA_UAT_NEW.PK_LOA_EMPL_LEAVE_STATUS) viol
ated
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
WARNING: SQL Error: 1, SQLState: 23000
May 11, 2004 4:04:21 PM net.sf.hibernate.util.JDBCExceptionReporter logException
s
SEVERE: ORA-00001: unique constraint (LOA_UAT_NEW.PK_LOA_EMPL_LEAVE_STATUS) viol
ated
May 11, 2004 4:04:21 PM net.sf.hibernate.JDBCException <init>
SEVERE: Could not execute JDBC batch update
java.sql.BatchUpdateException: ORA-00001: unique constraint (LOA_UAT_NEW.PK_LOA_
EMPL_LEAVE_STATUS) violated
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:4
30)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePrepare
dStatement.java:2948)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeBatch(Dele
gatingPreparedStatement.java:231)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.
java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at com.sbc.hrtech.loa.server.businesslogic.utility.LOAUtility.updateLeav
e(LOAUtility.java:389)
at com.sbc.hrtech.loa.ui.action.LOAApplicationAuthorizationAction.execut
e(LOAApplicationAuthorizationAction.java:110)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
May 11, 2004 4:04:21 PM net.sf.hibernate.impl.SessionImpl execute
SEVERE: Could not synchronize database state with session
net.sf.hibernate.JDBCException: Could not execute JDBC batch update
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:129)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.j
ava:61)
at com.sbc.hrtech.loa.server.businesslogic.utility.LOAUtility.updateLeav
e(LOAUtility.java:389)
at com.sbc.hrtech.loa.ui.action.LOAApplicationAuthorizationAction.execut
e(LOAApplicationAuthorizationAction.java:110)
at org.apache.struts.action.RequestProcessor.processActionPerform(Reques
tProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.ja
va:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:148
2)
at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Appl
icationFilterChain.java:284)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationF
ilterChain.java:204)
at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperV
alve.java:257)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardContextValve.invokeInternal(Standard
ContextValve.java:245)
at org.apache.catalina.core.StandardContextValve.invoke(StandardContextV
alve.java:199)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.j
ava:195)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.j
ava:164)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:149)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineVal
ve.java:156)
at org.apache.catalina.core.StandardValveContext.invokeNext(StandardValv
eContext.java:151)
at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.jav
a:564)
at org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
at org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:20
6)
at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java
:828)
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.proce
ssConnection(Http11Protocol.java:700)
at org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java
:584)
at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadP
ool.java:683)
at java.lang.Thread.run(Thread.java:534)
Caused by: java.sql.BatchUpdateException: ORA-00001: unique constraint (LOA_UAT_
NEW.PK_LOA_EMPL_LEAVE_STATUS) violated
at oracle.jdbc.dbaccess.DBError.throwBatchUpdateException(DBError.java:4
30)
at oracle.jdbc.driver.OraclePreparedStatement.executeBatch(OraclePrepare
dStatement.java:2948)
at org.apache.commons.dbcp.DelegatingPreparedStatement.executeBatch(Dele
gatingPreparedStatement.java:231)
at net.sf.hibernate.impl.BatchingBatcher.doExecuteBatch(BatchingBatcher.
java:54)
at net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:122)
... 36 more
Tue May 11 16:04:21 EDT 2004 error persisting leave notes
Tue May 11 16:04:21 EDT 2004 error persisting leave notes
May 11, 2004 4:04:21 PM com.sbc.hrtech.framework.utility.LoggerUtil log
SEVERE: error persisting leave notes
Tue May 11 16:04:21 EDT 2004 error persisting leave notes
Could not execute JDBC batch update
net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:129)
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:61)
com.sbc.hrtech.loa.server.businesslogic.utility.LOAUtility.updateLeave(L
OAUtility.java:389)
com.sbc.hrtech.loa.ui.action.LOAApplicationAuthorizationAction.execute(L
OAApplicationAuthorizationAction.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
ocessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
javax.servlet.http.HttpServlet.service(HttpServlet.java:856)
org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(Applica
tionFilterChain.java:284)
org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilt
erChain.java:204)
org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValv
e.java:257)
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:151)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
64)
org.apache.catalina.core.StandardContextValve.invokeInternal(StandardCon
textValve.java:245)
org.apache.catalina.core.StandardContextValve.invoke(StandardContextValv
e.java:199)
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:151)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
64)
org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java
:195)
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:151)
org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java
:164)
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:149)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
64)
org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.
java:156)
org.apache.catalina.core.StandardValveContext.invokeNext(StandardValveCo
ntext.java:151)
org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:5
64)
org.apache.catalina.core.ContainerBase.invoke(ContainerBase.java:972)
org.apache.coyote.tomcat5.CoyoteAdapter.service(CoyoteAdapter.java:206)
org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:82
8)
org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processC
onnection(Http11Protocol.java:700)
org.apache.tomcat.util.net.TcpWorkerThread.runIt(PoolTcpEndpoint.java:58
4)
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:683)
java.lang.Thread.run(Thread.java:534)
Tue May 11 16:04:21 EDT 2004 error persisting leave notes
Could not execute JDBC batch update
net.sf.hibernate.impl.BatcherImpl.executeBatch(BatcherImpl.java:129)
net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2385)
net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2335)
net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2204)
net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java
:61)
com.sbc.hrtech.loa.server.businesslogic.utility.LOAUtility.updateLeave(L
OAUtility.java:389)
com.sbc.hrtech.loa.ui.action.LOAApplicationAuthorizationAction.execute(L
OAApplicationAuthorizationAction.java:110)
org.apache.struts.action.RequestProcessor.processActionPerform(RequestPr
ocessor.java:484)
org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:
274)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:525)
javax.servlet.http.HttpServlet.service(HttpServlet.java:763)
|