Quantcast

How to use AND & OR operators in SELECT statement

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate
star

How to use AND & OR operators in SELECT statement

lenin
This post has NOT been accepted by the mailing list yet.
I am new in this framework on which am try to write the below query to get the value from database...am getting some exception...please help me
The query is

<select id="selectlike" resultType="contact">
                select
                        id, lastName, firstName, phone, email from contact
                           where id=#{values} AND firstname LIKE '%'|| ${firstname} ||'%'
        </select>

Exception is


### Error querying database.  Cause: org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter values of statement org.sample.mybatis.mappers.ContactMapper.selectlike
### The error may involve defaultParameterMap
### The error occurred while setting parameters
### Cause: org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter values of statement org.sample.mybatis.mappers.ContactMapper.selectlike
        at org.apache.ibatis.exceptions.ExceptionFactory.wrapException(ExceptionFactory.java:8)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:61)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:53)
        at org.apache.ibatis.binding.MapperMethod.executeForList(MapperMethod.java:82)
        at org.apache.ibatis.binding.MapperMethod.execute(MapperMethod.java:63)
        at org.apache.ibatis.binding.MapperProxy.invoke(MapperProxy.java:35)
        at $Proxy1.selectlike(Unknown Source)
        at org.sample.mybatis.mappers.Main.run(Main.java:78)
        at org.sample.mybatis.mappers.Main.main(Main.java:37)
Caused by: org.apache.ibatis.executor.ExecutorException: There was no TypeHandler found for parameter values of statement org.sample.mybatis.mappers.ContactMapper.selectlike
        at org.apache.ibatis.executor.parameter.DefaultParameterHandler.setParameters(DefaultParameterHandler.java:71)
        at org.apache.ibatis.executor.statement.PreparedStatementHandler.parameterize(PreparedStatementHandler.java:61)
        at org.apache.ibatis.executor.statement.RoutingStatementHandler.parameterize(RoutingStatementHandler.java:43)
        at org.apache.ibatis.executor.SimpleExecutor.prepareStatement(SimpleExecutor.java:56)
        at org.apache.ibatis.executor.SimpleExecutor.doQuery(SimpleExecutor.java:40)
        at org.apache.ibatis.executor.BaseExecutor.query(BaseExecutor.java:94)
        at org.apache.ibatis.executor.CachingExecutor.query(CachingExecutor.java:72)
        at org.apache.ibatis.session.defaults.DefaultSqlSession.selectList(DefaultSqlSession.java:59)
        ... 7 more
Loading...