unexpected row count and selects return no rows

2,271 views
Skip to first unread message

Phil Cruz

unread,
Sep 19, 2013, 2:01:43 PM9/19/13
to cf-or...@googlegroups.com
I have a CF10 app using cf-orm. I have auto flushatrequestend = false, so in the orm entities I have a save() method like

public function save()
{
var trans = OrmGetSession().beginTransaction();
try 
{
     EntitySave(this);
     trans.commit();
}
catch(Any exc)
{
     trans.rollback();
     rethrow;
}
}

Intermittently, I'll get an error "batch update returned unexpected row count from update". Things will be running fine, then I might get several of these over the course of 20-30 minutes, then back to normal. 

From google searching on that error, I gather it's a hibernate error but I'm not sure why it's happening and how to resolve.

Also, while digging into this I was looking at the fusion reactor jdbc logs. I can see the update query that runs and it looks fine. But then looking at some of the queries running before that update I see a bunch of selects that FR says return 0 rows but the should always return rows. For example, a simple query like

select ordertype0_.orderTypeID as orderTyp1_14_0_, ordertype0_.name as name14_0_, ordertype0_.sortOrder as sortOrder14_0_ from orderTypes ordertype0_ where ordertype0_.orderTypeID=4

Why would cf-orm return 0 rows??

-Phil


struct

Cause:  
	[struct]
	Message: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
	StackTrace: org.hibernate.StaleStateException: Batch update returned unexpected row count from update [0]; actual row count: 0; expected: 1
		at org.hibernate.jdbc.Expectations$BasicExpectation.checkBatched(Expectations.java:85)
		at org.hibernate.jdbc.Expectations$BasicExpectation.verifyOutcome(Expectations.java:70)
		at org.hibernate.jdbc.NonBatchingBatcher.addToBatch(NonBatchingBatcher.java:47)
		at org.hibernate.persister.entity.AbstractEntityPersister.update(AbstractEntityPersister.java:2574)
		at org.hibernate.persister.entity.AbstractEntityPersister.updateOrInsert(Abst

Brian Kotek

unread,
Sep 19, 2013, 3:08:39 PM9/19/13
to cf-or...@googlegroups.com
No idea if this has anything to do with it, but why are you manually using Hibernate session transactions instead of just using CF's transaction?


--
You received this message because you are subscribed to the Google Groups "cf-orm-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cf-orm-dev+...@googlegroups.com.
To post to this group, send email to cf-or...@googlegroups.com.
Visit this group at http://groups.google.com/group/cf-orm-dev.
For more options, visit https://groups.google.com/groups/opt_out.

Cameron Childress

unread,
Sep 19, 2013, 3:17:25 PM9/19/13
to cf-or...@googlegroups.com
On Thu, Sep 19, 2013 at 2:01 PM, Phil Cruz wrote:
Intermittently, I'll get an error "batch update returned unexpected row count from update". Things will be running fine, then I might get several of these over the course of 20-30 minutes, then back to normal. 

I have seen this error before and every time it's been due to something subtle that I did wrong in an ORM entity. I can't remember exactly what it was that caused it though. Trying to remember.

Not this?

-Cameron 

--
Cameron Childress
--
p:   678.637.5072
im: cameroncf

Phil Cruz

unread,
Sep 20, 2013, 4:16:07 PM9/20/13
to cf-or...@googlegroups.com

Phil Cruz

unread,
Sep 20, 2013, 4:19:08 PM9/20/13
to cf-or...@googlegroups.com
I don't think it's that because if it were it would error all the time. It works 99.99% of the time. In fact, right now I have one server throwing the error but another server in the cluster is not. It's really strange.

-Phil

Phil Cruz

unread,
Sep 20, 2013, 4:19:19 PM9/20/13
to cf-or...@googlegroups.com
I don't think it's that because if it were it would error all the time. It works 99.99% of the time. In fact, right now I have one server throwing the error but another server in the cluster is not. It's really strange.

-Phil

On Thursday, September 19, 2013 12:17:25 PM UTC-7, Cameron Childress wrote:

Phil Cruz

unread,
Sep 24, 2013, 6:05:47 PM9/24/13
to cf-or...@googlegroups.com
I think I found the issue. I came across this article http://blog.grogscave.net/2010/12/sql-server-no-count-and-hibernate.html which talks about the problem. I looked at some older templates in the app that do inserts like

<cfquery name="putUser" datasource="#dsn#">
      SET NOCOUNT ON
         INSERT INTO USERS (username, email)
         VALUES   
            (<cfqueryparam cfsqltype="CF_SQL_CHAR" value="#usersname#">,
             <cfqueryparam cfsqltype="CF_SQL_CHAR" value="#email#"> )
      SELECT @@Identity AS newId      
      SET NOCOUNT OFF   
   </cfquery>

which shouldn't be a problem but I noticed one template inadvertently finished with SET NOCOUNT ON instead of SET NOCOUNT OFF. I removed all the SET NOCOUNTs and changed to using the generatedKey property of cfquery to get the last ID. I have yet to get the error since making the change so I'm hoping that's it. (Though it only happened intermittently so I'll have to wait a few more days before I feel like I'm really out of the woods.)

Thanks,
Phil
Reply all
Reply to author
Forward
0 new messages