{"action":"created","issue":{"url":"https://api.github.com/repos/mybatis/mybatis-3/issues/329","labels_url":"https://api.github.com/repos/mybatis/mybatis-3/issues/329/labels{/name}","comments_url":"https://api.github.com/repos/mybatis/mybatis-3/issues/329/comments","events_url":"https://api.github.com/repos/mybatis/mybatis-3/issues/329/events","html_url":"https://github.com/mybatis/mybatis-3/issues/329","id":54057378,"number":329,"title":"Maybe it is a bug. Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'","user":{"login":"someus","id":4159935,"avatar_url":"https://avatars.githubusercontent.com/u/4159935?v=3","gravatar_id":"","url":"https://api.github.com/users/someus","html_url":"https://github.com/someus","followers_url":"https://api.github.com/users/someus/followers","following_url":"https://api.github.com/users/someus/following{/other_user}","gists_url":"https://api.github.com/users/someus/gists{/gist_id}","starred_url":"https://api.github.com/users/someus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/someus/subscriptions","organizations_url":"https://api.github.com/users/someus/orgs","repos_url":"https://api.github.com/users/someus/repos","events_url":"https://api.github.com/users/someus/events{/privacy}","received_events_url":"https://api.github.com/users/someus/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":6,"created_at":"2015-01-12T14:11:22Z","updated_at":"2015-01-31T03:03:34Z","closed_at":"2015-01-16T04:04:02Z","body":"I used Mybatis 3.2.5 in a simple project. The structure of th project is :\r\n\r\n![img-01](https://cloud.githubusercontent.com/assets/4159935/5703923/90a236d2-9aa7-11e4-8ba6-0abdd951d157.png)\r\n\r\nThe content of `mybatis-config.xml` is\r\n```\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE configuration\r\n        PUBLIC \"-//mybatis.org//DTD Config 3.0//EN\"\r\n        \"http://mybatis.org/dtd/mybatis-3-config.dtd\">\r\n<configuration>\r\n    <environments default=\"development\">\r\n        <environment id=\"development\">\r\n            <transactionManager type=\"JDBC\"/>\r\n            <dataSource type=\"POOLED\">\r\n                <property name=\"driver\" value=\"com.mysql.jdbc.Driver\"/>\r\n                <property name=\"url\" value=\"jdbc:mysql://127.0.0.1:3306/blog_db?useUnicode=true&amp;characterEncoding=utf8\"/>\r\n                <property name=\"username\" value=\"root\"/>\r\n                <property name=\"password\" value=\"123\"/>\r\n            </dataSource>\r\n        </environment>\r\n    </environments>\r\n    <mappers>\r\n        <mapper resource=\"letian/mybatis/mapper/UserMapper.xml\"/>\r\n    </mappers>\r\n</configuration>\r\n```\r\n\r\nThe table `user` in `blog_db` has 2 records. \r\n```\r\nmysql> select * from user;\r\n+----+--------+----------------+----------+\r\n| id | name   | email          | password |\r\n+----+--------+----------------+----------+\r\n|  1 | letian | letian@111.com | 123      |\r\n|  2 | xiaosi | xiaosi@111.com | 123      |\r\n+----+--------+----------------+----------+\r\n2 rows in set (0.00 sec)\r\n```\r\n\r\nThe source code of `letian.mybatis.bean.User` is \r\n```\r\npackage letian.mybatis.bean;\r\n\r\npublic class User {\r\n\r\n    private int id;\r\n    private String name;\r\n    private String email;\r\n    private String password;\r\n\r\n    // ......\r\n    // getters and setters\r\n    // ......\r\n\r\n    @Override\r\n    public String toString() {\r\n        return \"User{\" +\r\n                \"id=\" + id +\r\n                \", name='\" + name + '\\'' +\r\n                \", email='\" + email + '\\'' +\r\n                \", password='\" + password + '\\'' +\r\n                '}';\r\n    }\r\n}\r\n```\r\n\r\nThe source code of `letian.mybatis.dao.UserMapper` is \r\n\r\n```\r\npackage letian.mybatis.dao;\r\n\r\nimport letian.mybatis.bean.User;\r\n\r\npublic interface UserMapper {\r\n\r\n    User findById(int id);\r\n}\r\n```\r\n\r\nThe source code of `letian/mybatis/mapper/UserMapper.xml` is \r\n```\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE mapper PUBLIC\r\n        \"-//mybatis.org//DTD Mapper 3.0//EN\"\r\n        \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\r\n\r\n<mapper namespace=\"letian.mybatis.dao.UserMapper\">\r\n    <select id=\"findById\" parameterType=\"HashMap\" resultType=\"letian.mybatis.bean.User\">\r\n        select\r\n        * from blog_db.user where id=#{id}\r\n    </select>\r\n</mapper>\r\n```\r\n\r\nThe source code of `Main.java` is \r\n\r\n```\r\nimport java.io.IOException;\r\n\r\nimport org.apache.ibatis.io.Resources;\r\nimport org.apache.ibatis.session.SqlSession;\r\nimport org.apache.ibatis.session.SqlSessionFactory;\r\nimport org.apache.ibatis.session.SqlSessionFactoryBuilder;\r\n\r\nimport letian.mybatis.bean.User;\r\nimport letian.mybatis.dao.UserMapper;\r\n\r\n\r\npublic class Main {\r\n\r\n    public static void main(String[] args) throws IOException {\r\n\r\n        SqlSessionFactory sessionFactory;\r\n        sessionFactory = new SqlSessionFactoryBuilder()\r\n                .build(Resources.getResourceAsReader(\"mybatis-config.xml\"));\r\n\r\n        SqlSession sqlSession = sessionFactory.openSession();\r\n        UserMapper userMapper = sqlSession.getMapper(UserMapper.class);\r\n        \r\n        User user = userMapper.findById(1);\r\n        System.out.println(user);\r\n\r\n    }\r\n}\r\n```\r\n\r\nMain.java could be executed correctly.  If the value of `parameterType` in `<select id=\"findById\">...</select>` in `letian/mybatis/mapper/UserMapper.xml` is set to `int` or `Integer`, `Main.java` could be executed correctly as well.\r\n\r\nHowever, if the content of `letian/mybatis/mapper/UserMapper.xml` is changed to \r\n\r\n```\r\n<?xml version=\"1.0\" encoding=\"UTF-8\" ?>\r\n<!DOCTYPE mapper PUBLIC\r\n        \"-//mybatis.org//DTD Mapper 3.0//EN\"\r\n        \"http://mybatis.org/dtd/mybatis-3-mapper.dtd\">\r\n\r\n<mapper namespace=\"letian.mybatis.dao.UserMapper\">\r\n\r\n    <select id=\"findById\" parameterType=\"HashMap\" resultType=\"letian.mybatis.bean.User\">\r\n        select * from\r\n        blog_db.user where\r\n        <choose>\r\n            <when test=\"id &lt; 0\">\r\n                id = 0-#{id}\r\n            </when>\r\n            <otherwise>\r\n                id = #{id}\r\n            </otherwise>\r\n        </choose>\r\n    </select>\r\n\r\n</mapper>\r\n```\r\n\r\n`Main.java` cannot be executed and I got the error as follows:\r\n\r\n```\r\nException in thread \"main\" org.apache.ibatis.exceptions.PersistenceException: \r\n### Error querying database.  Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'\r\n### Cause: org.apache.ibatis.reflection.ReflectionException: There is no getter for property named 'id' in 'class java.lang.Integer'\r\n......\r\n```\r\n\r\nIf the value of `parameterType` in `<select id=\"findById\">...</select>` in `letian/mybatis/mapper/UserMapper.xml` is set to `int` or `Integer`, `Main.java` cannot be executed as well.\r\n\r\nThough this problem was solved in a different way, I think it's an unreasonable implementation for MyBatis."},"comment":{"url":"https://api.github.com/repos/mybatis/mybatis-3/issues/comments/72301725","html_url":"https://github.com/mybatis/mybatis-3/issues/329#issuecomment-72301725","issue_url":"https://api.github.com/repos/mybatis/mybatis-3/issues/329","id":72301725,"user":{"login":"qq291462491","id":4670397,"avatar_url":"https://avatars.githubusercontent.com/u/4670397?v=3","gravatar_id":"","url":"https://api.github.com/users/qq291462491","html_url":"https://github.com/qq291462491","followers_url":"https://api.github.com/users/qq291462491/followers","following_url":"https://api.github.com/users/qq291462491/following{/other_user}","gists_url":"https://api.github.com/users/qq291462491/gists{/gist_id}","starred_url":"https://api.github.com/users/qq291462491/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/qq291462491/subscriptions","organizations_url":"https://api.github.com/users/qq291462491/orgs","repos_url":"https://api.github.com/users/qq291462491/repos","events_url":"https://api.github.com/users/qq291462491/events{/privacy}","received_events_url":"https://api.github.com/users/qq291462491/received_events","type":"User","site_admin":false},"created_at":"2015-01-31T03:03:34Z","updated_at":"2015-01-31T03:03:34Z","body":"+ 1，good！"}}