-->
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.  [ 7 posts ] 
Author Message
 Post subject: Exception when use hibernate... need GUIDE
PostPosted: Sat May 31, 2008 2:40 am 
Beginner
Beginner

Joined: Sat May 31, 2008 2:35 am
Posts: 30
Location: pakistan
hi to all...
i m new to using hibernate with struts.. i face that Exception when ever i serach the result from MYSQl db..

can any one tell me y this occuring and how to prevent it....

-------------------------------------------------------------
----------------------------------------------------------------

type Exception report

message

description The server encountered an internal error () that prevented it from fulfilling this request.

exception

javax.servlet.ServletException: org.hibernate.exception.DataException: Could not execute JDBC batch update
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:286)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

org.hibernate.exception.DataException: Could not execute JDBC batch update
org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:77)
org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:202)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
easywhey.persistence.ProductDAO.findAll(ProductDAO.java:139)
easywhey.action.SearchProductsAction.execute(SearchProductsAction.java:58)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

root cause

java.sql.BatchUpdateException: Data truncation: Data too long for column 'Title' at row 1
com.mysql.jdbc.PreparedStatement.executeBatchSerially(PreparedStatement.java:1257)
com.mysql.jdbc.PreparedStatement.executeBatch(PreparedStatement.java:943)
org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:58)
org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:195)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:235)
org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:140)
org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:297)
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
easywhey.persistence.ProductDAO.findAll(ProductDAO.java:139)
easywhey.action.SearchProductsAction.execute(SearchProductsAction.java:58)
org.apache.struts.chain.commands.servlet.ExecuteAction.execute(ExecuteAction.java:58)
org.apache.struts.chain.commands.AbstractExecuteAction.execute(AbstractExecuteAction.java:67)
org.apache.struts.chain.commands.ActionCommandBase.execute(ActionCommandBase.java:51)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.commons.chain.generic.LookupCommand.execute(LookupCommand.java:304)
org.apache.commons.chain.impl.ChainBase.execute(ChainBase.java:190)
org.apache.struts.chain.ComposableRequestProcessor.process(ComposableRequestProcessor.java:283)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:1913)
org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:449)
javax.servlet.http.HttpServlet.service(HttpServlet.java:690)
javax.servlet.http.HttpServlet.service(HttpServlet.java:803)

note The full stack trace of the root cause is available in the Apache Tomcat/6.0.14 logs.


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 31, 2008 6:31 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Quote:
Data truncation: Data too long for column 'Title' at row 1


You have declared some data length for your column and you are trying to save some value which needs more storage. Change you database column definition or do a validation of the data length in you application.

Carlo


Top
 Profile  
 
 Post subject:
PostPosted: Sat May 31, 2008 6:40 am 
Beginner
Beginner

Joined: Sat May 31, 2008 2:35 am
Posts: 30
Location: pakistan
realy thanx fr rep me...

ok i try to change the length of row in my Db...


but i m confusing that u say that Exception occur due to low length in Db... but i m only reterving the data from Db not inserting in it... and i not see any Exception when i use simple JDBC connection but using Hibernate that Exception occur..

so would u tell me that y that kind of Exception only occur in my Application when i use hibernate and it is woking perfectelly in simple JDBC connection..

waiting fr ur Response..

Thanx again fr suporting...


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jun 02, 2008 2:07 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Quote:
org.hibernate.event.def.DefaultAutoFlushEventListener.onAutoFlush(DefaultAutoFlushEventListener.java:41)
org.hibernate.impl.SessionImpl.autoFlushIfRequired(SessionImpl.java:954)
org.hibernate.impl.SessionImpl.list(SessionImpl.java:1099)
org.hibernate.impl.QueryImpl.list(QueryImpl.java:79)
easywhey.persistence.ProductDAO.findAll(ProductDAO.java:139)


Hi,

you're saying you're do only reading. But on the stack trace you can see the call
Code:
autoFlushIfRequired.
This is something Hibernate does automatically before executing a query - that is, it checks, if it has dirty objects (entities) in the persistence context - which might affect the query results. So it flushes this dirty data to the DB - and that's where your exception comes from.

Carlo
------------------------------------
please credit me if this helped you


Top
 Profile  
 
 Post subject: i increase the length of row in DB
PostPosted: Tue Jun 03, 2008 2:40 am 
Beginner
Beginner

Joined: Sat May 31, 2008 2:35 am
Posts: 30
Location: pakistan
AS u say to increase the length of row in a table i d that but same Exception again occur when i search the product..

if that Exception occur and if using Firfox br than after refreshing next result are shown but when using the IE refresh can't be work and same Exception agin be thrown by Application..

so can u tell me how again i prevent it..

my running web application is that...

http://www.hostpattern.net:8080/EasyWhey

waiting fr ur response...

hope u tell me me the how i do that


Top
 Profile  
 
 Post subject: Re: i increase the length of row in DB
PostPosted: Tue Jun 03, 2008 5:09 am 
Pro
Pro

Joined: Tue Jun 12, 2007 4:13 am
Posts: 209
Location: Berlin, Germany
Nommi wrote:
so can u tell me how again i prevent it..


Hi Nommi,

what ever your app does and how consisted the Hibernate mappings are with your DB, I will show you how you can prevent the flushing of dirty objects when Hibernate is asked to do a query (remember, normally Hibernate flushes dirty entities to the DB before it will execute the query).

Code:
Query q = em.createQuery(.....)
q.setFlushMode(FlushMode.COMMIT);

Dirty entities will then only be written into the DB at commit time of your transaction.

PS: if you want to do real work with Hibernate, you have to eagerly study the Hibernate (and JPA) documentation. Better: read the Hibernate Book.

Carlo

---------------------------------------------
if this post helped you please give me credits


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jun 03, 2008 7:29 am 
Beginner
Beginner

Joined: Sat May 31, 2008 2:35 am
Posts: 30
Location: pakistan
yaa it working now

setFlushMode(FlushMode.COMMIT); realy work and now my Application working f9..

I realy thanx to u fr support ...

Thanx again CarloF.....

will be contact in new Hibernate Prob...


Tc


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 7 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.