[hibernate-issues] [Hibernate-JIRA] Commented: (HHH-5188) Use provided enum type ordinal/string when reading
Stefan Larsson (JIRA)
noreply at atlassian.com
Sun Jan 16 04:07:06 EST 2011
[ http://opensource.atlassian.com/projects/hibernate/browse/HHH-5188?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=39647#action_39647 ]
Stefan Larsson commented on HHH-5188:
-------------------------------------
Replacing hibernate-core-3.6.0 of JBoss AS 6.0.0 with a patched one makes it possible to read PostgreSQL enums again.
> Use provided enum type ordinal/string when reading
> --------------------------------------------------
>
> Key: HHH-5188
> URL: http://opensource.atlassian.com/projects/hibernate/browse/HHH-5188
> Project: Hibernate Core
> Issue Type: Bug
> Components: core
> Affects Versions: 3.5.0-CR-2, 3.5.1, 3.6.0
> Reporter: Stefan Larsson
> Priority: Minor
> Attachments: EnumType.java-typeSafeNullSafeGet.patch
>
>
> When Hibernate reads a PostgreSQL enum type using ResultSet.getObject(), the JDBC driver returns a driver-specific PGObject object, which preserves both the value of the enum and its type ordinal/string. Hibernate fails with a ClassCastException when it attempts to cast the PGObject into a String in org.hibernate.type.EnumType.nullSafeGet().
> The code in org.hibernate.type.EnumType assumes that ResultSet.getObject() will either return a Number or a String, which is not true for the PostgreSQL driver. IMHO it would be better to let the JDBC driver do the conversion using ResultSet.getInt() or getString() instead.
> The attached patch allows JBoss AS 6 M3 (Hibernate 3.5.0-CR-2) to read PostgreSQL enums, using JPA, with a a Java enum annotated as @javax.persistence.Enumerated(javax.persistence.EnumType.STRING).
> Also, I believe that perhaps ignoring the given enum type causes Issue HHH-4230, where an ordinal enum was stored in character field. ResultSet.getInteger() might work for that one depending on the JDBC driver.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
More information about the hibernate-issues
mailing list