Solved

Ibatis result set

Posted on 2012-04-05
1
532 Views
Last Modified: 2013-11-13
Advance Result Maps.

My question is for the query below how to define a Result Map in MyBatis?

SELECT SUPPLIERS.SUPPLIER_NAME, ORDERS.ORDER_NUMBER FROM SUPPLIERS, ORDERS WHERE SUPPLIERS.SUPPLIER_ID = ORDERS.SUPPLIER_ID

Thanks,
0
Comment
Question by:aniruddhp
1 Comment
 
LVL 35

Accepted Solution

by:
girionis earned 500 total points
ID: 37823108
The simplest would be to have something like the following:

<select id="selectData" resultType="hashmap">
  SELECT SUPPLIERS.SUPPLIER_NAME, ORDERS.ORDER_NUMBER FROM SUPPLIERS, ORDERS WHERE SUPPLIERS.SUPPLIER_ID = ORDERS.SUPPLIER_ID
</select>

Open in new window


because you define an *implicit* resultMap. If you want to define an explicit resultMap you need to have a proper object

package my.pack.age;
public class MyResult {
   String supplier_name;
   int order_number;

    // C'tor and getters/setters
}


<select id="selectData" resultType="my.pack.age.MyResult">
  SELECT SUPPLIERS.SUPPLIER_NAME, ORDERS.ORDER_NUMBER FROM SUPPLIERS, ORDERS WHERE SUPPLIERS.SUPPLIER_ID = ORDERS.SUPPLIER_ID
</select>

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now