-->
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.  [ 1 post ] 
Author Message
 Post subject: ConstraintViolation: Could not execute JDBC batch update
PostPosted: Thu Feb 07, 2013 11:39 am 
Newbie

Joined: Thu Feb 07, 2013 11:24 am
Posts: 1
In my application I have many database tables. One of them is "AlarmMessage" table which contains references to 3 other FK tables.
When I try to insert an "AlarmMessage" values into the table, I got the following error. I checked every mapping file; all of them are correct. Even I tried to insert values into other 3 FK tables one by one before saving the AlarmMessage values which was successfull. But I cannot save values into the "AlarmMessage" table. In the followings there are "AlarmMessage" xml mapping file and the "save" function for "Alarm Message":

mapping:

<hibernate-mapping package="com.omega.messages">
<class name="AlarmMessage" table="alarmmessage">
<id name="alarmsId" column="alarmmessageid">
<generator class="sequence">
<param name="sequence">alarmsid_seq</param>
</generator>
</id>
<many-to-one name="mtsTrackId" class="Vehicle" column="mtstrackid" not-null="true" lazy="false"/>
<many-to-one name="ioStatusId" class="IoStatus" column="iostatusid" cascade="all" not-null="true"/>
<many-to-one name="coordinatesId" class="Coordinates" column="coordinatesid" cascade="all" not-null="true"/>
<property name="alarmStatus" type="java.lang.String" column="alarmstatus"/>
<property name="totalDistance" type="java.lang.Double" column="totaldistance"/>
<property name="totalworkingDuration" type="java.lang.Integer" column="totalworkingduration"/>
<property name="maintenanceRemainingTime" type="java.lang.Integer" column="maintenanceremainingtime"/>
<property name="isRead" type="java.lang.Boolean" column="isread"/>
</class>
</hibernate-mapping>

Alarm Message save function:

public static void saveMessage(AlarmMessage message) {
Session session = HibernateUtil.getSessionFactory().openSession();
Transaction transaction = null;
try {
transaction = session.beginTransaction();
session.save(message);
transaction.commit();
session.flush();
} catch (HibernateException e) {
transaction.rollback();
e.printStackTrace();
} finally {
session.close();
}
}

the whole stacktrace of the error:

org.hibernate.exception.ConstraintViolationException: Could not execute JDBC batch update
at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:96)
at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:275)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:268)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:184)
at org.hibernate.event.def.AbstractFlushingEventListener.performExecutions(AbstractFlushingEventListener.java:321)
at org.hibernate.event.def.DefaultFlushEventListener.onFlush(DefaultFlushEventListener.java:51)
at org.hibernate.impl.SessionImpl.flush(SessionImpl.java:1216)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:383)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:133)
at com.omega.util.TrackerDAO.saveMessage(TrackerDAO.java:56)
at com.omega.MessageTest.main(MessageTest.java:16)
Caused by: java.sql.BatchUpdateException: Tpilı iş girişi 0 insert into alarmmessage (mtstrackid, iostatusid, coordinatesid, alarmstatus, totaldistance, totalworkingduration, maintenanceremainingtime, isread, alarmmessageid) values ('CKZ25', '1666477', '5205527', '1000', '43.0', NULL, NULL, NULL, '41803') durduruldu. Nedenini görmek için getNextException fonksiyonu çağırın.
at org.postgresql.jdbc2.AbstractJdbc2Statement$BatchResultHandler.handleError(AbstractJdbc2Statement.java:2598)
at org.postgresql.core.v3.QueryExecutorImpl.processResults(QueryExecutorImpl.java:1836)
at org.postgresql.core.v3.QueryExecutorImpl.execute(QueryExecutorImpl.java:407)
at org.postgresql.jdbc2.AbstractJdbc2Statement.executeBatch(AbstractJdbc2Statement.java:2737)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
... 9 more


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

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.