0

I have an INSTR_ROUTING database table with three columns: INSTR_ROUTING table

My Java code is:

    public Map<String, String> getInstrumentRouting() {
    return getSqlSession().selectMap(NAMESPACE_PFX + "getInstrumentRouting", "INSTR_INSTANCE_NM");

and mybatis I've tried multiple ways, the latest two are:

    <select id="getInstrumentRouting" resultType="java.util.HashMap">
    select  INSTR_ROUTING_ID    as irId,
            INSTR_INSTANCE_NM   as instrumentName,      
            LAB_SYSTEM_NM       as destinationName  
    from INSTR_ROUTING
    WHERE INSTR_ROUTING_ID = #{irId, jdbcType=VARCHAR}
</select>

and:

    <resultMap id="instrumentRoutingMap" type="com.labcorp.adapter.di.common.InstrumentRoute">
    <result column="INSTR_INSTANCE_NM" property="instrumentName"
        jdbcType="VARCHAR" />
    <result column="LAB_SYSTEM_NM" property="queueInstanceName"
        jdbcType="VARCHAR" />
</resultMap>

<select id="getInstrumentRouting" resultMap="instrumentRoutingMap">
    select  INSTR_ROUTING_ID    as irId,
            INSTR_INSTANCE_NM   as instrumentName,      
            LAB_SYSTEM_NM       as destinationName  
    from INSTR_ROUTING
    WHERE INSTR_ROUTING_ID = #{irId, jdbcType=VARCHAR}
</select>

All I've been able to get is an empty Map "{}" or an exception, e.g. saying it can't find the type "java.util.HashMap".

Can anyone set me straight? This should be easy...

1 Answer 1

0

I got a simplified version working. I changed it to only get the one LAB_SYSTEM_NM for a given INSTR_INSTANCE_NM (instead of loading the entire table).

<?xml version="1.0" encoding="UTF-8"?>

<select id="getDiInstanceName" resultType="String">
    select LAB_SYSTEM_NM as destinationName 
    from INSTR_ROUTING
    WHERE INSTR_INSTANCE_NM = #{instrumentName, jdbcType=VARCHAR}
</select>

    public String getDiInstanceNameFor(String instrumentName) {
    return getSqlSession().selectOne(NAMESPACE_PFX + "getDiInstanceName", instrumentName);
}

Hope that helps someone else.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.