Kotlin+mybatis(.xml) update sql return

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

Kotlin+mybatis(.xml) update sql return

javawcy
    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





--
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: Kotlin+mybatis(.xml) update sql return

Guy Rouillier-2
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





--
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: Kotlin+mybatis(.xml) update sql return

javawcy
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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

--
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: Kotlin+mybatis(.xml) update sql return

javawcy
FYI:
      Mapper method 'com.yrd_sys_provider.mapper.sys.YrdSysBroadCastMapperKt.insert attempted to return null from a     method with a primitive return type (int).



2018-05-22 8:53 GMT+08:00 cy wang <[hidden email]>:
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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


--
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]: Kotlin+mybatis(.xml) update sql return

Guy Rouillier-2
We don't know what YrdSysBroadCastMapperKt.insert does.  If you'd like help with a specific issue, you'll need to post some runnable code.  A complete project on Github would be even better.

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:43:39 PM
Subject: Re: Kotlin+mybatis(.xml) update sql return

FYI:
      Mapper method 'com.yrd_sys_provider.mapper.sys.YrdSysBroadCastMapperKt.insert attempted to return null from a     method with a primitive return type (int).



2018-05-22 8:53 GMT+08:00 cy wang <[hidden email]>:
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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


--
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: Re[2]: Kotlin+mybatis(.xml) update sql return

javawcy
There is the code:
fun insert(map: Map<String,Any>): Int?
val a = yrdSysBroadCastMapperKt.insert(map)
println(a)
<select id="insert">
insert into yrd_sys_broadcast(
loan_product_id,
broadcast_msg
)values(
#{loanProductId},
#{broadCastMsg}
)
</select>
2018-05-22 10:48:31.155 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==>  Preparing: insert into yrd_sys_broadcast( loan_product_id, broadcast_msg )values( ?, ? ) 
2018-05-22 10:48:31.258 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==> Parameters: 35(Integer), 恭喜xxx申请<font color='#FF0000'>xxx贷款</font>1000元成功(String)
null
As you can see,it return a null value

2018-05-22 10:46 GMT+08:00 Guy Rouillier <[hidden email]>:
We don't know what YrdSysBroadCastMapperKt.insert does.  If you'd like help with a specific issue, you'll need to post some runnable code.  A complete project on Github would be even better.

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:43:39 PM
Subject: Re: Kotlin+mybatis(.xml) update sql return

FYI:
      Mapper method 'com.yrd_sys_provider.mapper.sys.YrdSysBroadCastMapperKt.insert attempted to return null from a     method with a primitive return type (int).



2018-05-22 8:53 GMT+08:00 cy wang <[hidden email]>:
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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


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

--
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[4]: Kotlin+mybatis(.xml) update sql return

Guy Rouillier-2
That's not what I see.  Look at the log I provided from my successful run of a Kotlin project.  The next DEBUG line should be something like this:

DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1

You need to clarify what you are logging.  Rather than simply println(a), put a prompt in front of it so you know what is being printed.  I think that null is coming from the insert, not from your println.  Is your database set up to accept double-byte characters?

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:50:52 PM
Subject: Re: Re[2]: Kotlin+mybatis(.xml) update sql return

There is the code:
fun insert(map: Map<String,Any>): Int?
val a = yrdSysBroadCastMapperKt.insert(map)
println(a)
<select id="insert">
insert into yrd_sys_broadcast(
loan_product_id,
broadcast_msg
)values(
#{loanProductId},
#{broadCastMsg}
)
</select>
2018-05-22 10:48:31.155 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==>  Preparing: insert into yrd_sys_broadcast( loan_product_id, broadcast_msg )values( ?, ? ) 
2018-05-22 10:48:31.258 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==> Parameters: 35(Integer), 恭喜xxx申请<font color='#FF0000'>xxx贷款</font>1000元成功(String)
null
As you can see,it return a null value

2018-05-22 10:46 GMT+08:00 Guy Rouillier <[hidden email]>:
We don't know what YrdSysBroadCastMapperKt.insert does.  If you'd like help with a specific issue, you'll need to post some runnable code.  A complete project on Github would be even better.

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:43:39 PM
Subject: Re: Kotlin+mybatis(.xml) update sql return

FYI:
      Mapper method 'com.yrd_sys_provider.mapper.sys.YrdSysBroadCastMapperKt.insert attempted to return null from a     method with a primitive return type (int).



2018-05-22 8:53 GMT+08:00 cy wang <[hidden email]>:
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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


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

--
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: Re[4]: Kotlin+mybatis(.xml) update sql return

Jeff Butler
You have your insert statement coded in <select> tags - so MyBatis is assuming it is a query and looking for a result set. Inserts should be coded in <insert> tags :)

Jeff Butler


On Mon, May 21, 2018 at 11:33 PM Guy Rouillier <[hidden email]> wrote:
That's not what I see.  Look at the log I provided from my successful run of a Kotlin project.  The next DEBUG line should be something like this:

DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1

You need to clarify what you are logging.  Rather than simply println(a), put a prompt in front of it so you know what is being printed.  I think that null is coming from the insert, not from your println.  Is your database set up to accept double-byte characters?

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:50:52 PM
Subject: Re: Re[2]: Kotlin+mybatis(.xml) update sql return

There is the code:
fun insert(map: Map<String,Any>): Int?
val a = yrdSysBroadCastMapperKt.insert(map)
println(a)
<select id="insert">
insert into yrd_sys_broadcast(
loan_product_id,
broadcast_msg
)values(
#{loanProductId},
#{broadCastMsg}
)
</select>
2018-05-22 10:48:31.155 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==>  Preparing: insert into yrd_sys_broadcast( loan_product_id, broadcast_msg )values( ?, ? ) 
2018-05-22 10:48:31.258 DEBUG 5203 --- [:30007-thread-2] c.y.m.s.YrdSysBroadCastMapperKt.insert   : ==> Parameters: 35(Integer), 恭喜xxx申请<font color='#FF0000'>xxx贷款</font>1000元成功(String)
null
As you can see,it return a null value

2018-05-22 10:46 GMT+08:00 Guy Rouillier <[hidden email]>:
We don't know what YrdSysBroadCastMapperKt.insert does.  If you'd like help with a specific issue, you'll need to post some runnable code.  A complete project on Github would be even better.

--
Guy Rouillier

------ Original Message ------
From: "cy wang" <[hidden email]>
Sent: 5/21/2018 10:43:39 PM
Subject: Re: Kotlin+mybatis(.xml) update sql return

FYI:
      Mapper method 'com.yrd_sys_provider.mapper.sys.YrdSysBroadCastMapperKt.insert attempted to return null from a     method with a primitive return type (int).



2018-05-22 8:53 GMT+08:00 cy wang <[hidden email]>:
that is help a lot

2018-05-21 15:59 GMT+08:00 Guy Rouillier <[hidden email]>:
This works for me:

mapper.kt:

    fun update(contact: Contact): Int?

mapper.xml:

      <update id="update">
        update contact set
            lastName = #{lastName},
            firstName = #{firstName},
            phone = #{phone},
            email = #{email}
        where id = #{id}
    </update>

test.kt:

      private fun updateContact()
      {
      val contact = Contact(2, "Guy", "Rouillier", "111-111-1111", "me[hidden email]emailaddr.com");
      
      val iRows = mapper!!.update(contact);
      
      log.info("Number of rows updated: " + iRows);
      }

Output:

   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: org.apache.ibatis.datasource.unpooled.UnpooledDataSource@51565e2
   INFO 2018-05-21 07:50:36,657 org.sample.mybatis.KtMain: Calling updateContact...

   DEBUG 2018-05-21 07:50:36,923 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==>  Preparing: update contact set lastName = ?, firstName = ?, phone = ?, email = ? where id = ?
   DEBUG 2018-05-21 07:50:36,969 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: ==> Parameters: Rouillier(String), Guy(String), 111-111-1111(String), [hidden email](String), 2(Integer)
   DEBUG 2018-05-21 07:50:36,985 org.apache.ibatis.logging.jdbc.BaseJdbcLogger: <==    Updates: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: Number of rows updated: 1
   INFO 2018-05-21 07:50:36,985 org.sample.mybatis.KtMain: All done!

--
Guy Rouillier

------ Original Message ------
To: "mybatis-user" <[hidden email]>
Sent: 5/21/2018 1:24:55 AM
Subject: Kotlin+mybatis(.xml) update sql return

    I can't get a return int value from update mapper in Kotlin.
    example: 
                 fun update(xx:Int):Int?
                 
                 <update id="update">
                      update xx set xx = xx where xx=xx;
                 </update>
   it return null value install of int . but it works in java.





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


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

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

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