java - Is it possible to map POJO fields with names different from the table columns? -
i relatively new ibatis. know upgraded mybatis, reason have use ibatis. question "is possible map pojo fields names different table columns?"
i have table, mapping file, , pojo class. can read data if pojo class has names same columns in table, if name field else, not work. changed corresponding getter , defined resultmap in mapping file following
<resultmap id="result" class="subscriber"> <result column="advisorid" property="id" jdbctype="integer"/> <result column="firstname" property="firstname" jdbctype="varchar"/> <result column="lastname" property="lastname" jdbctype="varchar"/> <result column="emailid" property="emailid222" jdbctype="varchar"/> </resultmap> <select id="getall" resultmap="result"> select advisorid,firstname,lastname,emailid communication </select>
here example, trying rename emailid in pojo field emailid222
in subscriber class have define getter , setter methods field. careful use capital letters if necessary. have restart application make changes work. in case, should implement:
getemailid222(){...} setemailid222(string emailid222){...}
Comments
Post a Comment