org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4 Error creating lazy proxy

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4 Error creating lazy proxy

郭大鹏
Machine translation:
When I was testing fetchType="lazy", Error creating lazy Proxy appeared.
I don't know if I'm missing something.
I use a org org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
After investigation, I found that mybatis fixed this problem when it was 3.5.0, but Now I'm using 3.5.6. I don't know why this problem is happening to me.
If you can confirm that there is no such problem on 3.5.6, I hope you can tell me and I will try to solve it by myself. I'm not sure if It's just me.

This is a demo of the code I'm testing
https://github.com/GuoDapeng/mybatis-demo

Here is the database file
doc/sql/database.sql

Here's another test
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

原文:
我在测试 fetchType="lazy" 的时候,出现了 Error creating lazy proxy。
我不清楚是不是我忽略了什么。
我使用的是 org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
我调查得知,mybatis 3.5.0 的时候修复过这个问题,我现在用的是 3.5.6。我不知道这个问题为啥发生在我身上。
如果能确认 3.5.6 是没有这个问题的,希望能告诉我,我尝试自己解决。我现在不确定是不是只有我出现了问题。

这是我测试代码的demo
https://github.com/GuoDapeng/mybatis-demo

这里有数据库文件
doc/sql/database.sql

这里又一个测试
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/d392bad0-a6da-4764-a664-ded269cd59e1n%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4 Error creating lazy proxy

Iwao AVE!
Hello,

The error message says 'UserBase is final'.
To achieve lazy-loading, MyBatis creates a dynamic proxy of `UserBase` class, so `UserBase` has to be non-final [1].
Replacing `data class UserBase` to `open class UserBase` seems to fix the problem.

[1] https://stackoverflow.com/q/16437323/1261766

Regards,
Iwao

On Tue, Dec 29, 2020 at 8:34 PM 郭大鹏 <[hidden email]> wrote:
Machine translation:
When I was testing fetchType="lazy", Error creating lazy Proxy appeared.
I don't know if I'm missing something.
I use a org org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
After investigation, I found that mybatis fixed this problem when it was 3.5.0, but Now I'm using 3.5.6. I don't know why this problem is happening to me.
If you can confirm that there is no such problem on 3.5.6, I hope you can tell me and I will try to solve it by myself. I'm not sure if It's just me.

This is a demo of the code I'm testing
https://github.com/GuoDapeng/mybatis-demo

Here is the database file
doc/sql/database.sql

Here's another test
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

原文:
我在测试 fetchType="lazy" 的时候,出现了 Error creating lazy proxy。
我不清楚是不是我忽略了什么。
我使用的是 org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
我调查得知,mybatis 3.5.0 的时候修复过这个问题,我现在用的是 3.5.6。我不知道这个问题为啥发生在我身上。
如果能确认 3.5.6 是没有这个问题的,希望能告诉我,我尝试自己解决。我现在不确定是不是只有我出现了问题。

这是我测试代码的demo

这里有数据库文件
doc/sql/database.sql

这里又一个测试
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/d392bad0-a6da-4764-a664-ded269cd59e1n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/CA%2Buep2T%3DMwaTNCUUBFBsOvfa004iOm9JsTvPRWnE9FLYTJdHaQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4 Error creating lazy proxy

郭大鹏
machine translation:
Thank you very much, your ideas helped me. I now use the kotlin All-open compiler plugin to solve the problem I encountered. I have pushed the complete code to GitHub.

原文:
非常感谢,你的思路帮助了我。我现在通过 kotlin All-open compiler plugin 解决了我遇到的问题。我已经把完整的代码推送到 GitHub 了。


kotlin-allopen.png
在2021年1月2日星期六 UTC+8 下午10:02:16<Iwao AVE!> 写道:
Hello,

The error message says 'UserBase is final'.
To achieve lazy-loading, MyBatis creates a dynamic proxy of `UserBase` class, so `UserBase` has to be non-final [1].
Replacing `data class UserBase` to `open class UserBase` seems to fix the problem.

[1] https://stackoverflow.com/q/16437323/1261766

Regards,
Iwao

On Tue, Dec 29, 2020 at 8:34 PM 郭大鹏 <[hidden email]> wrote:
Machine translation:
When I was testing fetchType="lazy", Error creating lazy Proxy appeared.
I don't know if I'm missing something.
I use a org org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
After investigation, I found that mybatis fixed this problem when it was 3.5.0, but Now I'm using 3.5.6. I don't know why this problem is happening to me.
If you can confirm that there is no such problem on 3.5.6, I hope you can tell me and I will try to solve it by myself. I'm not sure if It's just me.

This is a demo of the code I'm testing
https://github.com/GuoDapeng/mybatis-demo

Here is the database file
doc/sql/database.sql

Here's another test
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

原文:
我在测试 fetchType="lazy" 的时候,出现了 Error creating lazy proxy。
我不清楚是不是我忽略了什么。
我使用的是 org.mybatis.spring.boot:mybatis-spring-boot-starter:2.1.4
我调查得知,mybatis 3.5.0 的时候修复过这个问题,我现在用的是 3.5.6。我不知道这个问题为啥发生在我身上。
如果能确认 3.5.6 是没有这个问题的,希望能告诉我,我尝试自己解决。我现在不确定是不是只有我出现了问题。

这是我测试代码的demo

这里有数据库文件
doc/sql/database.sql

这里又一个测试
src/test/kotlin/icu/guodapeng/mybatisdemo/domain/UserRolesTests.kt

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/d392bad0-a6da-4764-a664-ded269cd59e1n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "mybatis-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/724ee09b-8ce6-457b-b89a-5068e9b88cabn%40googlegroups.com.