Mybatis invalid characters & oracle to find all the superiors of the current user

Problem phenomenon:

Today, in the xml file of mybatis, I wrote a method: to find all the records of the parent organization of the current department, and the result was an error: invalid characters .


problem analysis:

Written in the xml file, the method selectDeptInfoBySId based on the oracle statement is used to find all the higher-level institutions of the current department.

<select id="selectDeptInfoBySId" resultMap="SecUserResultMap">
    select SID, SIDPARENT, DEPTTYPE, "NAME"
    from sec_user
    start with sid = #{sid,jdbcType=DECIMAL}
    connect by prior sidparent = sid;
  </select>

But an error, the error message is invalid characters;

At first I thought that mybatis could not recognize the start keyword, because this word is white, while other Oracle keywords are in yellow font.

After tossing twice, I want to find other methods, but Oracle seems to have no other better way to achieve this function;

So I began to suspect that it might not be the problem of the start keyword, but that the sentence was written incorrectly. Later, when I checked the same error on the Internet, I was inspired:

It turns out that this sentence has a semicolon (;)

The mybatis statement is not recognized by a semicolon (;) the


Solution:

Just remove the semicolon and modify it to:

<select id="selectDeptInfoBySId" resultMap="SecUserResultMap">
    select SID, SIDPARENT, DEPTTYPE, "NAME"
    from sec_user
    start with sid = #{sid,jdbcType=DECIMAL}
    connect by prior sidparent = sid
  </select>

Guess you like

Origin blog.csdn.net/weixin_42585386/article/details/114145981