| Bug #25644 | NullPointerException in com.mysql.jdbc.CallableStatement | ||
|---|---|---|---|
| Submitted: | 16 Jan 2007 9:58 | Modified: | 25 Jan 2007 9:50 |
| Reporter: | Lars Borg | Email Updates: | |
| Status: | Verified | Impact on me: | |
| Category: | Connector / J | Severity: | S4 (Feature request) |
| Version: | 5.0.4 | OS: | Windows (Windows XP) |
| Assigned to: | Assigned Account | CPU Architecture: | Any |
[16 Jan 2007 9:58]
Lars Borg
[16 Jan 2007 11:51]
Lars Borg
Further testing revealed that this bug occurs only when Hibernate is used in a certain way...
I'm calling the SP like this, since that is the way they say it should be done:
<sql-query name="getAllVersionsFunc" callable="true">
<return alias="v" class="xxxx.data.dto.Version">
<return-property name="id" column="ID"/>
<return-property name="someValue" column="someValue"/>
<return-property name="version" column="ver"/>
</return>
{ ? = CALL getAllVersionsProc() }
</sql-query>
I saw that this statement was translated by the connector into:
SELECT getAllVersionsProc()
... and that's a bit strange... it believes it's a function...
So, I changed the original statement in the <sql-query> to just:
CALL getAllVersionsProc()
The result was very satisfying, since all worked just fine.
Also "SELECT getAllVersionsProc()" got a correct answer... "FUNCTION does not exist"
This means that the bug ONLY occurs when the call comes from Hibernate like this:
{ ? = CALL getAllVersionsProc() }
Maybe this is a no-bug candidate, but CallableStatement should definitly behave in a better way in this strange situation.
My suggested fix gives the correct answer "FUNCTION does not exist"
But does this mean that there is a bug in the above mentioned translator? Well, I leave that up to you...
[18 Jan 2007 8:33]
Tonci Grgin
Hi Lars and thanks for your report. >But does this mean that there is a bug in the above mentioned translator? Well, I leave that up to you... It should be fairly easy to check that. Just write pure test case (no Hibernate) and see if error occurs. I'm waiting on your results.
[18 Jan 2007 15:03]
Mark Matthews
> This means that the bug ONLY occurs when the call comes from Hibernate like > this:
> { ? = CALL getAllVersionsProc() }
You're telling the JDBC driver that this is a function when you use that syntax. I agree we shouldn't throw an NPE in this case (so we'll fix that), but you're using the API incorrectly.
(it's not really clear prior to JDBC-4.0 from the documentation that Sun ships that this is the case, but the escape syntax is based upon ODBC, and it's clear there that you're calling a function. Also note that DatabaseMetaData has methods that will return information for stored functions, and that syntax is how you call them.)
[22 Jan 2007 9:30]
Lars Borg
I just tested calling "{ ? = CALL getAllversionsProc() }" without Hibernate and that generates no NPE, it just says "FUNCTION asj.getAllVersionsProc does not exist".
But when I'm calling the same statement using Hibernate, I get the NPE.
[25 Jan 2007 9:50]
Tonci Grgin
I am setting this report to "Verified" on the basis of Mark's remark: "I agree we shouldn't throw an NPE in this case (so we'll fix that), but you're using the API incorrectly."
