Bug #33966 | Alias are ignored on a select when using a combination of Hibernate/mysql 5.1 | ||
---|---|---|---|
Submitted: | 21 Jan 2008 21:12 | Modified: | 25 Jan 2008 16:14 |
Reporter: | lkajsdlkfj lkajsdlfksdjf | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | Connector / J | Severity: | S3 (Non-critical) |
Version: | 5.1.22 | OS: | Windows (XP) |
Assigned to: | CPU Architecture: | Any | |
Tags: | alias, hibernate |
[21 Jan 2008 21:12]
lkajsdlkfj lkajsdlfksdjf
[22 Jan 2008 20:54]
Sébastien Fournier
Meet the same problem few days ago, and finally read from the driver's doc that it is not a bug : jdbc driver 5.0.4 is the last version before a change on aliased column name return by jdbc driver, this is the reason why it worked when you tried this older version (try 5.0.5 or > and you should have the same trouble as with the latest version). To solve it, in your driver connection url, add the option "useOldAliasMetadataBehavior" with value "true" (before 5.0.5, it was the default value, which has been changed to "false" from 5.0.5) -> ...?useOldAliasMetadataBehavior=true More precision about jdbc driver parameters at : http://dev.mysql.com/doc/refman/5.1/en/connector-j-reference-configuration-properties.html
[25 Jan 2008 16:14]
Tonci Grgin
Hi Yev and thanks for your report. It is as Sébastien said, to get as close as possible to Java specs we introduced this change in behavior. Sébastien, thanks for your help and thanks to both of you for using MySQL.
[18 Mar 2010 18:18]
Dave Meyer
A better solution would be to use getColumnLabel(). According to the jdk api: "Gets the designated column's suggested title for use in printouts and displays. The suggested title is usually specified by the SQL AS clause. If a SQL AS is not specified, the value returned from getColumnLabel will be the same as the value returned by the getColumnName method. (http://java.sun.com/javase/6/docs/api/java/sql/ResultSetMetaData.html) " This seems like a more elegant solution as long as you have access to the middleware code calling this method (in the case of hibernate, you would need to wait until they fix their code). This will make the code compatible with any version of the driver.