Type handler breaking functionality in <collection>

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

Type handler breaking functionality in <collection>

Pawel Zmarlicki-2
I'm using MyBatis 3.3.1 with MyBatis-Spring 3.3.1.

I have a result map, which includes the following:
  <collection ofType="CollectionElementType" property="widgets" column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}"  select="selectCollectionElements">
    <id property="column1" column="COLUMN1" />
    <id property="column2" column="COLUMN2" />
    <id property="column3" column="COLUMN3" />
  </collection>    

COLUMN2 is a String column, which requires a type handler to change the text to uppercase.  This type handler is defined inside the element typeHandlers in the mapper configuration file.  

Apparently the type handler is invoked before the key values for selectCollectionElements are constructed, which results in values not matching the database table, which in turn prevents the corresponding rows from being retrieved.

If I disable the type handler, the list in property widgets is correctly populated with matching elements fetched by selectCollectionElements, but I must then use custom code to apply logic in type handler to each element of the list.

When defining the composite key column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}", is there a way to either disable the custom type handler just for the purposes of building the key to be used for selectCollectionElements?  If not, can an alternate type handler be specified just for COLUMN2 in this key?

--
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: Type handler breaking functionality in <collection>

Guy Rouillier-2
What happens if you remove your type handler from the <typehandlers> element in the config XML and instead add it just to the  <id> element for your collection?
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 4/30/2016 8:06:26 AM
Subject: Type handler breaking functionality in <collection>
 
I'm using MyBatis 3.3.1 with MyBatis-Spring 3.3.1.

I have a result map, which includes the following:
  <collection ofType="CollectionElementType" property="widgets" column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}"  select="selectCollectionElements">
    <id property="column1" column="COLUMN1" />
    <id property="column2" column="COLUMN2" />
    <id property="column3" column="COLUMN3" />
  </collection>    

COLUMN2 is a String column, which requires a type handler to change the text to uppercase.  This type handler is defined inside the element typeHandlers in the mapper configuration file.  

Apparently the type handler is invoked before the key values for selectCollectionElements are constructed, which results in values not matching the database table, which in turn prevents the corresponding rows from being retrieved.

If I disable the type handler, the list in property widgets is correctly populated with matching elements fetched by selectCollectionElements, but I must then use custom code to apply logic in type handler to each element of the list.

When defining the composite key column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}", is there a way to either disable the custom type handler just for the purposes of building the key to be used for selectCollectionElements?  If not, can an alternate type handler be specified just for COLUMN2 in this key?

--
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: Type handler breaking functionality in <collection>

Pawel Zmarlicki-2
The inquiry works and the collection is populated correctly, but the type handler is not applied to contents of COLUMN2.  It is not clear to me what typeHandler should do when provided in the element <id>, since it looks like it's not doing anything.

On Sunday, May 1, 2016 at 12:30:29 AM UTC-4, Guy Rouillier wrote:
What happens if you remove your type handler from the <typehandlers> element in the config XML and instead add it just to the  <id> element for your collection?
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="X92iG7mSBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">pzmar...@...>
To: "mybatis-user" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="X92iG7mSBgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...>
Sent: 4/30/2016 8:06:26 AM
Subject: Type handler breaking functionality in <collection>
 
I'm using MyBatis 3.3.1 with MyBatis-Spring 3.3.1.

I have a result map, which includes the following:
  <collection ofType="CollectionElementType" property="widgets" column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}"  select="selectCollectionElements">
    <id property="column1" column="COLUMN1" />
    <id property="column2" column="COLUMN2" />
    <id property="column3" column="COLUMN3" />
  </collection>    

COLUMN2 is a String column, which requires a type handler to change the text to uppercase.  This type handler is defined inside the element typeHandlers in the mapper configuration file.  

Apparently the type handler is invoked before the key values for selectCollectionElements are constructed, which results in values not matching the database table, which in turn prevents the corresponding rows from being retrieved.

If I disable the type handler, the list in property widgets is correctly populated with matching elements fetched by selectCollectionElements, but I must then use custom code to apply logic in type handler to each element of the list.

When defining the composite key column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}", is there a way to either disable the custom type handler just for the purposes of building the key to be used for selectCollectionElements?  If not, can an alternate type handler be specified just for COLUMN2 in this key?

--
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="X92iG7mSBgAJ" 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[2]: Type handler breaking functionality in <collection>

Guy Rouillier-2
The type handler, when applied to the <id> element, should do the same thing you'd expect it to do when applied globally.
 
This is going to be difficult to diagnose any further in general terms.  If you have a small working sample that I can test using a PostgreSQL environment, please package it up and send it to me directly.  Include SQL to create the table and populate some test data.
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 5/3/2016 7:36:36 AM
Subject: Re: Type handler breaking functionality in <collection>
 
The inquiry works and the collection is populated correctly, but the type handler is not applied to contents of COLUMN2.  It is not clear to me what typeHandler should do when provided in the element <id>, since it looks like it's not doing anything.

On Sunday, May 1, 2016 at 12:30:29 AM UTC-4, Guy Rouillier wrote:
What happens if you remove your type handler from the <typehandlers> element in the config XML and instead add it just to the  <id> element for your collection?
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <<A href="javascript:" rel=nofollow gdf-obfuscated-mailto="X92iG7mSBgAJ">pzmar...@...>
To: "mybatis-user" <<A href="javascript:" rel=nofollow gdf-obfuscated-mailto="X92iG7mSBgAJ">mybati...@...>
Sent: 4/30/2016 8:06:26 AM
Subject: Type handler breaking functionality in <collection>
 
I'm using MyBatis 3.3.1 with MyBatis-Spring 3.3.1.

I have a result map, which includes the following:
  <collection ofType="CollectionElementType" property="widgets" column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}"  select="selectCollectionElements">
    <id property="column1" column="COLUMN1" />
    <id property="column2" column="COLUMN2" />
    <id property="column3" column="COLUMN3" />
  </collection>    

COLUMN2 is a String column, which requires a type handler to change the text to uppercase.  This type handler is defined inside the element typeHandlers in the mapper configuration file.  

Apparently the type handler is invoked before the key values for selectCollectionElements are constructed, which results in values not matching the database table, which in turn prevents the corresponding rows from being retrieved.

If I disable the type handler, the list in property widgets is correctly populated with matching elements fetched by selectCollectionElements, but I must then use custom code to apply logic in type handler to each element of the list.

When defining the composite key column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}", is there a way to either disable the custom type handler just for the purposes of building the key to be used for selectCollectionElements?  If not, can an alternate type handler be specified just for COLUMN2 in this key?

--
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:" rel=nofollow gdf-obfuscated-mailto="X92iG7mSBgAJ">mybatis-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Virus-free. www.avast.com

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: Re[2]: Type handler breaking functionality in <collection>

Pawel Zmarlicki-2
I'm not working with PostgreSQL, so I'm not going to be able to take time to do this.  I will try and add custom type handler to each String property in result map.

I have noticed that the best way to describe this problem is that the implicit type handler defined in mapper configuration is only used while building key values for the collection, and I've been unable to override this type handler by providing a custom handler in the element <id>.  The implicit type handler is never used for setting properties in a result map, but I can provide a custom type handler for each result map property.

I've found the same happening for Date properties: I have registered a custom type handler extending DateOnlyTypeHandler in mapper configuration, but the default DateTypeHandler is used instead.


On Tuesday, May 3, 2016 at 11:40:46 PM UTC-4, Guy Rouillier wrote:
The type handler, when applied to the <id> element, should do the same thing you'd expect it to do when applied globally.
 
This is going to be difficult to diagnose any further in general terms.  If you have a small working sample that I can test using a PostgreSQL environment, please package it up and send it to me directly.  Include SQL to create the table and populate some test data.
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OP6ASDBZAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">pzmar...@...>
To: "mybatis-user" <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OP6ASDBZAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">mybati...@...>
Cc: <a href="javascript:" target="_blank" gdf-obfuscated-mailto="OP6ASDBZAAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">guy.ro...@...
Sent: 5/3/2016 7:36:36 AM
Subject: Re: Type handler breaking functionality in <collection>
 
The inquiry works and the collection is populated correctly, but the type handler is not applied to contents of COLUMN2.  It is not clear to me what typeHandler should do when provided in the element <id>, since it looks like it's not doing anything.

On Sunday, May 1, 2016 at 12:30:29 AM UTC-4, Guy Rouillier wrote:
What happens if you remove your type handler from the <typehandlers> element in the config XML and instead add it just to the  <id> element for your collection?
 
--
Guy Rouillier
 
 
 
------ Original Message ------
From: "Pawel Zmarlicki" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 4/30/2016 8:06:26 AM
Subject: Type handler breaking functionality in <collection>
 
I'm using MyBatis 3.3.1 with MyBatis-Spring 3.3.1.

I have a result map, which includes the following:
  <collection ofType="CollectionElementType" property="widgets" column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}"  select="selectCollectionElements">
    <id property="column1" column="COLUMN1" />
    <id property="column2" column="COLUMN2" />
    <id property="column3" column="COLUMN3" />
  </collection>    

COLUMN2 is a String column, which requires a type handler to change the text to uppercase.  This type handler is defined inside the element typeHandlers in the mapper configuration file.  

Apparently the type handler is invoked before the key values for selectCollectionElements are constructed, which results in values not matching the database table, which in turn prevents the corresponding rows from being retrieved.

If I disable the type handler, the list in property widgets is correctly populated with matching elements fetched by selectCollectionElements, but I must then use custom code to apply logic in type handler to each element of the list.

When defining the composite key column="{column1=COLUMN1,column2=COLUMN2,column3=COLUMN3}", is there a way to either disable the custom type handler just for the purposes of building the key to be used for selectCollectionElements?  If not, can an alternate type handler be specified just for COLUMN2 in this key?

--
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 style="COLOR:#4453ea" 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" 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

<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.