-
Notifications
You must be signed in to change notification settings - Fork 368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Exception UNION could not convert type for inheritance hierarchies with JsonStringType #27
Comments
Please provide a replicating test case for this issue. Just fork the project and use only of the PostgreSQL unit tests as an example to create a new use case that demonstrates this issue. Thanks. |
Closing because no test case was provided to prove the issue. |
Finally got the time to create a reproducer. The issue is easily worked around, but I think a proper fix requires a change in Hibernate which is why I wanted you to have another look at the issue. See #109. |
Given an class hierarchy with entities B and C that both extend base class A, when C has a property mapped with
JsonStringType
, and one queries allA
usingSELECT a FROM A a
, the query fails with the following exception:The error is caused by the fact that the produced SQL query has the following format: (I slightly simplified it to only include the relevant part)
The
::uuid
cast originates fromPostgreSQL81Dialect#getSelectClauseNullString(sqlType)
, which returnsuuid
for input1111
(which isTypes.OTHER
). So it seems somehow,OTHER
is already bound touuid
, and the work around performed by Hibernate does not work anymore (a better workaround would probably be to consider the columnDefinition of the column as well).I'm uncertain whether this workaround is still required, but all new dialects (I am using the
PostgreSQL95Dialect
) still extend from thePostgreSQL81Dialect
without overridinggetSelectClauseNullString
method. Furthermore, I am aware that this issue should probably be fixed in Hibernate rather than here. This method will in fact break for all queries using a null value of a type for which its JDBC type is mapped to multiple types.Nevertheless, I've had success with mapping my JSON properties to
Types.JAVA_OBJECT
rather thanTypes.OTHER
. This type is not subject to the bug for me.Types.JAVA_OBJECT
is also the JDBC type of choice as of thePostgreSQL92Dialect
.Is there any particular reason to not switch the JDBC type of
JsonStringType
toTypes.JAVA_OBJECT
?The text was updated successfully, but these errors were encountered: