-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 
Author Message
 Post subject: Insertion problem with hibernate
PostPosted: Thu Mar 11, 2004 5:59 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Hi

When a save is called for an object, it gets saved in database for the first time. Id is generated thro' sequence. But when same object is tried to save again then it throws exception:

ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "handle" on bean "BeanId(CrushMargin#CrushMargin_Business.jar#PlantCreate, null)". Exception data: java.lang.NullPointerException

As the key gets assigned thro' a sequence , it should save same object when a refresh is called on the browser. Then why doesn't it saves it and throws the exception?

Thanks
Yogs


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 6:17 pm 
Regular
Regular

Joined: Wed Mar 03, 2004 9:38 am
Posts: 70
Use update() or saveOrUpdate() instead of save().


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 6:28 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
joib wrote:
Use update() or saveOrUpdate() instead of save().


But since same java object is getting populated with different key, still we need to say update?

When It tries to insert second time, it's totally a new session getting created.

Thanks
Yogs


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 6:43 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Yogs wrote:
joib wrote:
Use update() or saveOrUpdate() instead of save().


Update and saveOrUpdate used but still getting the same exception.

Thanks
Yogs


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 7:21 pm 
Expert
Expert

Joined: Thu Jan 08, 2004 6:17 pm
Posts: 278
How do you know this NullPointerException is being thrown by Hibernate?

Please post the full stack trace that gives you this impression.

Thanks,
Rob


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:44 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
RobJellinghaus wrote:
How do you know this NullPointerException is being thrown by Hibernate?

Please post the full stack trace that gives you this impression.

Thanks,
Rob



Here it is

Hibernate: select PLANT_SEQ.nextval from dual
[3/11/04 14:46:01:595 EST] 7a769a68 SystemOut O Hibernate: select PLANT_COMMODITY_SEQ.nextval from dual
[3/11/04 14:46:01:595 EST] 7a769a68 SystemOut O Hibernate: select PLANT_COMMODITY_SEQ.nextval from dual
[3/11/04 14:46:01:611 EST] 7a769a68 SystemOut O Hibernate: select PLANT_CAPACITY_SEQ.nextval from dual
[3/11/04 14:46:01:611 EST] 7a769a68 SystemOut O Hibernate: select PLANT_CAPACITY_SEQ.nextval from dual
[3/11/04 14:46:01:611 EST] 7a769a68 SystemOut O Hibernate: select PLANT_CAPACITY_SEQ.nextval from dual
[3/11/04 14:46:01:627 EST] 7a769a68 SystemOut O Hibernate: select PLANT_CAPACITY_SEQ.nextval from dual
[3/11/04 14:46:01:627 EST] 7a769a68 SystemOut O Hibernate: select PLANT_MARKET_SEQ.nextval from dual
[3/11/04 14:46:01:627 EST] 7a769a68 SystemOut O Hibernate: select PLANT_MARKET_SEQ.nextval from dual
[3/11/04 14:46:01:627 EST] 7a769a68 SystemOut O Hibernate: select PLANT_PORT_SEQ.nextval from dual
[3/11/04 14:46:01:642 EST] 7a769a68 SystemOut O Hibernate: select PLANT_PORT_SEQ.nextval from dual
[3/11/04 14:46:01:642 EST] 7a769a68 SystemOut O Hibernate: insert into BGM_COMMON.PLANT (LOCATION_ID, PLANT_NAME, COMPANY_CODE, START_OF_CROP_YEAR, PLANT_STATUS, UPDATE_DATE, UPDATED_BY, CREATE_DATE, CREATED_BY, PLANT_ID) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
[3/11/04 14:46:01:673 EST] 7a769a68 SystemOut O Hibernate: insert into BGM_COMMON.PLANT_COMMODITY (PLANT_ID, COMMODITY_CODE, UPDATE_DATE, UPDATED_BY, CREATE_DATE, CREATED_BY, PLANT_COMMODITY_ID) values (?, ?, ?, ?, ?, ?, ?)
[3/11/04 14:46:01:673 EST] 7a769a68 ExceptionUtil E CNTR0020E: Non-application exception occurred while processing method "handle" on bean "BeanId(CrushMargin#CrushMargin_Business.jar#PlantCreate, null)". Exception data: java.lang.NullPointerException
at oracle.jdbc.dbaccess.DBData.clearItem(DBData.java:431)
at oracle.jdbc.dbaccess.DBDataSetImpl.clearItem(DBDataSetImpl.java:3528)
at oracle.jdbc.driver.OraclePreparedStatement.clearParameters(OraclePreparedStatement.java:3401)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.resetStatement(WSJdbcConnection.java:1719)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1415)
at com.ibm.ws.rsadapter.jdbc.WSJdbcConnection.prepareStatement(WSJdbcConnection.java:1381)
at net.sf.hibernate.impl.SessionFactoryImpl.getPreparedStatement(SessionFactoryImpl.java:537)
at net.sf.hibernate.impl.BatcherImpl.prepareStatement(BatcherImpl.java:52)
at net.sf.hibernate.impl.BatcherImpl.prepareBatchStatement(BatcherImpl.java:93)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:469)
at net.sf.hibernate.persister.EntityPersister.insert(EntityPersister.java:454)
at net.sf.hibernate.impl.ScheduledInsertion.execute(ScheduledInsertion.java:20)
at net.sf.hibernate.impl.SessionImpl.executeAll(SessionImpl.java:2100)
at net.sf.hibernate.impl.SessionImpl.execute(SessionImpl.java:2061)
at net.sf.hibernate.impl.SessionImpl.flush(SessionImpl.java:2005)
at net.sf.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:57)
at com.bunge.bgm.crushmargin.plant.ejb.PlantCreateBean.handle(PlantCreateBean.java:39)
at com.bunge.bgm.crushmargin.plant.ejb.EJSRemoteStatelessPlantCreate_72136c1c.handle(EJSRemoteStatelessPlantCreate_72136c1c.java:22)
at com.bunge.bgm.crushmargin.plant.ejb._PlantCreate_Stub.handle(_PlantCreate_Stub.java:257)
at com.bunge.bgm.crushmargin.plant.handler.PlantEJBHandler.handle(PlantEJBHandler.java:44)
at com.bunge.bgm.common.servicefacade.PlainKilimServiceFacade.process(PlainKilimServiceFacade.java:33)
at com.bunge.bgm.common.accessor.PlainKilimAccessor.access(Unknown Source)
at com.bunge.bgm.crushmargin.action.common.AbstActionBase.receiveResult(AbstActionBase.java:69)
at com.bunge.bgm.crushmargin.action.common.LoginAction.addPlant(LoginAction.java:441)
at com.bunge.bgm.crushmargin.action.common.LoginAction.execute(LoginAction.java:49)
at org.apache.struts.action.RequestProcessor.processActionPerform(RequestProcessor.java:484)
at org.apache.struts.action.RequestProcessor.process(RequestProcessor.java:274)
at org.apache.struts.action.ActionServlet.process(ActionServlet.java:1482)
at org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:507)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:740)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.ibm.ws.webcontainer.servlet.StrictServletInstance.doService(StrictServletInstance.java:110)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet._service(StrictLifecycleServlet.java:174)
at com.ibm.ws.webcontainer.servlet.IdleServletState.service(StrictLifecycleServlet.java:313)
at com.ibm.ws.webcontainer.servlet.StrictLifecycleServlet.service(StrictLifecycleServlet.java:116)
at com.ibm.ws.webcontainer.servlet.ServletInstance.service(ServletInstance.java:283)
at com.ibm.ws.webcontainer.servlet.ValidServletReferenceState.dispatch(ValidServletReferenceState.java:42)
at com.ibm.ws.webcontainer.servlet.ServletInstanceReference.dispatch(ServletInstanceReference.java:40)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.handleWebAppDispatch(WebAppRequestDispatcher.java:974)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.dispatch(WebAppRequestDispatcher.java:555)
at com.ibm.ws.webcontainer.webapp.WebAppRequestDispatcher.forward(WebAppRequestDispatcher.java:200)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.doForward(WebAppInvoker.java:119)
at com.ibm.ws.webcontainer.srt.WebAppInvoker.handleInvocationHook(WebAppInvoker.java:276)
at com.ibm.ws.webcontainer.cache.invocation.CachedInvocation.handleInvocation(CachedInvocation.java:71)
at com.ibm.ws.webcontainer.cache.invocation.CacheableInvocationContext.invoke(CacheableInvocationContext.java:114)
at com.ibm.ws.webcontainer.srp.ServletRequestProcessor.dispatchByURI(ServletRequestProcessor.java:186)
at com.ibm.ws.webcontainer.oselistener.OSEListenerDispatcher.service(OSEListener.java:334)
at com.ibm.ws.webcontainer.http.HttpConnection.handleRequest(HttpConnection.java:56)
at com.ibm.ws.http.HttpConnection.readAndHandleRequest(HttpConnection.java:618)
at com.ibm.ws.http.HttpConnection.run(HttpConnection.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:52 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Well, doesn't look much like Hibernate at fault here, does it?

You should focus upon the connection pool and JDBC driver.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 8:55 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Disable websphere's PreparedStatement cache, and see if the exception goes away.


Top
 Profile  
 
 Post subject:
PostPosted: Thu Mar 11, 2004 9:01 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
gavin wrote:
Disable websphere's PreparedStatement cache, and see if the exception goes away.



First time it adds the record...Second time it throws above exception...again if you try, it adds record and so on.

Also can you please tell me how to disable PreparedStatement Cache in WebSphere?

Thanks


Top
 Profile  
 
 Post subject: Problem with hibernate configuration file
PostPosted: Fri Mar 12, 2004 4:58 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Hi

I am working on J2EE application. When I add following line to the hibernate.cfg.xml, it works and inserts a record. But when datasource is configured and that JNDI name is mentioned then it gives earlier exceptions posted.

<property name="hibernate.connection.driver_class">oracle.jdbc.driver.OracleDriver</property>
<property name="hibernate.connection.url">jdbc:oracle:thin:@10.x.x.x:1521:dbname</property>
<property name="hibernate.connection.username">user_common</property>
<property name="hibernate.connection.password">user_common</property>

<!-- Database Settings -->
<property name="default_schema">BGM_COMMON</property>
<property name="dialect">net.sf.hibernate.dialect.OracleDialect</property>
<property name="show_sql">true</property>

Thanks


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 5:03 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Why the code doesn't work when you give below line to hibernate.cfg.xml?

<property name="hibernate.connection.datasource">COMMONDS</property>


Top
 Profile  
 
 Post subject:
PostPosted: Fri Mar 12, 2004 5:59 pm 
Beginner
Beginner

Joined: Wed Mar 03, 2004 4:56 pm
Posts: 29
Hey Thanks Gavin

After setting statement cache size to 0, problem is solved.

Thanks
Yogs


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 12 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.