Subject: Every alternate record insertion into the database table is failing
Hibernate version: 3.0.5 Oracle: 9i enterprise edition WSAD 5.1
I have a list of 10 tables in my dropdown box. User can select any table and relevant input boxes will pop up. User can enter data and press the submit button. Record is saved in the DB table (the problem is: alternate record is not saved into the DB).
After user submission, my Action will forward the begenning JSP page,
(along with succes/failure message depending on the succes or failure)
And user can (re)select a table and submit the record for insertion.
I can not insert records sequentially (into teh same table) through web interface, (but I can do the same through JUnit tests).
Every alternate time my record is not inserted into the table.
In the JUnit test, I invoked the same method and can insert any number of records (user-entered data is hard coded) w/o any problem.
But I have problem when I enter the data in the text boxes and subit the data through user interface(JSP).
I used both get and post methods, and they behaved same(alternate failures). I ruled out that I am not violating any meta data constrainsts(Strigs as strings, Date as date etc).
I am using ClassMetaData object to assign user entered data values to the POJO properties.
I can insert a single record at a time sequentially in all the 10 tables.
The problme is I cannot insert a second record. I also treid opening a new borwser and entering a 2nd record , but it gives the same error message(alternate failures).
============================== my code snippets:
import org.hibernate.metadata.ClassMetadata;
import org.springframework.orm.hibernate3.HibernateTemplate;
...
....
ClassMetadata classMetadata = getClassMetadata(clazz);
...
Object pojoObj = getTableClass(tableName).newInstance();
...
... // pojoObj, propName, user-entered-Value ie., recordMap.get(propName) are
/ verified through System.out.println() statements and errors ruled out
// before executing the below statement
classMetadata.setPropertyValue(pojoObj,propName,recordMap.get(propName),EntityMode.POJO);
....
HibernateTemplate template = getHibernateTemplate();
template.save(pojoObj);
==============================
I used try/catch blocks at every stage and feel that classMetadata.setPropertyValue(...)
method is invoked succesfully every time and the problem is in SQL code execution (alternative insertions).
Any comments/suggestions will be greatly apprecaited.
TIA
---------succesful insertion:
<..20b..> Completed : template.save(pojoObj)
Hibernate: insert into EXT_AGN (LAST_UPDT_DT, EXT_AGN_NM, EXT_AGN_CD,
LAST_UPDT_BY_USER_ID, EXT_AGN_ID) values (?, ?, ?, ?, ?)
[2/28/06 12:49:21:549 CST] c3a4f80 SystemOut
---------next failed insertion throws java.lang.NullPointerException:
<..20b..> Completed : template.save(pojoObj)
Hibernate: insert into EXT_AGN (LAST_UPDT_DT, EXT_AGN_NM, EXT_AGN_CD,
LAST_UPDT_BY_USER_ID, EXT_AGN_ID) values (?, ?, ?, ?, ?)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemOut O
ERROR [49/28/06 12:49:33:532 CST] com.mycomany.dec.web.internalTables.InTablesInsertAction.insertRecord(InTablesInsertAction.java:163): -
<..24..>catch{}: Exception in insertRecord() :null[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R java.lang.NullPointerException
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:1762)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1458)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1424)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:396)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:76)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:69)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:150)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:1839)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.persister.entity.BasicEntityPersister.insert(BasicEntityPersister.java:2194)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.action.EntityInsertAction.execute(EntityInsertAction.java:46)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:239)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:223)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:136)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:274)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:27)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:730)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:324)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:86)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.springframework.orm.hibernate3.HibernateTransactionManager.doCommit(HibernateTransactionManager.java:584)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.springframework.transaction.support.AbstractPlatformTransactionManager.processCommit(AbstractPlatformTransactionManager.java:496)
[2/28/06 12:49:33:532 CST] 3ff2cf80 SystemErr R at org.springframework.transaction.support.AbstractPlatformTransactionManager.commit(AbstractPlatformTransactionManager.java:469)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.transaction.interceptor.TransactionAspectSupport.doCommitTransactionAfterReturning(TransactionAspectSupport.java:266)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.transaction.interceptor.TransactionInterceptor.invoke(TransactionInterceptor.java:106)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:170)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:176)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at $Proxy66.insertRecordService(Unknown Source)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.mycompany.infer.dec.web.internalTables.InTablesInsertAction.insertRecord(InTablesInsertAction.java:153)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java(Compiled Code))
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java(Compiled Code))
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at java.lang.reflect.Method.invoke(Method.java(Compiled Code))
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.actions.DispatchAction.dispatchMethod(DispatchAction.java:274)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.mycompany.infer.dec.web.DamAction.dispatchMethod(DamAction.java:122)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.actions.DispatchAction.execute(DispatchAction.java:194)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:419)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:224)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1194)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:760)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:76)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.orm.hibernate3.support.OpenSessionInViewFilter.doFilterInternal(OpenSessionInViewFilter.java:174)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:76)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.filter.FilterInstanceWrapper.doFilter(FilterInstanceWrapper.java:132)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.filter.WebAppFilterChain.doFilter(WebAppFilterChain.java:71)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:564)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:182)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.http.HttpConnection.run(HttpConnection.java:439)
[2/28/06 12:49:33:548 CST] 3ff2cf80 SystemErr R at com.ibm.ws.util.ThreadPool$Worker.run(ThreadPool.java:672)
|