Issue Type: Bug Bug
Assignee: Unassigned
Created: 26/Jun/12 1:53 PM
Description:

I have a case in which my sql-delete needs to update two tables (set delete flag & date on ENTITY table, set date on CHANNEL_MARK).

<sql-delete check="none">declare @entity_id int = ?, @update_date date = getdate(); update ENTITY set DELETED = 1, UPDATE_DATE = @update_date where ENTITY_ID = @entity_id; update CHANNEL_MARK set LAST_UPDATE_DATE = @update_date where CHANNEL_ID in (select CHANNEL_ID from ENTITY where ENTITY_ID = @entity_id);</sql-delete>

Even though I've set check="none", BatchingBatcher.java still calls checkRowCounts which causes the following exception:

2012-06-26 17:58:30,798 | WARN | org.hibernate.jdbc.AbstractBatcher | accountId=6 email=jchapman@trionworlds.com sessionId=6F52E08F22400E7BDB5B2F5AEC961098 | JDBC driver did not return the expected number of row counts
2012-06-26 18:36:21,694 | ERROR | org.hibernate.jdbc.AbstractBatcher | accountId=6 email=jchapman@trionworlds.com sessionId=6F52E08F22400E7BDB5B2F5AEC961098 | Exception executing batch:
java.lang.NullPointerException
at org.hibernate.jdbc.BatchingBatcher.checkRowCounts(BatchingBatcher.java:90)
at org.hibernate.jdbc.BatchingBatcher.doExecuteBatch(BatchingBatcher.java:70)
at org.hibernate.jdbc.AbstractBatcher.executeBatch(AbstractBatcher.java:268)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:114)
at org.hibernate.jdbc.AbstractBatcher.prepareStatement(AbstractBatcher.java:109)
at org.hibernate.jdbc.AbstractBatcher.prepareBatchStatement(AbstractBatcher.java:244)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2650)
at org.hibernate.persister.entity.AbstractEntityPersister.delete(AbstractEntityPersister.java:2895)
at org.hibernate.action.EntityDeleteAction.execute(EntityDeleteAction.java:97)
at org.hibernate.engine.ActionQueue.execute(ActionQueue.java:267)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:259)
at org.hibernate.engine.ActionQueue.executeActions(ActionQueue.java:183)
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:1206)
at org.hibernate.impl.SessionImpl.managedFlush(SessionImpl.java:375)
at org.hibernate.transaction.JDBCTransaction.commit(JDBCTransaction.java:137)

I'm using NOCOUNT to work around the problem:
<sql-delete check="none">set nocount on; declare @entity_id int = ?, @update_date date = getdate(); update ENTITY set DELETED = 1, UPDATE_DATE = @update_date where ENTITY_ID = @entity_id; set nocount off; update CHANNEL_MARK set LAST_UPDATE_DATE = @update_date where CHANNEL_ID in (select CHANNEL_ID from ENTITY where ENTITY_ID = @entity_id);</sql-delete>

Environment: 3.6.0
Project: Hibernate ORM
Priority: Minor Minor
Reporter: Jeremy Chapman
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators.
For more information on JIRA, see: http://www.atlassian.com/software/jira