org.hibernate.exception.DataException: Could not execute JDBC batchupdate

A

Amit Jain

Hi All,
I am getting below exception while inserting/adding row in table named
as "apss"

com.yashbinary.crtracker.common.ApplicationException:
DataAccessException Error in ApssEntityImpl.insertApssEntity():
com.yashbinary.crtracker.common.DataAccessException: Error in
APSSDAOImpl.insertApssEntity(): org.hibernate.exception.DataException:
Could not execute JDBC batch update

com.yashbinary.crtracker.apssentity.ApssEntityManagerImpl.insertApssEntity
(ApssEntityManagerImpl.java:55)
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
sun.reflect.NativeMethodAccessorImpl.invoke
(NativeMethodAccessorImpl.java:39)
sun.reflect.DelegatingMethodAccessorImpl.invoke
(DelegatingMethodAccessorImpl.java:25)
java.lang.reflect.Method.invoke(Method.java:585)

org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection
(AopUtils.java:301)
org.springframework.aop.framework.JdkDynamicAopProxy.invoke
(JdkDynamicAopProxy.java:198)
$Proxy1.insertApssEntity(Unknown Source)

com.yashbinary.crtracker.struts.postapssentity.PostApssEntityAction.execute
(PostApssEntityAction.java:60)
org.springframework.web.struts.DelegatingActionProxy.execute
(DelegatingActionProxy.java:106)
org.apache.struts.action.RequestProcessor.processActionPerform
(RequestProcessor.java:431)

com.yashbinary.crtracker.struts.controller.XRequestProcessor.processActionPerform
(XRequestProcessor.java:45)
org.apache.struts.action.RequestProcessor.process
(RequestProcessor.java:236)
com.yashbinary.crtracker.struts.controller.XRequestProcessor.process
(XRequestProcessor.java:32)
org.apache.struts.action.ActionServlet.process(ActionServlet.java:
1196)
org.apache.struts.action.ActionServlet.doPost(ActionServlet.java:432)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter
(MonitorFilter.java:390)

ApssDAOImpl.java
-------------------------------------
public class ApssDAOImpl extends HibernateDaoSupport implements
IApssDAO{
public void insertApssEntity(ApssVO apssVO) throws DataAccessException
{
Transaction tx = null;
Session session = getHibernateTemplate().getSessionFactory
().openSession();
try {
tx = session.beginTransaction();
session.save(apssVO);
tx.commit();
}catch (RuntimeException e) {
if (tx != null && tx.isActive()) {
try {
// Second try catch as the rollback could fail as
well
tx.rollback();
} catch (HibernateException e1) {
logger.debug("Error in APSSDAOImpl.insertApssEntity
(): Rolling back transaction");
}
// throw again the first exception
throw new DataAccessException("Error in
APSSDAOImpl.insertApssEntity(): " + e.toString(), e);
}
}
}
}

Table "apss"
------------------------------
CREATE TABLE apss (
id VARCHAR(50) NOT NULL, owner INTEGER NOT NULL,
entity VARCHAR(2) NOT NULL, case_id VARCHAR(50) NOT NULL,
title LONG VARCHAR NOT NULL, type VARCHAR(50) NOT NULL,
start_date DATE NOT NULL, close_date DATE,
asms_version VARCHAR(20) NOT NULL, account VARCHAR(50) NOT NULL,
reporting_code VARCHAR(10) NOT NULL, severity VARCHAR(2),
rank VARCHAR(5), remark LONG VARCHAR NOT NULL,
change_list INTEGER, hotfix_order INTEGER NOT NULL,
affected_file LONG VARCHAR NOT NULL, foundation_fix LONG VARCHAR,
park_time DATE, num_park TINYINT,
last_reopen DATE, total_effort TINYINT,
pre_cr LONG VARCHAR, PRIMARY KEY (id), foreign key (owner) REFERENCES
member(emp_id));

Table "member"
--------------------------------
CREATE TABLE member (
emp_id INTEGER NOT NULL, first_name VARCHAR(50),
last_name VARCHAR(50), email_id VARCHAR(20),
password VARCHAR(10), PRIMARY KEY (emp_id));

apss.hbm.xml
-----------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 22, 2009 3:44:09 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.yashbinary.crtracker.vo.ApssVO" table="apss"
catalog="crtracker">
<id name="id" type="string">
<column name="id" length="50" />
<generator class="assigned" />
</id>
<many-to-one name="member"
class="com.yashbinary.crtracker.vo.MemberVO" fetch="select">
<column name="owner" not-null="true" unique="true" />
</many-to-one>
<property name="entity" type="string">
<column name="entity" length="2" not-null="true" />
</property>
<property name="caseId" type="string">
<column name="case_id" length="50" not-null="true" />
</property>
<property name="title" type="string">
<column name="title" length="256" not-null="true" />
</property>
<property name="type" type="string">
<column name="type" length="50" not-null="true" />
</property>
<property name="startDate" type="date">
<column name="start_date" length="10" not-null="true" />
</property>
<property name="closeDate" type="date">
<column name="close_date" length="10" not-null="true" />
</property>
<property name="asmsVersion" type="string">
<column name="asms_version" length="20" not-null="true" />
</property>
<property name="account" type="string">
<column name="account" length="50" not-null="true" />
</property>
</property>
<property name="severity" type="string">
<column name="severity" length="2" not-null="true" />
</property>
<property name="rank" type="string">
<column name="rank" length="5" not-null="true" />
</property>
<property name="remark" type="string">
<column name="remark" length="16277215" not-null="true" />
</property>
<property name="changeList" type="int">
<column name="change_list" not-null="true" />
</property>
<property name="hotfixOrder" type="int">
<column name="hotfix_order" not-null="true" />
</property>
<property name="affectedFile" type="string">
<column name="affected_file" length="16277215" not-
null="true" />
</property>
<property name="foundationFix" type="string">
<column name="foundation_fix" length="16277215" not-
null="true" />
</property>
<property name="parkTime" type="date">
<column name="park_time" length="10" />
</property>
<property name="numPark" type="java.lang.Byte">
<column name="num_park" />
</property>
<property name="lastReopen" type="date">
<column name="last_reopen" length="10" />
</property>
<property name="totalEffort" type="java.lang.Byte">
<column name="total_effort" />
</property>
<property name="preCr" type="string">
<column name="pre_cr" length="65535" />
</property>
</class>
</hibernate-mapping>

member.hbm.xml
----------------------------------------
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD
3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<!-- Generated Apr 22, 2009 3:44:09 PM by Hibernate Tools 3.2.1.GA -->
<hibernate-mapping>
<class name="com.yashbinary.crtracker.vo.MemberVO" table="member"
catalog="crtracker">
<id name="empId" type="int">
<column name="emp_id" />
<generator class="assigned" />
</id>
<property name="firstName" type="string">
<column name="first_name" length="50" />
</property>
<property name="lastName" type="string">
<column name="last_name" length="50" />
</property>
<property name="emailId" type="string">
<column name="email_id" length="20" />
</property>
<property name="password" type="string">
<column name="password" length="10" />
</property>
<set name="apsses" inverse="true">
<key>
<column name="owner" not-null="true" unique="true" />
</key>
<one-to-many class="com.yashbinary.crtracker.vo.ApssVO" />
</set>
</class>
</hibernate-mapping>

ApssVO.java
------------------------------------
public class ApssVO extends ValueObject implements
java.io.Serializable {
private MemberVO member;
//other members and there getters and setters
public MemberVO getMember() {
return this.member;
}

public void setMember(MemberVO member) {
this.member = member;
}
}

MemberVO.java
-------------------------------------
public class MemberVO extends ValueObject implements
java.io.Serializable {
private Set<ApssVO> apsses = new HashSet<ApssVO>(0);
//other members and there getters and setters
public void setPassword(String password) {
this.password = password;
}
public Set<ApssVO> getApsses() {
return this.apsses;
}

public void setApsses(Set<ApssVO> apsses) {
this.apsses = apsses;
}
}

applicationContext.xml
---------------------------------------------
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource"><ref local="dataSource"/></property>
<property name="mappingResources">
<list> <value>com/yashbinary/crtracker/vo/h_mapping/
Member.hbm.xml</value>
<value>com/yashbinary/crtracker/vo/h_mapping/
Apss.hbm.xml</value>
</list>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">create</prop>
</props>
</property>
</bean>

<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

<bean id="apssEntityManager"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="apssEntityManagerTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>

<bean id="apssEntityManagerTarget"
class="com.yashbinary.crtracker.apssentity.ApssEntityManagerImpl">
<property name="apssDAO">
<ref local="apssDAO"/>
</property>
</bean>

<bean id="apssDAO"
class="com.yashbinary.crtracker.apssentity.dao.ApssDAOImpl">
<property name="sessionFactory">
<ref local="sessionFactory"/>
</property>
</bean>

"$Proxy1.insertApssEntity(Unknown Source)"

Any idea what's going wrong?

Thanks in advance,
Amit Jain
 
A

Amit Jain

Hi All,

I google this exception but did not found any relevant answer.

I added one property in hibernate.cfg.xml i.e.
"hibernate.jdbc.batch_size 0 ". But after doing that changes in
hibernate.cfg.xml nothing got same exception.

Thanks and Regards,
Amit Jain
 
A

Amit Jain

Hi All,
I am using Struts, Spring with Hibernate and MySQL.

I am trying to modify the data by inserting a record without
explicitly defining read-only.
I think Spring supports the concept of read-only transactions. A read-
only transaction does not modify any data.

Is there any attribute which sets transaction mode other than read-
only.

<bean id="apssEntityManager"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="apssEntityManagerTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>


Thanks and regards,
Amit Jain
 
J

Jim Garrison

Amit said:
Hi All,
I am using Struts, Spring with Hibernate and MySQL.

I am trying to modify the data by inserting a record without
explicitly defining read-only.
I think Spring supports the concept of read-only transactions. A read-
only transaction does not modify any data.

Is there any attribute which sets transaction mode other than read-
only.

<bean id="apssEntityManager"
class="org.springframework.transaction.interceptor.TransactionProxyFactoryBean">
<property name="transactionManager">
<ref bean="transactionManager"/>
</property>
<property name="target">
<ref bean="apssEntityManagerTarget"/>
</property>
<property name="transactionAttributes">
<props>
<prop key="find*">PROPAGATION_REQUIRED,readOnly</prop>
</props>
</property>
</bean>


Thanks and regards,
Amit Jain

What's the underlying SQLException?

There is a known problem with JDBC drivers between 10.2.0.4 and
11.0.1.6 inclusive relating to throwing ArrayIndexOutOfBoundsException
when updating large batches.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top