Abhijeet
Abhijeet

Reputation: 266

MyBatis: Select a Map to map

How can I select a map of map using mybatis?

SELECT process_code, priority, execution_interval FROM scheduling_parameter

How can I retrieve a result in the form Map<process_code, Map<priority,execution_interval>>

Upvotes: 2

Views: 796

Answers (1)

Persia
Persia

Reputation: 895

I think you implements the mybatis ResultHandler and write your transform code in it; or get map from mybatis and write the transform code in your service class. like this:

sqlSession.select("yourstatmentid",new ResultHandler(){ 
    @Override 
    public void handleResult(ResultContext context){ 
        List<Map> data = (List<Map>) context.getResultObject(); 
        //transform list to map as you like 
    } 
 }) 

Upvotes: 2

Related Questions