mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

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

mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

喻奇

1584418780129.jpg


just like pic show

,I have difine RecordInfo<T>  class , and i Return the RecordInfo<RiskInfo>  in queryRiskList function.but i use @Result(property = "content.appId", column = "app_id")  to map RiskInfo class Feild appId to database column app_id when I run  this function,I get this error "org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'",  but I define the  type of content as RiskInfo in Function return params, why mybatis can not
 discern the RiskInfo class,how could I solve this error?

--
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/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

Guy Rouillier-2
Why is your map mapping appId twice, once for appInfo.appId and again for content.appId?

To answer your question, this appears to be the classic problem of type erasure with generics:


--
Guy Rouillier

On 3/17/2020 12:47:11 AM, "喻奇" <[hidden email]> wrote:

1584418780129.jpg


just like pic show

,I have difine RecordInfo<T>  class , and i Return the RecordInfo<RiskInfo>  in queryRiskList function.but i use @Result(property = "content.appId", column = "app_id")  to map RiskInfo class Feild appId to database column app_id when I run  this function,I get this error "org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'",  but I define the  type of content as RiskInfo in Function return params, why mybatis can not
 discern the RiskInfo class,how could I solve this error?

--
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/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%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/em6bb5d118-65a0-427d-8ca6-455b1cc3920c%40asus.
Reply | Threaded
Open this post in threaded view
|

Re: mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

喻奇


在 2020年3月17日星期二 UTC+8下午4:42:54,Guy Rouillier写道:
Why is your map mapping appId twice, once for appInfo.appId and again for content.appId?

To answer your question, this appears to be the classic problem of type erasure with generics:

<a href="https://www.baeldung.com/java-type-erasure" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.baeldung.com%2Fjava-type-erasure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyrtj0p2mja09QOUsZWoG-sa4_rQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.baeldung.com%2Fjava-type-erasure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyrtj0p2mja09QOUsZWoG-sa4_rQ&#39;;return true;">https://www.baeldung.com/java-type-erasure

--
Guy Rouillier

On 3/17/2020 12:47:11 AM, "喻奇" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BvJ-rRmBAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">yich...@...> wrote:

1584418780129.jpg


just like pic show

,I have difine RecordInfo<T>  class , and i Return the RecordInfo<RiskInfo>  in queryRiskList function.but i use @Result(property = "content.appId", column = "app_id")  to map RiskInfo class Feild appId to database column app_id when I run  this function,I get this error "org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'",  but I define the  type of content as RiskInfo in Function return params, why mybatis can not
 <a href="http://www.baidu.com/link?url=gvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW" style="color:rgb(51,51,51);font-family:arial" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Dgvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBjf7t1tzvwpb-lFouzVT8oGQEnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Dgvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBjf7t1tzvwpb-lFouzVT8oGQEnQ&#39;;return true;">discern the RiskInfo class,how could I solve this error?

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="BvJ-rRmBAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com.
hi,thanks for your reply,mapping appId twice is not question that i ask,my question neither is java Type Erasure ,i wonder  “use annotation @Result can not map custom Java generic that already define the class Type in return param

--
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/ec371a86-5f03-48b6-8c89-456c62239f55%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re[2]: mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

Guy Rouillier-2
>> my question neither is java Type Erasure ,i wonder  “use annotation @Result can not map custom Java generic that already define the class Type in return param

Well, that may not be the question you asked, but appears to be the situation you face:

"org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'"

If you are able to post a *simple* example, I'm willing to take a look, since we are on coronavirus isolation.  From what you have provided, I cannot see how "content" is defined.

--
Guy Rouillier

On 3/19/2020 3:41:37 AM, "喻奇" <[hidden email]> wrote:



在 2020年3月17日星期二 UTC+8下午4:42:54,Guy Rouillier写道:
Why is your map mapping appId twice, once for appInfo.appId and again for content.appId?

To answer your question, this appears to be the classic problem of type erasure with generics:


--
Guy Rouillier

On 3/17/2020 12:47:11 AM, "喻奇" <[hidden email]> wrote:

1584418780129.jpg


just like pic show

,I have difine RecordInfo<T>  class , and i Return the RecordInfo<RiskInfo>  in queryRiskList function.but i use @Result(property = "content.appId", column = "app_id")  to map RiskInfo class Feild appId to database column app_id when I run  this function,I get this error "org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'",  but I define the  type of content as RiskInfo in Function return params, why mybatis can not
 discern the RiskInfo class,how could I solve this error?

--
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 mybati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com.
hi,thanks for your reply,mapping appId twice is not question that i ask,my question neither is java Type Erasure ,i wonder  “use annotation @Result can not map custom Java generic that already define the class Type in return param

--
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/ec371a86-5f03-48b6-8c89-456c62239f55%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/em650f1b9c-9dad-4986-b16e-e4b63bdaeb8c%40asus.
Reply | Threaded
Open this post in threaded view
|

Re: Re[2]: mybatis 3.4.4 use annotation @Result can not map custom Java generic that already define the class Type in return param

喻奇

1585194816723.jpg

as the pic show,content is defined as  Java generic, but at the function return param "RecordInfo<RiskInfo>" ,I already define java generic T as  "RiskInfo.class",  so why "use annotation @Result can not map custom Java generic that already define the class Type in return param




在 2020年3月20日星期五 UTC+8下午1:11:51,Guy Rouillier写道:
>> my question neither is java Type Erasure ,i wonder  “use annotation @Result can not map custom Java generic that already define the class Type in return param

Well, that may not be the question you asked, but appears to be the situation you face:

"org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'"

If you are able to post a *simple* example, I'm willing to take a look, since we are on coronavirus isolation.  From what you have provided, I cannot see how "content" is defined.

--
Guy Rouillier

On 3/19/2020 3:41:37 AM, "喻奇" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="5qKyHH6UAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">yich...@...> wrote:



在 2020年3月17日星期二 UTC+8下午4:42:54,Guy Rouillier写道:
Why is your map mapping appId twice, once for appInfo.appId and again for content.appId?

To answer your question, this appears to be the classic problem of type erasure with generics:

<a href="https://www.baeldung.com/java-type-erasure" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.baeldung.com%2Fjava-type-erasure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyrtj0p2mja09QOUsZWoG-sa4_rQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.baeldung.com%2Fjava-type-erasure\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEyrtj0p2mja09QOUsZWoG-sa4_rQ&#39;;return true;">https://www.baeldung.com/java-type-erasure

--
Guy Rouillier

On 3/17/2020 12:47:11 AM, "喻奇" <[hidden email]> wrote:

1584418780129.jpg


just like pic show

,I have difine RecordInfo<T>  class , and i Return the RecordInfo<RiskInfo>  in queryRiskList function.but i use @Result(property = "content.appId", column = "app_id")  to map RiskInfo class Feild appId to database column app_id when I run  this function,I get this error "org.apache.ibatis.reflection.ReflectionException: There is no setter for property named 'appId' in 'class java.lang.Object'",  but I define the  type of content as RiskInfo in Function return params, why mybatis can not
 <a href="http://www.baidu.com/link?url=gvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW" style="color:rgb(51,51,51);font-family:arial" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Dgvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBjf7t1tzvwpb-lFouzVT8oGQEnQ&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fwww.baidu.com%2Flink%3Furl%3Dgvo1MW04oADQNdLR9iQKfacq46bhJ-4iaY1cIpygcKJhj-WYfSKG_Osa4kNgLrLwb_t4IXXnDEKCYpNg5folT3wUT3vxTsLyGZxhcVHgoOW\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGBjf7t1tzvwpb-lFouzVT8oGQEnQ&#39;;return true;">discern the RiskInfo class,how could I solve this error?

--
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 <a href="https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium=email&amp;utm_source=footer" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/054182d4-dc96-4dbc-beeb-4f7a8e2ba020%40googlegroups.com.
hi,thanks for your reply,mapping appId twice is not question that i ask,my question neither is java Type Erasure ,i wonder  “use annotation @Result can not map custom Java generic that already define the class Type in return param

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="5qKyHH6UAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/mybatis-user/ec371a86-5f03-48b6-8c89-456c62239f55%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/ec371a86-5f03-48b6-8c89-456c62239f55%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/mybatis-user/ec371a86-5f03-48b6-8c89-456c62239f55%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/mybatis-user/ec371a86-5f03-48b6-8c89-456c62239f55%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/5bf5d401-f6a2-4ffc-b98f-1cd5a3821f51%40googlegroups.com.