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
Create a record type and map to it via a constructorresultMap, as above.
Expected result
The default record constructor would be found and linked.
Actual result
The default record constructor is not found due to the java type of the ResultMapping being java.lang.Object.
Workaround
Define the javaType for the constructor args. This was not necessary in version 3.5.9.
The text was updated successfully, but these errors were encountered:
jdmichal
changed the title
Regression: Constructor args fails on record / immutable types
Regression: Constructor args fails on record types
Mar 7, 2023
It appears that this is a duplicate of the closed #2803. However, it appears the PR that closed that issue is being withdrawn. So perhaps having this new issue open or closing this and reopening 2803 is appropriate.
As mentioned by @tzie0062 in that issue, this is a regression from 3.5.9 to 3.5.11. Some explanation seems in order for why this regression is taking place in a patch release, regardless of the attempt of #2804 to fix it.
It is the same issue as #2803 .
Here is the background.
It worked in 3.5.9 because the value was recognized as a writable property (which was clearly wrong).
It caused a problem with auto-mapping ( #2195 ), so we fixed it in 3.5.10.
As a result, value is no longer recognized as a writable property.
Now, as documented, in constructor mapping, javaType is required when there is no (writable) property with the same name and type.
This is why your result map stopped working in 3.5.10+ (it may work in 3.5.12, but it is just another 'accident' 😣 and we will release 3.5.13 ASAP).
It is unfortunate that it accidentally worked in ≤ 3.5.9 and I apologize for the confusion, but the right solution to your problem is to specify javaType instead of name.
MyBatis version
3.5.11 via mybatis-spring-boot-starter 2.3.0
Regression from 3.5.9 via mybatis-spring-boot-starter 2.2.2
Database vendor and version
PostgreSQL 14.x
Test case or example project
Steps to reproduce
record
type and map to it via aconstructor
resultMap
, as above.Expected result
The default
record
constructor would be found and linked.Actual result
The default
record
constructor is not found due to the java type of theResultMapping
beingjava.lang.Object
.Workaround
Define the
javaType
for the constructor args. This was not necessary in version 3.5.9.The text was updated successfully, but these errors were encountered: