You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In JOOQ there are 2 general ways to declare the returning clause (for update/insert/delete). Those are [Insert|Update|Delete]ResultStep#returning and [Insert|Update|Delete]ResultStep#returningResult where the latter is to allow returning different record type than the one representing the table (e.g. Record1<UUID> instead of UserRecord with just one field actually present (if that's all you need)).
Currently only the first approach is supported. It would be useful to support the latter as well because it currently fails with ClassCastException at runtime. Example output: java.lang.ClassCastException: class com...model.tables.records.UserRecord cannot be cast to class org.jooq.Record1
The text was updated successfully, but these errors were encountered:
GeorgiPetkov
changed the title
Add support queries using *ResultStep#returningResult
Add support for queries using *ResultStep#returningResultMay 7, 2021
it currently fails with ClassCastException at runtime. Example output: java.lang.ClassCastException: class com...model.tables.records.UserRecord cannot be cast to class org.jooq.Record1
What is the behaviour of JOOQ in this case? Can you please provide a code sample that results in this error?
The problems is that the method ReactiveJooq#executeReturning (called by ReactiveJooq#executeReturningOne below) always creates records of table's type. In other words, the assumption that the insert/update query's generic type matches the record type of the table is incorrect when using returningResult. I've provided 2 tests showing the differences (the second one fails). I've extracted the queries into variables to emphasize on the types. Apart from the last line in the query and the map usage the tests are identical.
In JOOQ there are 2 general ways to declare the returning clause (for update/insert/delete). Those are
[Insert|Update|Delete]ResultStep#returning
and[Insert|Update|Delete]ResultStep#returningResult
where the latter is to allow returning different record type than the one representing the table (e.g.Record1<UUID>
instead ofUserRecord
with just one field actually present (if that's all you need)).Currently only the first approach is supported. It would be useful to support the latter as well because it currently fails with
ClassCastException
at runtime. Example output:java.lang.ClassCastException: class com...model.tables.records.UserRecord cannot be cast to class org.jooq.Record1
The text was updated successfully, but these errors were encountered: