Hello,

is there any proper documentation on ibatis? All i found was a wiki-page with 30 pages or so and a small pdf. (If yes, could someone give me the url?)

Ok but here is my actual problem:

public class User extends ApplicationObject {
   ...
   private Map<UserData, UserField> userfields;
   ....
}

UserData is an Enumeration having a property "name". So basically a String but I use enums for type safety.

public enum UserData {
   ...
   private String name;

   UserData(String name) {
       this.name = name;
   }

UserField look like this:

public class UserField extends ApplicationObject {

   private UserData userdata;
   private String content;
   ....
}

Well to put the problem quite simple:

I need to fetch from the table userfield all fields that have a given user.id and map the name column there on UserData objects, at last put it all into a HashMap.
Now I wonder how I am supposed to write the mappings. So far I have:

in user.xml

  <resultMap id="selectAllResult" class="com.youmove.domain.user.User">
       <result property="id" column="user_id"/>
       <result property="name" column="name"/>
       <result property="surname" column="surname"/>
       <result property="nickname" column="nickname"/>
       <result property="password" column="password"/>
       <result property="email" column="email"/>
       <result property="phonenumber" column="phonenumber"/>
       <result property="userfields" ?BIGQUESTION?/>
   </resultMap>

Something like this would explain it best:
<result property="userfields" select="UserField.getFieldByUserId" /> and then map this all to a HashMap :-D


and of course I have also a userfield.xml with a result map.

<resultMap id="userFieldResult" class="com.youmove.domain.user.UserField">
       <result property="id" column="userfield_id"/>
       <result property="userdata" column="userdata"/>
       <result property="content" column="content"/>
       <result property="visibility" column="visibility"/>
   </resultMap>

<select id="getFieldByUserId" parameterClass="int" resultMap="userFieldResult">
       SELECT * FROM userfield WHERE user_id = #value#
   </select>

Or what is the best way to fetch the data? Maybe some type handlers or something. But again, I havent found any good documentation on it.

Cheers,
- Andreas


Reply via email to