Win a copy of Secure Financial Transactions with Ansible, Terraform, and OpenSCAP this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Jeanne Boyarsky
  • Bear Bibeault
Sheriffs:
  • Rob Spoor
  • Henry Wong
  • Liutauras Vilda
Saloon Keepers:
  • Tim Moores
  • Carey Brown
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Frits Walraven
  • Himai Minh
  • Jj Roberts

can mybatis mapper have array return type?

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can mybatis mapper have array return type?
I've query like select dept_no from employee where emp_id in (1,2) which returns two rows.
mapper.xml has following
<select id="getDeptNo" resultType="int">
SELECT dept_no FROM employee
where ticker in
<foreach item="item" index="index" collection="array" open="("
separator="," close=")">
#{item}
</foreach>
</select>

And in the mapper class , can I've
public int[] getDeptNo(String[] empId);

When I try this , it is throwing an exception java.lang.ClassCastException: [I incompatible with [Ljava.lang.Object;

I've to declare the returnType to "Integer" and have the mapper class declaration as public List<Integer> getDeptNo(String[] empId);

Why I can not get the array?
 
Remember to always leap before you look. But always take the time to smell the tiny ads:
SKIP - a book about connecting industrious people with elderly land owners
https://coderanch.com/t/skip-book
reply
    Bookmark Topic Watch Topic
  • New Topic