Using MyBatis and Oracle 11 How Do You Call a Stored Procedure With Multiple Parameters

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

Using MyBatis and Oracle 11 How Do You Call a Stored Procedure With Multiple Parameters

Benjamin Pusey
Versions
ojdbc7 : 12.1.0.2,
mybatis: 3.2.3,
mybatis-spring: 1.2.1
 
          Database: Oracle 11

Issue Description

I'm trying to call a stored procedure from MyBatis with three parameters and return a defined object type. 

Mapper.xml

<select id="getDetails" statementType="CALLABLE" resultMap="paramMap">
{call USER.PKG.procedure(
                #{paramMap, jdbcType=STRUCT, mode=IN},
#{paramMap.id, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.name, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.date, mode=OUT, jdbcType=DATE},
                #{paramMap.total, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.total2, mode=OUT, jdbcType=VARCHAR} )}
</select>


Mapper.java


public interface NodeMapper {
Object getDetails(@Param("paramMap") HashMap<String, Object> paramMap);
}

MapperDAO.java

public Detail getDetails(int ID, int group, long DT) {
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("ID", ID);
param.put("group", group);
param.put("DT", DT);
mapper.getDetails(param);
return (Detail) param.get(); // not sure what to do here
}


Any help would be greatly appreciated, I'm definitely not doing this correctly. I found examples online but I'm not sure if they're compatible with oracle SQL. 

This one uses parameters but the database is MYSQL:
http://stackoverflow.com/questions/8626678/mybatis-mapper-to-call-a-proc-with-multiple-in-parameters

This one doesn't use parameters but is using oracle SQL:
http://stackoverflow.com/questions/15666856/calling-oracle-stored-procedures-with-mybatis



--
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: Using MyBatis and Oracle 11 How Do You Call a Stored Procedure With Multiple Parameters

Iwao AVE!

// Iwao

2017-01-27 6:52 GMT+09:00 Benjamin Pusey <[hidden email]>:
Versions
ojdbc7 : 12.1.0.2,
mybatis: 3.2.3,
mybatis-spring: 1.2.1
 
          Database: Oracle 11

Issue Description

I'm trying to call a stored procedure from MyBatis with three parameters and return a defined object type. 

Mapper.xml

<select id="getDetails" statementType="CALLABLE" resultMap="paramMap">
{call USER.PKG.procedure(
                #{paramMap, jdbcType=STRUCT, mode=IN},
#{paramMap.id, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.name, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.date, mode=OUT, jdbcType=DATE},
                #{paramMap.total, mode=OUT, jdbcType=VARCHAR},
                #{paramMap.total2, mode=OUT, jdbcType=VARCHAR} )}
</select>


Mapper.java


public interface NodeMapper {
Object getDetails(@Param("paramMap") HashMap<String, Object> paramMap);
}

MapperDAO.java

public Detail getDetails(int ID, int group, long DT) {
HashMap<String, Object> param = new HashMap<String, Object>();
param.put("ID", ID);
param.put("group", group);
param.put("DT", DT);
mapper.getDetails(param);
return (Detail) param.get(); // not sure what to do here
}


Any help would be greatly appreciated, I'm definitely not doing this correctly. I found examples online but I'm not sure if they're compatible with oracle SQL. 

This one uses parameters but the database is MYSQL:

This one doesn't use parameters but is using oracle SQL:



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