Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8797179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T23:47:54+00:00 2026-06-13T23:47:54+00:00

I’m getting this exception in MyBatis while trying to execute the update statement(UpdateUser): java.lang.ClassCastException:

  • 0

I’m getting this exception in MyBatis while trying to execute the update statement(UpdateUser):

java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Boolean
at $Proxy6.updateUser(Unknown Source)
at com.nortal.pirs.persistence.dbmybatis.UserDaoMyBatisImpl.updateUser(UserDaoMyBatisImpl.java:60)
at com.nortal.pirs.test.persistence.UserDaoAbstractTest.testUpdateUser(UserDaoAbstractTest.java:117)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:30)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

My Data type User with which I’m working looks like this:

public class User {
private String firstName = "";
private String lastName = "";
private String personCode = "";
private Date birthDate = new Date();
private Gender gender = Gender.MALE;
private String email = "";
private String password = "";
private UserState userState = UserState.UNAPPROVED;

public User() {
}

with the apropriate gettters and setters of course.

My UserMapper.java interface for mybatis looks as follows:

public interface UserMapper {

public User getUserByEmail(String email);   

public void addUser(User user);

public void removeUser(String email);

public int getNumberOfUsers();

public int userExists(String email);

public boolean updateUser(@Param ("oldUser") User oldUser, @Param("newUser") User newUser);

public Map<String, User> getAllUsers();

}

And my UserMapper.xml looks like this:

 <?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
  PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.nortal.pirs.persistence.dbmybatis.UserMapper">

    <!-- QUESTION: Is the <cache /> needed as described in one of your examples? And what is it meant to do? -->

    <resultMap id="UserMap" type="com.nortal.pirs.datamodel.User">
        <result property="firstName" column="firstName"/>
        <result property="lastName" column="lastName"/>
        <result property="personCode" column="personCode"/>
        <result property="birthDate" column="birthDate" javaType="Date"/>
        <result property="gender" column="gender" javaType="com.nortal.pirs.datamodel.Gender"/>
        <result property="email" column="email"/>
        <result property="password" column="password"/>
        <result property="userState" column="userState" javaType="com.nortal.pirs.datamodel.UserState"/>        
    </resultMap>

    <select id="getUserByEmail" parameterType="String" resultMap="UserMap">
        SELECT 
        firstName,
        lastName,
        personCode,
        birthDate,
        gender,
        email,
        password,
        userState       
        FROM   USER 
        WHERE  email = #{email}
    </select>

    <insert id="addUser" parameterType="User" >
        INSERT INTO user

        (firstName,
        lastName,
        personCode,
        birthDate,
        gender,
        email,
        password,
        userState)

        VALUES
        (#{firstName},
        #{lastName},
        #{personCode},
        #{birthDate},
        #{gender},
        #{email},
        #{password},
        #{userState})        
    </insert>

    <delete id="removeUser" parameterType="String">
        DELETE FROM user
        WHERE email = #{email}
    </delete>


    <select id="getNumberOfUsers" resultType="int">
        SELECT
        COUNT(email)
        FROM USER
    </select>

    <select id="userExists" parameterType="String" resultType="int">
        SELECT CASE WHEN EXISTS (
            SELECT
            COUNT(email)
            FROM USER)
    </select>

    <update id="updateUser" parameterType="map">
        UPDATE user
        SET 
        firstName = #{newUser.firstName},
        lastName = #{newUser.lastName},
        personCode = #{newUser.personCode},
        birthDate = #{newUser.birthDate},
        gender = #{newUser.gender},
        email = #{newUser.email},
        password = #{newUser.password},
        userState = #{newUser.userState}
        WHERE email = #{oldUser.email}
    </update>

</mapper>

as I’ve mentioned the exception is thrown when updateUser is called. The strange thing is I can’t even see anything Integer related here. I mean I even tried testing with just updating one field. It’s all the same. I don’t get the exception only if the query is totally removed, I would get the query error or something error…

Any suggestions? Thanks in advance.

Edit: if people are voting my question down without saying anything, they should at least tell what was wrong with the question, that would be more helpful… I haven’t posted this question out of fun. Indeed I’m kinda stuck on this for some time now…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T23:47:55+00:00Added an answer on June 13, 2026 at 11:47 pm

    UPDATE query does not return a boolean type. It returns an integer depicting the number of rows successfully updated. And you have given a return type of boolean to your updateUser which is using UPDATE query.

    Change the return type of updateUser to int. I hope that would work then.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am trying to understand how to use SyndicationItem to display feed which is
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am trying to render a haml file in a javascript response like so:
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.