ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dan Turkenkopf" <dturk...@gmail.com>
Subject Immutable objects in ResultMaps
Date Thu, 04 Dec 2008 01:25:57 GMT
Maybe I'm just missing something, but I thought that iBATIS required the
objects used in a result map to have declared setters.

I was in the process if I could figure out a way to use a builder pattern to
get immutable objects through iBATOR and was working my way through a sample

To my surprise, when I removed the setters from my domain object, everything
still seemed to work.

Did I miss this functionality being introduced?

Dan Turkenkopf

Here's my domain object:

public class Master {

    private String id;
    private String firstName;
    private String lastName;

     * @return the firstName
    public String getFirstName() {
        return firstName;
     * @return the id
    public String getId() {
        return id;
     * @return the lastName
    public String getLastName() {
        return lastName;

And here's my SQL Map:

<sqlMap namespace="Master">

  <!-- Result maps describe the mapping between the columns returned
       from a query, and the class properties.  A result map isn't
       necessary if the columns (or aliases) match to the properties
       exactly. -->
  <resultMap id="MasterResult"
    <result property="id" column="lahmanid"/>
    <result property="firstName" column="nameFirst"/>
    <result property="lastName" column="nameLast"/>

  <!-- Select with no parameters using the result map for Master class. -->
  <select id="selectAllMasters" resultMap="MasterResult">
    select * from MASTER


View raw message