Cant call SP correctly use java List with Object as subelement

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

Cant call SP correctly use java List with Object as subelement

maystrong123
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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: Cant call SP correctly use java List with Object as subelement

Iwao AVE!
It worked for me.

Here is the project that I used to test.

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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: Cant call SP correctly use java List with Object as subelement

maystrong123
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.
<a href="https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="OHEqeRfPAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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="OHEqeRfPAgAJ" 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: Cant call SP correctly use java List with Object as subelement

Iwao AVE!
Using MyBatis Spring should not affect the behavior.
I'm not sure about Druid.
Try replacing it with something else and see if it works.

Or, if you upload a small example project as I did, I or someone might be able to help.

Regards,
Iwao

2017-10-08 20:11 GMT+09:00 <[hidden email]>:
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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 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: Cant call SP correctly use java List with Object as subelement

maystrong123
https://gitee.com/liusg123/mybatis-sp-test.git please run the junit class directly

在 2017年10月8日星期日 UTC+8下午7:34:38,Iwao AVE!写道:
Using MyBatis Spring should not affect the behavior.
I'm not sure about Druid.
Try replacing it with something else and see if it works.

Or, if you upload a small example project as I did, I or someone might be able to help.

Regards,
Iwao

2017-10-08 20:11 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="bQ-iIikMBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.
<a href="https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


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

--
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="bQ-iIikMBAAJ" 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: Cant call SP correctly use java List with Object as subelement

maystrong123
In reply to this post by Iwao AVE!
Please run the junit test class directly

https://gitee.com/liusg123/mybatis-sp-test.git 

在 2017年10月8日星期日 UTC+8下午7:34:38,Iwao AVE!写道:
Using MyBatis Spring should not affect the behavior.
I'm not sure about Druid.
Try replacing it with something else and see if it works.

Or, if you upload a small example project as I did, I or someone might be able to help.

Regards,
Iwao

2017-10-08 20:11 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="bQ-iIikMBAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.
<a href="https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


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

--
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="bQ-iIikMBAAJ" 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: Cant call SP correctly use java List with Object as subelement

Kazuki Shimizu
It is working fine on my local pc.

I've added some assertions as follow:

package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hamcrest.core.Is;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.test.sp.FeignApplication;
import com.test.sp.repo.mapper.BankInfoMapper;
import com.test.sp.repo.vo.Bkdataset;

import javax.sql.DataSource;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = FeignApplication.class)
public class BankInfoSyncTest {
 
@Autowired
  private BankInfoMapper bankInfoMapper;

 
@Autowired
  private DataSource dataSource;

  @Test
  public void testWyqybankchagRpt() {

   
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate
.update("DELETE FROM TESTA");

   
List<Bkdataset> dataset = new ArrayList<Bkdataset>();
   
Bkdataset bd = new Bkdataset();
    bd
.setAcpicd("acp01");
    bd
.setAlttype("altt01");
    bd
.setAltdate("altd01");
    dataset
.add(bd);
   
Bkdataset bd1 = new Bkdataset();
    bd1
.setAcpicd("acp02");
    bd1
.setAlttype("altt02");
    bd1
.setAltdate("altd02");
    dataset
.add(bd1);
   
bankInfoMapper.saveSyncBankInfos(dataset);

   
List<Map<String, Object>> records = jdbcTemplate.queryForList("SELECT * FROM TESTA ORDER BY A");

   
Assert.assertThat(records.size(), Is.is(2));
   
{
     
Map<String, Object> record = records.get(0);
     
Assert.assertThat(record.get("A").toString(), Is.is("1"));
     
Assert.assertThat(record.get("B").toString(), Is.is("altt01"));
     
Assert.assertThat(record.get("C").toString(), Is.is("altd01"));
   
}
   
{
     
Map<String, Object> record = records.get(1);
     
Assert.assertThat(record.get("A").toString(), Is.is("2"));
     
Assert.assertThat(record.get("B").toString(), Is.is("altt02"));
     
Assert.assertThat(record.get("C").toString(), Is.is("altd02"));
   
}
 
}

}

Local PC : Mac
DB: Oracle Express Edition 11g Release 2 on Ubuntu
Jdbc Driver: com.oracle.jdbc7:12.1.0.2 (download from oracle maven repository)

Best Regards,
Kazuki

On Tuesday, October 10, 2017 at 12:28:20 AM UTC+9, [hidden email] wrote:
Please run the junit test class directly

<a href="https://gitee.com/liusg123/mybatis-sp-test.git" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitee.com%2Fliusg123%2Fmybatis-sp-test.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEOuZyJqj7n4y63BJkfnNaD0ypdKA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitee.com%2Fliusg123%2Fmybatis-sp-test.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEOuZyJqj7n4y63BJkfnNaD0ypdKA&#39;;return true;">https://gitee.com/liusg123/mybatis-sp-test.git 

在 2017年10月8日星期日 UTC+8下午7:34:38,Iwao AVE!写道:
Using MyBatis Spring should not affect the behavior.
I'm not sure about Druid.
Try replacing it with something else and see if it works.

Or, if you upload a small example project as I did, I or someone might be able to help.

Regards,
Iwao

2017-10-08 20:11 GMT+09:00 <[hidden email]>:
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.
<a href="https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


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

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

--
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: Cant call SP correctly use java List with Object as subelement

maystrong123
Really strange,the db version is the seam ,and the jdbc jar i tried many versions 。So could u help to run the junit test class test.BankInfoSyncTest.testWyqybankchagRpt directly with all the seem maven jars ?Tks a lot

在 2017年10月10日星期二 UTC+8上午12:21:05,Kazuki Shimizu写道:
It is working fine on my local pc.

I've added some assertions as follow:

package test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.hamcrest.core.Is;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import com.test.sp.FeignApplication;
import com.test.sp.repo.mapper.BankInfoMapper;
import com.test.sp.repo.vo.Bkdataset;

import javax.sql.DataSource;

@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = FeignApplication.class)
public class BankInfoSyncTest {
 
@Autowired
  private BankInfoMapper bankInfoMapper;

 
@Autowired
  private DataSource dataSource;

  @Test
  public void testWyqybankchagRpt() {

   
JdbcTemplate jdbcTemplate = new JdbcTemplate(dataSource);
    jdbcTemplate
.update("DELETE FROM TESTA");

   
List<Bkdataset> dataset = new ArrayList<Bkdataset>();
   
Bkdataset bd = new Bkdataset();
    bd
.setAcpicd("acp01");
    bd
.setAlttype("altt01");
    bd
.setAltdate("altd01");
    dataset
.add(bd);
   
Bkdataset bd1 = new Bkdataset();
    bd1
.setAcpicd("acp02");
    bd1
.setAlttype("altt02");
    bd1
.setAltdate("altd02");
    dataset
.add(bd1);
   
bankInfoMapper.saveSyncBankInfos(dataset);

   
List<Map<String, Object>> records = jdbcTemplate.queryForList("SELECT * FROM TESTA ORDER BY A");

   
Assert.assertThat(records.size(), Is.is(2));
   
{
     
Map<String, Object> record = records.get(0);
     
Assert.assertThat(record.get("A").toString(), Is.is("1"));
     
Assert.assertThat(record.get("B").toString(), Is.is("altt01"));
     
Assert.assertThat(record.get("C").toString(), Is.is("altd01"));
   
}
   
{
     
Map<String, Object> record = records.get(1);
     
Assert.assertThat(record.get("A").toString(), Is.is("2"));
     
Assert.assertThat(record.get("B").toString(), Is.is("altt02"));
     
Assert.assertThat(record.get("C").toString(), Is.is("altd02"));
   
}
 
}

}

Local PC : Mac
DB: Oracle Express Edition 11g Release 2 on Ubuntu
Jdbc Driver: com.oracle.jdbc7:12.1.0.2 (download from oracle maven repository)

Best Regards,
Kazuki

On Tuesday, October 10, 2017 at 12:28:20 AM UTC+9, [hidden email] wrote:
Please run the junit test class directly

<a href="https://gitee.com/liusg123/mybatis-sp-test.git" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitee.com%2Fliusg123%2Fmybatis-sp-test.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEOuZyJqj7n4y63BJkfnNaD0ypdKA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgitee.com%2Fliusg123%2Fmybatis-sp-test.git\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEOuZyJqj7n4y63BJkfnNaD0ypdKA&#39;;return true;">https://gitee.com/liusg123/mybatis-sp-test.git 

在 2017年10月8日星期日 UTC+8下午7:34:38,Iwao AVE!写道:
Using MyBatis Spring should not affect the behavior.
I'm not sure about Druid.
Try replacing it with something else and see if it works.

Or, if you upload a small example project as I did, I or someone might be able to help.

Regards,
Iwao

2017-10-08 20:11 GMT+09:00 <[hidden email]>:
My project is started up by spring boot and mybatis-spring 
<mybatis-spring.version>1.3.1</mybatis-spring.version>
and ds i used druid
<druid-spring-boot.version>1.1.4</druid-spring-boot.version>

It worked for me.

Here is the project that I used to test.
<a href="https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2Fharawata%2Fmybatis-issues%2Ftree%2Fmaster%2Fml-20170926T060927\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFelLV1yJ7Ig0o4SvT7h3rKmlVvOg&#39;;return true;">https://github.com/harawata/mybatis-issues/tree/master/ml-20170926T060927

Oracle version: 11g (11.2.0.2.0)

Regards,
Iwao

2017-09-26 18:09 GMT+09:00 <[hidden email]>:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


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

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

--
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: Cant call SP correctly use java List with Object as subelement

maystrong123
In reply to this post by maystrong123


在 2017年9月26日星期二 UTC+8下午5:09:27,maystr...@gmail.com写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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: Cant call SP correctly use java List with Object as subelement

Iwao AVE!
It worked on my environment as well.
The driver specified in the pom.xml does not exist [1], so I also used the official one downloaded from Oracle.

Just to clarify: you did run my test project and it worked as you expected, is that correct?

[1] The URL returns 404. I think it's not allowed to redistribute Oracle JDBC drivers.


2017-10-10 23:33 GMT+09:00 <[hidden email]>:


在 2017年9月26日星期二 UTC+8下午5:09:27,[hidden email]写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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: Cant call SP correctly use java List with Object as subelement

maystrong123
Sure,both shouldInsert() and shouldInsertWithJdbc() are tested and it doesn't worked as expected.To your difference ,I just change the jdbc jar version as : 
               <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
.I tested it on two oracle db instance on different linux machines,it work the same。The easy-project ojdbc jar files can be got here
 http://maven.aliyun.com/nexus/content/groups/public/ 

在 2017年10月10日星期二 UTC+8下午10:54:10,Iwao AVE!写道:
It worked on my environment as well.
The driver specified in the pom.xml does not exist [1], so I also used the official one downloaded from Oracle.

Just to clarify: you did run my test project and it worked as you expected, is that correct?

[1] The URL returns 404. I think it's not allowed to redistribute Oracle JDBC drivers.
<a href="http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;">http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar


2017-10-10 23:33 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kk4-gmiyAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:


在 2017年9月26日星期二 UTC+8下午5:09:27,maystr...@gmail.com写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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="kk4-gmiyAgAJ" 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: Cant call SP correctly use java List with Object as subelement

Iwao AVE!
You should have said so if my tests did not work for you ;)
The second test (shouldInsertWithJdbc) is plain JDBC, so if it fails, it's not a MyBatis issue and there may be something unusual with your Oracle setup(s).

FYI, I tried the driver from easyproject and the test still worked as expected.

2017-10-11 11:14 GMT+09:00 <[hidden email]>:
Sure,both shouldInsert() and shouldInsertWithJdbc() are tested and it doesn't worked as expected.To your difference ,I just change the jdbc jar version as : 
               <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
.I tested it on two oracle db instance on different linux machines,it work the same。The easy-project ojdbc jar files can be got here

在 2017年10月10日星期二 UTC+8下午10:54:10,Iwao AVE!写道:
It worked on my environment as well.
The driver specified in the pom.xml does not exist [1], so I also used the official one downloaded from Oracle.

Just to clarify: you did run my test project and it worked as you expected, is that correct?

[1] The URL returns 404. I think it's not allowed to redistribute Oracle JDBC drivers.


2017-10-10 23:33 GMT+09:00 <[hidden email]>:


在 2017年9月26日星期二 UTC+8下午5:09:27,maystr...@gmail.com写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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 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: Cant call SP correctly use java List with Object as subelement

maystrong123
In reply to this post by Iwao AVE!


在 2017年10月10日星期二 UTC+8下午10:54:10,Iwao AVE!写道:
It worked on my environment as well.
The driver specified in the pom.xml does not exist [1], so I also used the official one downloaded from Oracle.

Just to clarify: you did run my test project and it worked as you expected, is that correct?

[1] The URL returns 404. I think it's not allowed to redistribute Oracle JDBC drivers.
<a href="http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;">http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar


2017-10-10 23:33 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="kk4-gmiyAgAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:


在 2017年9月26日星期二 UTC+8下午5:09:27,maystr...@gmail.com写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


--
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="kk4-gmiyAgAJ" 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: Cant call SP correctly use java List with Object as subelement

maystrong123
In reply to this post by Iwao AVE!
I got it ,it has nothing to do with mybatis ,it works as expected when i us nvarchar2 type rather than varchar2 when define the oracle struct type,really confusing me a lot.Tks for your time.

在 2017年10月11日星期三 UTC+8下午9:01:04,Iwao AVE!写道:
You should have said so if my tests did not work for you ;)
The second test (shouldInsertWithJdbc) is plain JDBC, so if it fails, it's not a MyBatis issue and there may be something unusual with your Oracle setup(s).

FYI, I tried the driver from easyproject and the test still worked as expected.

2017-10-11 11:14 GMT+09:00 <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="_ztcKp78BAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">maystr...@...>:
Sure,both shouldInsert() and shouldInsertWithJdbc() are tested and it doesn't worked as expected.To your difference ,I just change the jdbc jar version as : 
               <dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
.I tested it on two oracle db instance on different linux machines,it work the same。The easy-project ojdbc jar files can be got here
 <a href="http://maven.aliyun.com/nexus/content/groups/public/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGS2eAMP_YDJI1174eaopmU3PYmJg&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fmaven.aliyun.com%2Fnexus%2Fcontent%2Fgroups%2Fpublic%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGS2eAMP_YDJI1174eaopmU3PYmJg&#39;;return true;">http://maven.aliyun.com/nexus/content/groups/public/ 

在 2017年10月10日星期二 UTC+8下午10:54:10,Iwao AVE!写道:
It worked on my environment as well.
The driver specified in the pom.xml does not exist [1], so I also used the official one downloaded from Oracle.

Just to clarify: you did run my test project and it worked as you expected, is that correct?

[1] The URL returns 404. I think it's not allowed to redistribute Oracle JDBC drivers.
<a href="http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar" rel="nofollow" target="_blank" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Fcentral.maven.org%2Fmaven2%2Fcn%2Feasyproject%2Fojdbc7%2F12.1.0.2.0%2Fojdbc7-12.1.0.2.0.jar\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFAqP90l8U7OumYoiriYnCqer73qA&#39;;return true;">http://central.maven.org/maven2/cn/easyproject/ojdbc7/12.1.0.2.0/ojdbc7-12.1.0.2.0.jar


2017-10-10 23:33 GMT+09:00 <[hidden email]>:


在 2017年9月26日星期二 UTC+8下午5:09:27,maystr...@gmail.com写道:
Is that a bug?I used mybatis 3.4.5(multi version tested) and oracle 11g to call procedure using different jdbc drivers,and it doesn't  pass values to my sp as expected
The db configs:
1.Oracle object:
create or replace type S_BANK_INFO as object
(
  a1 varchar2(20),
  a2 varchar2(30),
  a3 varchar2(30)
)
2.Oracle object:
create or replace type S_BANK_INFO_LST is table of S_BANK_INFO;

3.my table :
create table TESTA
(
  a   VARCHAR2(30),
  b   VARCHAR2(30),
  c   VARCHAR2(30)
)

4.my procedure :
create or replace procedure proc_bank_info_sync(s_banks IN S_BANK_INFO_LST) is

 v_idx integer;
begin
  
 for v_idx in s_banks.first .. s_banks.last loop

     insert into testa(a,b,c) values(v_idx,s_banks(v_idx).a2,s_banks(v_idx).a3);
  
 end loop;
end proc_bank_info_sync;


The sp is called as follows :
1.The java Mapper interface
     void saveSyncBankInfos(@Param("dataset") List<Bkdataset> dataset);
2.The Mapper xml file
    <select id="saveSyncBankInfos" parameterType="list" statementType="CALLABLE">
{call  proc_bank_info_sync(#{dataset,mode=IN,javaType=list,jdbcTypeName=S_BANK_INFO_LST,jdbcType=ARRAY})}
</select>
3.The mybatis type handler:
@MappedJdbcTypes(JdbcType.ARRAY)
public class ListTypeHandler extends BaseTypeHandler<List<Bkdataset>> {

@Override
public void setNonNullParameter(PreparedStatement ps, int i, List<Bkdataset> parameter, JdbcType jdbcType) throws SQLException {

System.out.println("asdfasdfasdfdasf++++++++++++++=========");
OracleJdbc4NativeJdbcExtractor dr = new OracleJdbc4NativeJdbcExtractor();    //tested with muti jdbcExtractors
Connection conn = dr.getNativeConnection(ps.getConnection());
StructDescriptor sdesc = StructDescriptor.createDescriptor("S_BANK_INFO", conn);
List<STRUCT> structs = new ArrayList<STRUCT>();
for (int idx = 0; idx < parameter.size(); idx++) {
Bkdataset ds = parameter.get(idx);         //Bkdataset is just PO with many string attribute
Object[] result = { ds.getAcpicd(), ds.getAlttype(), ds.getAltdate() };
structs.add(new STRUCT(sdesc, conn, result));
}
ArrayDescriptor desc = ArrayDescriptor.createDescriptor("S_BANK_INFO_LST", conn);
ARRAY array = new ARRAY(desc, conn, structs.toArray());
ps.setArray(i, array);
}
    //follows method are implemented as default  and not important
}
All the work looks  fine without exception and the data in table is :
Table head:  a    b     c
Table data :  1   null  null
                     2   null  null
Expected table data:
Table head:  a    b     c
Table data :  1   'word a'  'word c'
                     2   'word b'  'word d'


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

--
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="_ztcKp78BAAJ" 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
|

How to return a column value defined as datetime(3) in MySQL 5.7?

lvxiaoyi@juzix
Hi all,

A column defined as datetime(3) in MySQL 5.7, the value is like this '2017/10/18 18:04:15.616',
the result map defined as :
<result column="deal_time" jdbcType="TIMESTAMP" property="dealTime" />
but the returned value in bean's  field 'dealTime'  is '2017/10/18 18:04:15',

so, how can I get the  '2017/10/18 18:04:15.616' value in returned.

thanks!

--
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: How to return a column value defined as datetime(3) in MySQL 5.7?

Guy Rouillier-2
I just ran a test using MariaDB 10.2.6.  Make sure the values in the database contain milliseconds.  I'm no MySQL expert, but according to this:


if you don't specify a precision when creating the table and inserting the data, the value is stored with precision 0 (zero).  When I did all that, the value in the database is shown with milliseconds (using HeidiSQL), and the value displayed when retrieved via Java also displays the milliseconds.

Here's the SQL I used for insert:

insert into timestamptest values(now(3))

When I used just now(), the timestamp was inserted without millis.  Hope this helps.

--
Guy Rouillier

------ Original Message ------
From: "lvxiaoyi@juzix" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 10/26/2017 2:30:25 AM
Subject: How to return a column value defined as datetime(3) in MySQL 5.7?

Hi all,

A column defined as datetime(3) in MySQL 5.7, the value is like this '2017/10/18 18:04:15.616',
the result map defined as :
<result column="deal_time" jdbcType="TIMESTAMP" property="dealTime" />
but the returned value in bean's  field 'dealTime'  is '2017/10/18 18:04:15',

so, how can I get the  '2017/10/18 18:04:15.616' value in returned.

thanks!

--
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: How to return a column value defined as datetime(3) in MySQL 5.7?

lvxiaoyi@juzix
I have upgraded the MySQL jdbc driver from 5.1.6 to 5.1.44, and now, everything is OK.

Thanks

Date: 2017-10-27 09:20
Subject: Re: How to return a column value defined as datetime(3) in MySQL 5.7?
I just ran a test using MariaDB 10.2.6.  Make sure the values in the database contain milliseconds.  I'm no MySQL expert, but according to this:


if you don't specify a precision when creating the table and inserting the data, the value is stored with precision 0 (zero).  When I did all that, the value in the database is shown with milliseconds (using HeidiSQL), and the value displayed when retrieved via Java also displays the milliseconds.

Here's the SQL I used for insert:

insert into timestamptest values(now(3))

When I used just now(), the timestamp was inserted without millis.  Hope this helps.

--
Guy Rouillier

------ Original Message ------
From: "lvxiaoyi@juzix" <[hidden email]>
To: "mybatis-user" <[hidden email]>
Sent: 10/26/2017 2:30:25 AM
Subject: How to return a column value defined as datetime(3) in MySQL 5.7?

Hi all,

A column defined as datetime(3) in MySQL 5.7, the value is like this '2017/10/18 18:04:15.616',
the result map defined as :
<result column="deal_time" jdbcType="TIMESTAMP" property="dealTime" />
but the returned value in bean's  field 'dealTime'  is '2017/10/18 18:04:15',

so, how can I get the  '2017/10/18 18:04:15.616' value in returned.

thanks!

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