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 Joachim Hoffmann <j....@mine-it.at> on 2005/09/13 16:37:49 UTC

defaultMap: reuse "resultMap" for std CRUD

My primary objective to have a look at iBatis was  to type less for 
sql-jdbc-object mappings.
Therefore...
I wonder if it would possible in iBatis to define a default mapping, 
e.g. <defaultMap>,
which in turn could be reused for implicitly defined, standard instances 
of  insert/update/delete?

As far as I understood from the manuals there is a similar  feature for
<statement ... resultMap= ... > SELECT * FROM table </statement>

This would avoid that you have to re-type parts of the mapping inside 
the SQL statements
for insert, update, delete.

e.g.
<defaultMap id="dmAccountObject" ...>
     ... defined like resultMap, first Attribute is ObjID/PKey, etc. ...
</defaultMap>

<update>  id="defaultUpdate" defaultMap="dmAccountObject> </update>

instead of

<update id="updateAccount" parameterClass="account">
    update ACCOUNT set LANGPREF = #languagePreference#, FAVCATEGORY = 
#favouriteCategoryId#,
    MYLISTOPT = #listOption#, BANNEROPT = #bannerOption# where USERID = 
#username#
 </update>


Kind Regards,
JoHo


Re: defaultMap: reuse "resultMap" for std CRUD

Posted by Ron Grabowski <ro...@yahoo.com>.
 IBatisNet.DataMapper.Configuration.Statements.SqlGenerator

Now you have to tell me where Java's groupBy attribute is implemented.
:)

--- Larry Meadors <la...@gmail.com> wrote:

> Hey Ron, where is that code in the .net version? I would like to get
> this done...
> 
> Larry
> 
> On 9/13/05, Ron Grabowski <ro...@yahoo.com> wrote:
> > The .Net port of ibatis supports a generate tag:
> > 
> >  <update id="Update" parameterMap="update-generate-params">
> >   <generate table="Categories" by="Category_Id"/>
> >  </update>
> > 
> > That will automatically generate a generic:
> > 
> >  UPDATE Categories SET...
> > 
> > sql statement. I believe it also supports generating DELETE and
> SELECT
> > statements.
> > 
> > Perhaps you can look into porting this code to the Java version.
> > 
> > --- Joachim Hoffmann <j....@mine-it.at> wrote:
> > 
> > > My primary objective to have a look at iBatis was  to type less
> for
> > > sql-jdbc-object mappings.
> > > Therefore...
> > > I wonder if it would possible in iBatis to define a default
> mapping,
> > > e.g. <defaultMap>,
> > > which in turn could be reused for implicitly defined, standard
> > > instances
> > > of  insert/update/delete?
> > >
> > > As far as I understood from the manuals there is a similar 
> feature
> > > for
> > > <statement ... resultMap= ... > SELECT * FROM table </statement>
> > >
> > > This would avoid that you have to re-type parts of the mapping
> inside
> > >
> > > the SQL statements
> > > for insert, update, delete.
> > >
> > > e.g.
> > > <defaultMap id="dmAccountObject" ...>
> > >      ... defined like resultMap, first Attribute is ObjID/PKey,
> etc.
> > > ...
> > > </defaultMap>
> > >
> > > <update>  id="defaultUpdate" defaultMap="dmAccountObject>
> </update>
> > >
> > > instead of
> > >
> > > <update id="updateAccount" parameterClass="account">
> > >     update ACCOUNT set LANGPREF = #languagePreference#,
> FAVCATEGORY =
> > >
> > > #favouriteCategoryId#,
> > >     MYLISTOPT = #listOption#, BANNEROPT = #bannerOption# where
> USERID
> > > =
> > > #username#
> > >  </update>
> > >
> > >
> > > Kind Regards,
> > > JoHo
> > >
> > >
> > 
> >
> 


Re: defaultMap: reuse "resultMap" for std CRUD

Posted by Larry Meadors <la...@gmail.com>.
Hey Ron, where is that code in the .net version? I would like to get
this done...

Larry

On 9/13/05, Ron Grabowski <ro...@yahoo.com> wrote:
> The .Net port of ibatis supports a generate tag:
> 
>  <update id="Update" parameterMap="update-generate-params">
>   <generate table="Categories" by="Category_Id"/>
>  </update>
> 
> That will automatically generate a generic:
> 
>  UPDATE Categories SET...
> 
> sql statement. I believe it also supports generating DELETE and SELECT
> statements.
> 
> Perhaps you can look into porting this code to the Java version.
> 
> --- Joachim Hoffmann <j....@mine-it.at> wrote:
> 
> > My primary objective to have a look at iBatis was  to type less for
> > sql-jdbc-object mappings.
> > Therefore...
> > I wonder if it would possible in iBatis to define a default mapping,
> > e.g. <defaultMap>,
> > which in turn could be reused for implicitly defined, standard
> > instances
> > of  insert/update/delete?
> >
> > As far as I understood from the manuals there is a similar  feature
> > for
> > <statement ... resultMap= ... > SELECT * FROM table </statement>
> >
> > This would avoid that you have to re-type parts of the mapping inside
> >
> > the SQL statements
> > for insert, update, delete.
> >
> > e.g.
> > <defaultMap id="dmAccountObject" ...>
> >      ... defined like resultMap, first Attribute is ObjID/PKey, etc.
> > ...
> > </defaultMap>
> >
> > <update>  id="defaultUpdate" defaultMap="dmAccountObject> </update>
> >
> > instead of
> >
> > <update id="updateAccount" parameterClass="account">
> >     update ACCOUNT set LANGPREF = #languagePreference#, FAVCATEGORY =
> >
> > #favouriteCategoryId#,
> >     MYLISTOPT = #listOption#, BANNEROPT = #bannerOption# where USERID
> > =
> > #username#
> >  </update>
> >
> >
> > Kind Regards,
> > JoHo
> >
> >
> 
>

Re: defaultMap: reuse "resultMap" for std CRUD

Posted by Ron Grabowski <ro...@yahoo.com>.
The .Net port of ibatis supports a generate tag:

 <update id="Update" parameterMap="update-generate-params">
  <generate table="Categories" by="Category_Id"/>
 </update>

That will automatically generate a generic:

 UPDATE Categories SET...

sql statement. I believe it also supports generating DELETE and SELECT
statements.

Perhaps you can look into porting this code to the Java version.

--- Joachim Hoffmann <j....@mine-it.at> wrote:

> My primary objective to have a look at iBatis was  to type less for 
> sql-jdbc-object mappings.
> Therefore...
> I wonder if it would possible in iBatis to define a default mapping, 
> e.g. <defaultMap>,
> which in turn could be reused for implicitly defined, standard
> instances 
> of  insert/update/delete?
> 
> As far as I understood from the manuals there is a similar  feature
> for
> <statement ... resultMap= ... > SELECT * FROM table </statement>
> 
> This would avoid that you have to re-type parts of the mapping inside
> 
> the SQL statements
> for insert, update, delete.
> 
> e.g.
> <defaultMap id="dmAccountObject" ...>
>      ... defined like resultMap, first Attribute is ObjID/PKey, etc.
> ...
> </defaultMap>
> 
> <update>  id="defaultUpdate" defaultMap="dmAccountObject> </update>
> 
> instead of
> 
> <update id="updateAccount" parameterClass="account">
>     update ACCOUNT set LANGPREF = #languagePreference#, FAVCATEGORY =
> 
> #favouriteCategoryId#,
>     MYLISTOPT = #listOption#, BANNEROPT = #bannerOption# where USERID
> = 
> #username#
>  </update>
> 
> 
> Kind Regards,
> JoHo
> 
>