ReflectionException - foreach

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

ReflectionException - foreach

Chris P

Hello Everyone, I’m hoping someone can point me in the right direction in resolving my issue.


I have a mapper with an insert statement, that contains a foreach loop. The foreach element finds my collection (a list within the parameter being passed to the SQL Session), and defines an item:


<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")”>



I can see that it generates the prepared statement correctly, but when it goes to populate the values in the prepared statement I get the following exception:

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_ml_0' in ‘class com…’


This application is currently using an older version of myBatis, 3.2.2. Any ideas?


Thanks,


Chris

--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ReflectionException - foreach

Guy Rouillier-2
Show the entire insert statement, where you actually use the defined item "ml".
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Chris P" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 5/10/2016 9:03:05 PM
Subject: ReflectionException - foreach
 

Hello Everyone, I’m hoping someone can point me in the right direction in resolving my issue.


I have a mapper with an insert statement, that contains a foreach loop. The foreach element finds my collection (a list within the parameter being passed to the SQL Session), and defines an item:


<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")”>



I can see that it generates the prepared statement correctly, but when it goes to populate the values in the prepared statement I get the following exception:

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_ml_0' in ‘class com…’


This application is currently using an older version of myBatis, 3.2.2. Any ideas?


Thanks,


Chris

--
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].
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ReflectionException - foreach

Chris P
Here is the entire statement:

<insert id="insertMany">
INSERT INTO mytgoal.myt_measure_log (
myt_measure_key,
myt_goal_key,
myt_lkup_status_key,
outcome_numeric,
outcome_char,
target_type,

modified_by,

comments,

outcome_frequency,

outcome_intensity,

outcome_duration,

log_discriminator,

date_assessed_dt,

created_by,

created_ts

)


VALUES 

<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")">

#{ml.measureKey},

#{ml.goalKey},

#{ml.statusKey},

#{ml.outcomeNum},

#{ml.outcomeChar},

#{ml.targetType},

#{ml.modfiedBy},

#{ml.comments},

#{ml.outcomeFrequency},

#{ml.outcomeIntensity},

#{ml.outcomeDuration},

#{ml.logDiscriminator},

#{ml.dateAssessed, jdbcType=TIMESTAMP},

#{ml.createdBy},

#{ml.createdTime, jdbcType=TIMESTAMP}

</foreach>

</insert>


On Tuesday, May 10, 2016 at 10:11:25 PM UTC-4, Guy Rouillier wrote:
Show the entire insert statement, where you actually use the defined item "ml".
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Chris P" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="bf8JXsuiAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">cpast...@...>
To: "mybatis-user" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="bf8JXsuiAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...>
Sent: 5/10/2016 9:03:05 PM
Subject: ReflectionException - foreach
 

Hello Everyone, I’m hoping someone can point me in the right direction in resolving my issue.


I have a mapper with an insert statement, that contains a foreach loop. The foreach element finds my collection (a list within the parameter being passed to the SQL Session), and defines an item:


<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")”>



I can see that it generates the prepared statement correctly, but when it goes to populate the values in the prepared statement I get the following exception:

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_ml_0' in ‘class com…’


This application is currently using an older version of myBatis, 3.2.2. Any ideas?


Thanks,


Chris

--
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="bf8JXsuiAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=icon" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;"> Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=link" style="color:#4453ea" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;">www.avast.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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ReflectionException - foreach

Iwao AVE!
Hi Chris,

There were several foreach related issues in 3.2.x.
You should try upgrading to 3.4.0, 3.3.1 or 3.2.8 at least.

The snippet looks good, so if upgrading MyBatis didn't solve your problem, please create a test case like this.

Regards,
Iwao


2016-05-11 21:58 GMT+09:00 Chris P <[hidden email]>:
Here is the entire statement:

<insert id="insertMany">
INSERT INTO mytgoal.myt_measure_log (
myt_measure_key,
myt_goal_key,
myt_lkup_status_key,
outcome_numeric,
outcome_char,
target_type,

modified_by,

comments,

outcome_frequency,

outcome_intensity,

outcome_duration,

log_discriminator,

date_assessed_dt,

created_by,

created_ts

)


VALUES 

<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")">

#{ml.measureKey},

#{ml.goalKey},

#{ml.statusKey},

#{ml.outcomeNum},

#{ml.outcomeChar},

#{ml.targetType},

#{ml.modfiedBy},

#{ml.comments},

#{ml.outcomeFrequency},

#{ml.outcomeIntensity},

#{ml.outcomeDuration},

#{ml.logDiscriminator},

#{ml.dateAssessed, jdbcType=TIMESTAMP},

#{ml.createdBy},

#{ml.createdTime, jdbcType=TIMESTAMP}

</foreach>

</insert>


On Tuesday, May 10, 2016 at 10:11:25 PM UTC-4, Guy Rouillier wrote:
Show the entire insert statement, where you actually use the defined item "ml".
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Chris P" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 5/10/2016 9:03:05 PM
Subject: ReflectionException - foreach
 

Hello Everyone, I’m hoping someone can point me in the right direction in resolving my issue.


I have a mapper with an insert statement, that contains a foreach loop. The foreach element finds my collection (a list within the parameter being passed to the SQL Session), and defines an item:


<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")”>



I can see that it generates the prepared statement correctly, but when it goes to populate the values in the prepared statement I get the following exception:

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_ml_0' in ‘class com…’


This application is currently using an older version of myBatis, 3.2.2. Any ideas?


Thanks,


Chris

--
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].
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.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].
For more options, visit https://groups.google.com/d/optout.

--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ReflectionException - foreach

Chris P
Got it! Thanks so much for the help everyone...

After upgrading a few versions (up to 3.3.1), I got a different error that showed me I had a typo.
#{ml.modfiedBy} should be #{ml.modifiedBy}
I guess since it couldn't find the field within the collection object, the exception was being thrown at the parameterType level for the query. In 3.3.1 the error is more explicit. 

I was able to rollback to the current project version of myBatis and the query completes successfully. Sorry for wasting your time with something so trivial, and I appreciate the help.

On Wednesday, May 11, 2016 at 9:27:48 AM UTC-4, Iwao AVE! wrote:
Hi Chris,

There were several foreach related issues in 3.2.x.
You should try upgrading to 3.4.0, 3.3.1 or 3.2.8 at least.

The snippet looks good, so if upgrading MyBatis didn't solve your problem, please create a test case like this.
<a href="https://github.com/harawata/mybatis-issues/tree/master/gh-483" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fgh-483\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHrjsc3FNK7FdDJ9-l4yl9RptZBA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fgh-483\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEHrjsc3FNK7FdDJ9-l4yl9RptZBA&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/gh-483

Regards,
Iwao


2016-05-11 21:58 GMT+09:00 Chris P <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="FgC9SbTHAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">cpast...@...>:
Here is the entire statement:

<insert id="insertMany">
INSERT INTO mytgoal.myt_measure_log (
myt_measure_key,
myt_goal_key,
myt_lkup_status_key,
outcome_numeric,
outcome_char,
target_type,

modified_by,

comments,

outcome_frequency,

outcome_intensity,

outcome_duration,

log_discriminator,

date_assessed_dt,

created_by,

created_ts

)


VALUES 

<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")">

#{ml.measureKey},

#{ml.goalKey},

#{ml.statusKey},

#{ml.outcomeNum},

#{ml.outcomeChar},

#{ml.targetType},

#{ml.modfiedBy},

#{ml.comments},

#{ml.outcomeFrequency},

#{ml.outcomeIntensity},

#{ml.outcomeDuration},

#{ml.logDiscriminator},

#{ml.dateAssessed, jdbcType=TIMESTAMP},

#{ml.createdBy},

#{ml.createdTime, jdbcType=TIMESTAMP}

</foreach>

</insert>


On Tuesday, May 10, 2016 at 10:11:25 PM UTC-4, Guy Rouillier wrote:
Show the entire insert statement, where you actually use the defined item "ml".
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Chris P" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 5/10/2016 9:03:05 PM
Subject: ReflectionException - foreach
 

Hello Everyone, I’m hoping someone can point me in the right direction in resolving my issue.


I have a mapper with an insert statement, that contains a foreach loop. The foreach element finds my collection (a list within the parameter being passed to the SQL Session), and defines an item:


<foreach collection="measureLogs" item="ml" open="(" separator="),(" close=")”>



I can see that it generates the prepared statement correctly, but when it goes to populate the values in the prepared statement I get the following exception:

Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named '__frch_ml_0' in ‘class com…’


This application is currently using an older version of myBatis, 3.2.2. Any ideas?


Thanks,


Chris

--
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 mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

<a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=icon" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dicon\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGdgn6XHtGdGX0_ztl7zsznn9rycA&#39;;return true;"> Virus-free. <a href="https://www.avast.com/sig-email?utm_medium=email&amp;utm_source=link&amp;utm_campaign=sig-email&amp;utm_content=emailclient&amp;utm_term=link" style="color:#4453ea" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwww.avast.com%2Fsig-email%3Futm_medium%3Demail%26utm_source%3Dlink%26utm_campaign%3Dsig-email%26utm_content%3Demailclient%26utm_term%3Dlink\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEBTW1oVO7X9WxlATGseHnM8Gn-HQ&#39;;return true;">www.avast.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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="FgC9SbTHAwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybatis-user...@googlegroups.com.
For more options, visit <a href="https://groups.google.com/d/optout" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/optout&#39;;return true;">https://groups.google.com/d/optout.

--
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].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: ReflectionException - foreach

Iwao AVE!
No problem ;-)

2016-05-11 23:21 GMT+09:00 Chris P <[hidden email]>:
Got it! Thanks so much for the help everyone...

After upgrading a few versions (up to 3.3.1), I got a different error that showed me I had a typo.
#{ml.modfiedBy} should be #{ml.modifiedBy}
I guess since it couldn't find the field within the collection object, the exception was being thrown at the parameterType level for the query. In 3.3.1 the error is more explicit. 

I was able to rollback to the current project version of myBatis and the query completes successfully. Sorry for wasting your time with something so trivial, and I appreciate the help.

--
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].
For more options, visit https://groups.google.com/d/optout.