Search code examples
javaibatisresultset

IBatis: resultMap not being taken into account


I've been trying to get iBatis to return a list of POJOs like on this link:

http://www.java2s.com/Code/Java/J2EE/GetListOfObjects.htm

All I'm getting in return is a list of Map instances. Is there something I might be missing that usually baffles people learning this framework?

P.S: Not in front of my home pc right now. Will be happy to give additional info when I get back.


Solution

  • FWIW, I think iBatis has a steep learning curve but becomes very useful once you get over the hump.

    These two methods and two files might be of help.

    SqlSessionFactory: gets resource files and sets up the environment

    SqlSession: opens a session (based on SqlSessionFactory)

    Mapper: generated (or hand-built) Interface file to map the DB table to java. Helps CRUD by example.

    Example: generated (or hand-built) java file to complete the Where clause for any column

    The sqlMapper.queryForList("selectAllAccounts"); will look at the <select id="selectAllAccounts" resultMap="AccountResult"> in the Account.xml file.

    Are you getting the same results or different from the util.checkData call and the iBatis call?