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 ma...@checkfree.com on 2005/08/03 15:59:55 UTC
Embedding ResultMaps
Is there a way to embed result maps within parent result maps? The reason I
ask is that I have found that for large projects, SqlMaps can be
problematic to maintain when you have multiple classes that maintain
references to the same object or objects. For example suppose that I have a
user class and an address class. Now both class a and class b have
references to user and address and therefore have copies of the user and
address resultmaps included in their own result map. This is problematic
when you need to change a property in the base result map for either user
or address because you now have to find all other resultmaps(objects) that
maintain a reference to these objects and update those result maps as well.
I realize that you can extend a result map but that seems overly limiting
if you can only extend one resultmap at a time. Is there instead a way to
embed references to other resultmaps within a given resultmap? I cannot
believe that I am the only one who has run into this issue/concern, so
either I am missing something or it seems to be a limitation of the
product. Any feedback or best practices suggestion would be appreciated.
Thanks.
Michael A. Harris
Michael A. Harris
Manager, Software Development
maharris@checkfree.com
Phone: (614) 564-3138
Cell: (614) 397-0445
Pager: maharris@mycingular.blackberry.net
CheckFree. The Company that Powers Payment on the WebSM.
http://www.checkfree.com/paybillsonline
Re: Embedding ResultMaps
Posted by ma...@checkfree.com.
I don't think that is the problem (unless I am just not understanding
something). Let me give a better example.
Suppose I have this.
<resultMap class="com.ffblitz.ff.data.dc.FflRosterPlayer"
id="getFflRosterPlayerResult">
<result property="week" column="ftr.week"/>
<result property="rosterStatusCode"
column="ftr.roster_status_cd"/>
<result property="injuryStatusCode" column="ir.injury_cd"/>
<result property="injuryStatusDescription"
column="nis.description"/>
<result property="injuryStatusDetail"
column="ir.injury_detail"/>
<!-- From FFlLeague table -->
<result property="rosterLockBuffer"
column="fl.roster_auto_lock_buffer"/>
<!-- NflPlayer Object -->
<result property="nflPlayer.playerId"
column="np.nfl_player_id"/>
<result property="nflPlayer.lastName" column="np.last_name"/>
<result property="nflPlayer.firstName" column="np.first_name"/>
<result property="nflPlayer.jerseyName"
column="np.jersey_name"/>
<result property="nflPlayer.positionCode"
column="np.position_cd"/>
<result property="nflPlayer.playerType"
column="np.player_type"/>
<result property="nflPlayer.nflTeam.teamCode"
column="nt.nfl_team_cd"/>
<result property="nflPlayer.nflTeam.name" column="nt.name"/>
<result property="nflPlayer.nflTeam.conference"
column="nt.conference"/>
<result property="nflPlayer.nflTeam.division"
column="nt.division"/>
<result property="nflPlayer.nflTeam.smallImageUrl"
column="nt.image_sm_url"/>
<result property="nflPlayer.nflTeam.largeImageUrl"
column="nt.image_lg_url"/>
<result property="nflPlayer.nflTeam.byeWeek"
column="nt.bye_week"/>
<!-- FflTeam Object -->
<result property="fflTeam.fflTeamId" column="ft.ffl_team_id"/>
<result property="fflTeam.leagueId" column="ft.league_id"/>
<result property="fflTeam.teamName" column="ft.name"/>
<result property="fflTeam.slogan" column="ft.slogan"/>
<result property="fflTeam.imageUrl" column="ft.image_url"/>
<result property="fflTeam.fflUser.userId"
column="fu.ffl_user_id"/>
<result property="fflTeam.fflUser.lastName"
column="fu.last_name"/>
<result property="fflTeam.fflUser.firstName"
column="fu.first_name"/>
<result property="fflTeam.fflUser.screenName"
column="fu.screen_name"/>
<result property="fflTeam.fflUser.emailAddress"
column="fu.email_address"/>
<result property="fflTeam.fflUser.phoneNumber"
column="fu.phone_num"/>
<result property="fflTeam.fflUser.loginName"
column="fu.login_name"/>
<result property="fflTeam.fflUser.password"
column="fu.login_password"/>
<result property="fflTeam.fflUser.passwordQuestion"
column="fu.password_question"/>
<result property="fflTeam.fflUser.passwordAnswer"
column="fu.password_answer"/>
<result property="fflTeam.fflUser.emailVerified"
column="fu.email_verified"/>
<result property="fflTeam.fflUser.emailAlertsEnabled"
column="fu.send_email_notify"/>
<result property="fflTeam.fflUser.userRole" column="fu.role"/>
<result property="fflTeam.fflUser.leagueListEnabled"
column="fu.show_league_list"/>
</resultMap>
NflPlayer and FflTeam are straight cut and paste from their respective
resultmaps. I would hope that I could do something like this:
<resultMap class="com.ffblitz.ff.data.dc.FflRosterPlayer"
id="getFflRosterPlayerResult">
<result property="week" column="ftr.week"/>
<result property="rosterStatusCode"
column="ftr.roster_status_cd"/>
<result property="injuryStatusCode" column="ir.injury_cd"/>
<result property="injuryStatusDescription"
column="nis.description"/>
<result property="injuryStatusDetail"
column="ir.injury_detail"/>
<!-- From FFlLeague table -->
<result property="rosterLockBuffer"
column="fl.roster_auto_lock_buffer"/>
<!-- NflPlayer Object -->
<result resultMap="NflPlayerResultMap"/> ********* change here
<!-- FflTeam Object -->
<result resultMap="FflTeamResultMap"/>
</resultMap>
Without this capability I am required to cut and paste object reference
resultmaps all over the place. It becomes particularly bad when you want
to add a column to or modify one of the properties in the result map that
you have cut and pasted everywhere. I think you can see as well how single
inheritance doesn't really help in this case. Any suggestions are much
appreciated. Thanks.
Michael A. Harris
Manager, Software Development
maharris@checkfree.com
Phone: (614) 564-3138
Cell: (614) 397-0445
Pager: maharris@mycingular.blackberry.net
CheckFree. The Company that Powers Payment on the WebSM.
http://www.checkfree.com/paybillsonline
Ron Grabowski
<rongrabowski@yah
oo.com> To
user-java@ibatis.apache.org
08/03/2005 10:05 cc
AM
Subject
Re: Embedding ResultMaps
Please respond to
user-java@ibatis.
apache.org
It should be possible to reference a resultMap in another file if you
use the complete namespace. Have you tried that?
--- maharris@checkfree.com wrote:
>
> Is there a way to embed result maps within parent result maps? The
> reason I
> ask is that I have found that for large projects, SqlMaps can be
> problematic to maintain when you have multiple classes that maintain
> references to the same object or objects. For example suppose that I
> have a
> user class and an address class. Now both class a and class b have
> references to user and address and therefore have copies of the user
> and
> address resultmaps included in their own result map. This is
> problematic
> when you need to change a property in the base result map for either
> user
> or address because you now have to find all other resultmaps(objects)
> that
> maintain a reference to these objects and update those result maps as
> well.
> I realize that you can extend a result map but that seems overly
> limiting
> if you can only extend one resultmap at a time. Is there instead a
> way to
> embed references to other resultmaps within a given resultmap? I
> cannot
> believe that I am the only one who has run into this issue/concern,
> so
> either I am missing something or it seems to be a limitation of the
> product. Any feedback or best practices suggestion would be
> appreciated.
> Thanks.
>
>
> Michael A. Harris
>
>
> Michael A. Harris
> Manager, Software Development
> maharris@checkfree.com
> Phone: (614) 564-3138
> Cell: (614) 397-0445
> Pager: maharris@mycingular.blackberry.net
>
> CheckFree. The Company that Powers Payment on the WebSM.
> http://www.checkfree.com/paybillsonline
Re: Embedding ResultMaps
Posted by Ron Grabowski <ro...@yahoo.com>.
It should be possible to reference a resultMap in another file if you
use the complete namespace. Have you tried that?
--- maharris@checkfree.com wrote:
>
> Is there a way to embed result maps within parent result maps? The
> reason I
> ask is that I have found that for large projects, SqlMaps can be
> problematic to maintain when you have multiple classes that maintain
> references to the same object or objects. For example suppose that I
> have a
> user class and an address class. Now both class a and class b have
> references to user and address and therefore have copies of the user
> and
> address resultmaps included in their own result map. This is
> problematic
> when you need to change a property in the base result map for either
> user
> or address because you now have to find all other resultmaps(objects)
> that
> maintain a reference to these objects and update those result maps as
> well.
> I realize that you can extend a result map but that seems overly
> limiting
> if you can only extend one resultmap at a time. Is there instead a
> way to
> embed references to other resultmaps within a given resultmap? I
> cannot
> believe that I am the only one who has run into this issue/concern,
> so
> either I am missing something or it seems to be a limitation of the
> product. Any feedback or best practices suggestion would be
> appreciated.
> Thanks.
>
>
> Michael A. Harris
>
>
> Michael A. Harris
> Manager, Software Development
> maharris@checkfree.com
> Phone: (614) 564-3138
> Cell: (614) 397-0445
> Pager: maharris@mycingular.blackberry.net
>
> CheckFree. The Company that Powers Payment on the WebSM.
> http://www.checkfree.com/paybillsonline