0

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.

James P.
  • 19,313
  • 27
  • 97
  • 155

1 Answers1

1

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?

rajah9
  • 11,645
  • 5
  • 44
  • 57
  • rajah9, I took the link as an example. Will test the code later. I managed to get another resultMap to work. I'm wondering if something weird is happening. For one, the name of the POJO contains the word map. For another, I just noticed that a table is missing a primary key. Will post back if I make some progress. – James P. Apr 10 '11 at 19:30
  • Oh no ... I just realized I left a "Map" prefix on a toString. Never again ^^ . – James P. Apr 10 '11 at 22:23
  • 1
    Glad you figured it out, @James P. MyBatis reminds me of a couplet from childhood: "Shake and shake the ketchup bottle / First none'll come out, and then a lot'll." Sometimes a modifier or an ancient library link will make MyBatis a decorative paperweight. Removing of said and MyBatis is flying. – rajah9 Apr 11 '11 at 12:51