1
org.apache.ibatis.exceptions.PersistenceException: 
### Error querying database.  Cause: java.lang.UnsupportedOperationException
### The error may exist in kr/co/techinmotion/mybatis/mappers/dataOutputMapper.xml
### The error may involve kr.co.techinmotion.mybatis.mappers.dataOutputMapper.selectData1-Inline
### The error occurred while setting parameters
### SQL: select * from tbl_id, tbl_feed     where tbl_id.id = tbl_feed.upid     and tbl_id.token = ?
### Cause: java.lang.UnsupportedOperationException
at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:23)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:107)
at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:98)
at kr.co.techinmotion.daoImpl.DataDaoImplMybatis.selectData1(DataDaoImplMybatis.java:47)

I don't know why this error occurred.

This is my sql in mapper.

<select id="selectData1" parameterType="string" resultType="list">
    select * from tbl_id, tbl_feed  
    where tbl_id.id = tbl_feed.upid  
    and tbl_id.token = #{token}
</select>

and.. this is DAO.

public class DataDaoImplMybatis implements IdataDao {

    private DataDaoImplMybatis(){}

    private static DataDaoImplMybatis dao;

    public static DataDaoImplMybatis getInstance(){
        if(dao == null){
            dao = new DataDaoImplMybatis();
        }

        return dao;
    }

    SqlSessionFactory sessionFactory = SqlMapSessionFactory.getSqlSessionFactory();

    @Override
    public List<DataResult1> selectData1(String token){
        SqlSession session = sessionFactory.openSession();
        List<DataResult1> list = session.selectList("kr.co.techinmotion.mybatis.mappers.dataOutputMapper.selectData1", token);
        session.close();

        return list;
    }

}

please help me.. T_T

5 Answers 5

2

The "MyBatis-3-User-Guide" says: resultType: The fully qualified class name or alias for the expected type that will be returned from this statement. Note that in the case of collections, this should be the type that the collection contains, not the type of the collection itself. Use resultType OR resultMap, not both.

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

Comments

1

In my case was that added 'useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true' in jdbc.url, that solved my issue:)

jdbc.url=jdbc:mysql://127.0.0.1:3306/xxx?useUnicode=true&characterEncoding=utf8&autoReconnect=true&allowMultiQueries=true

Comments

0

The resultType SHOULD NOT be list, the below shows the revised type, but you have to make sure the select statement can map to DataResult1 accordingly

<select id="selectData1" parameterType="string" resultType="DataResult1">
    select * from tbl_id, tbl_feed  
    where tbl_id.id = tbl_feed.upid  
    and tbl_id.token = #{token}
</select>

alternatively, you may try this:

<select id="selectData1" parameterType="string" resultType="map">
    select * from tbl_id, tbl_feed  
    where tbl_id.id = tbl_feed.upid  
    and tbl_id.token = #{token}
</select>

and the changes to the java source code

List<Map<String,Object> list = session.selectList("kr.co.techinmotion.mybatis.mappers.dataOutputMapper.selectData1", token);

1 Comment

And NEVER use select * in production - you are guaranteeing a future failure.
0

1 floor is right, but I want to say resultType = "" respect a row in your database but not all, perhaps you may select count(user_id) from user, now your resultType = 'long', if you select more than two results, you may use resultType = 'map' or yourself map, resultType = 'yourselfMap'

Comments

0

You have to declare the "jdbcType=VARCHAR" or "jdbcType=NUMERIC" of the variable depending upon the type of variable passed in order to pass the null value. Try using this:

<select id="selectData1" parameterType="string" resultType="map">
    select * from tbl_id, tbl_feed  
    where tbl_id.id = tbl_feed.upid  
    and tbl_id.token = #{token,jdbcType=VARCHAR}
</select>

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.