db-ojb-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Matthew Baird" <Matthew.Ba...@motiva.com>
Subject RE: [Patch] o.a.o.b.util.batch.PreparedStatementInvocationHandler
Date Mon, 28 Jul 2003 01:16:29 GMT
i found this last week and have the fix in a changelist at work. I will update monday morning.

	-----Original Message----- 
	From: Ron Gallagher [mailto:rgallagh@bellsouth.net] 
	Sent: Sun 7/27/2003 6:17 PM 
	To: ojb-dev@db.apache.org 
	Cc: 
	Subject: [Patch] o.a.o.b.util.batch.PreparedStatementInvocationHandler
	
	

	All --
	
	I encountered a problem with the doExecute method in
	org.apache.ojb.broker.util.batch.PreparedStatementInvocationHandler. 
	
	The problem manifested itself in the following 'if' condition:
	
	if ((Method) _methods.get(i) == ADD_BATCH )
	{
	    /**
	     * we invoke on the platform and pass the stmt as an arg.
	     */
	    ((Method) _methods.get(i)).invoke(m_platform, new Object[] {stmt});
	}
	else
	{
	    ((Method) _methods.get(i)).invoke(stmt, (Object[]) _params.get(i));
	}
	
	When I ran this in my environment (jdk 1.3.1, oracle9i), the 'Method' object that was returned
by '_method.get(i)' was indeed the 'ADD_BATCH' method.  However, the expression "((Method)
_methods.get(i) == ADD_BATCH )" did not evaluate to true.  As a result, the 'Method' was invoked
on the 'stmt' variable causing an exception.  I believe it was an IllegalAccessException.
 The details are on my system at work.  I can provide the specifics once I get into the office
on Monday.
	
	Changing the expression mentioned earlier to use the ".equals" method fixed the problem.
 The updated code looks like this:
	if (((Method) _methods.get(i)).equals(ADD_BATCH))
	{
	    /**
	     * we invoke on the platform and pass the stmt as an arg.
	     */
	    ((Method) _methods.get(i)).invoke(m_platform, new Object[] {stmt});
	}
	else
	{
	    ((Method) _methods.get(i)).invoke(stmt, (Object[]) _params.get(i));
	}
	
	Attached is an update to o.a.o.b.util.batch.PreparedStatementInvocationHandler to fix this
problem. I also changed the loop in which this code occurs to get the 'Method' from the _methods
ArrayList once, at the beginning of the loop.
	
	

Mime
View raw message