You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user-java@ibatis.apache.org by Dan Turkenkopf <dt...@gmail.com> on 2008/12/04 02:25:57 UTC
Immutable objects in ResultMaps
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
application.
To my surprise, when I removed the setters from my domain object, everything
still seemed to work.
Did I miss this functionality being introduced?
Thanks,
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"
class="com.techegesis.immutable.domain.Master">
<result property="id" column="lahmanid"/>
<result property="firstName" column="nameFirst"/>
<result property="lastName" column="nameLast"/>
</resultMap>
<!-- Select with no parameters using the result map for Master class. -->
<select id="selectAllMasters" resultMap="MasterResult">
select * from MASTER
</select>
</sqlMap>
Re: Immutable objects in ResultMaps
Posted by Dan Turkenkopf <dt...@gmail.com>.
Wow.. I guess I did miss it. For some reason Google wasn't my friend. I
could only find people asking for it, and no record of it being given. :)
Thanks,
Dan
On Wed, Dec 3, 2008 at 8:57 PM, Jeff Butler <je...@gmail.com> wrote:
> See the release notes for version 2.2.0 - Clinton added support for
> private properties in August 2006! :)
>
> Jeff Butler
>
> On Wed, Dec 3, 2008 at 7:25 PM, Dan Turkenkopf <dt...@gmail.com> wrote:
> > 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
> > application.
> >
> > To my surprise, when I removed the setters from my domain object,
> everything
> > still seemed to work.
> >
> > Did I miss this functionality being introduced?
> >
> > Thanks,
> > 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"
> > class="com.techegesis.immutable.domain.Master">
> > <result property="id" column="lahmanid"/>
> > <result property="firstName" column="nameFirst"/>
> > <result property="lastName" column="nameLast"/>
> > </resultMap>
> >
> > <!-- Select with no parameters using the result map for Master class.
> -->
> > <select id="selectAllMasters" resultMap="MasterResult">
> > select * from MASTER
> > </select>
> >
> > </sqlMap>
> >
> >
> >
>
Re: Immutable objects in ResultMaps
Posted by Jeff Butler <je...@gmail.com>.
See the release notes for version 2.2.0 - Clinton added support for
private properties in August 2006! :)
Jeff Butler
On Wed, Dec 3, 2008 at 7:25 PM, Dan Turkenkopf <dt...@gmail.com> wrote:
> 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
> application.
>
> To my surprise, when I removed the setters from my domain object, everything
> still seemed to work.
>
> Did I miss this functionality being introduced?
>
> Thanks,
> 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"
> class="com.techegesis.immutable.domain.Master">
> <result property="id" column="lahmanid"/>
> <result property="firstName" column="nameFirst"/>
> <result property="lastName" column="nameLast"/>
> </resultMap>
>
> <!-- Select with no parameters using the result map for Master class. -->
> <select id="selectAllMasters" resultMap="MasterResult">
> select * from MASTER
> </select>
>
> </sqlMap>
>
>
>