ibatis-user-java mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bing Lu <mfcp...@yahoo.com>
Subject Re: abstract resultmap?
Date Sun, 30 Jul 2006 01:15:50 GMT
so let's say I want insert a Newspaper, I just call
insertDocument with Newspaper as parameter object? and
the insert will also insert newspaper related
attribute to the appropriate column name?

thanks a lot

--- Clinton Begin <clinton.begin@gmail.com> wrote:

> Yes, it can be abstract. But obviously you must
> ensure the query results
> never drop the map back to the base class (i.e with
> an unknown
> discriminator) otherwise you'll get an instantiation
> exception.
> 
> As for updates, if they're in the same table, then
> you can use the usual "if
> property exists" type dynamic conditionals.  If
> you're dealing with multiple
> tables, you'll have to write separate statements and
> call the appropriate
> ones -- it is just SQL at that point.  iBATIS
> doesn't do anything magical.
> 
> 
> Cheers,
> Clinton
> 
> On 7/29/06, Bing Lu <mfcplus@yahoo.com> wrote:
> >
> > so in the example testDomain.Document can be an
> > abstract class? And also if I want to
> insert/update a
> > book or newspaper what query do I call? I see
> > update/insertDocument but no update/insert
> operations
> > for books and Newspaper thanks
> >
> > <resultMap id="document"
> class="testdomain.Document">
> >     <result property="id" column="DOCUMENT_ID"/>
> >     <result property="title"
> column="DOCUMENT_TITLE"/>
> >     <result property="type"
> column="DOCUMENT_TYPE"/>
> >     <discriminator column="DOCUMENT_TYPE"
> > javaType="string" >
> >       <subMap value="Book" resultMap="book"/>
> >       <subMap value="Newspaper" resultMap="news"/>
> >     </discriminator>
> >   </resultMap>
> >
> > --- Clinton Begin <clinton.begin@gmail.com> wrote:
> >
> > > Yes, you can.
> > >
> > >
> > > On 7/29/06, Bing Lu <mfcplus@yahoo.com> wrote:
> > > >
> > > > so what if I have two classes that extends an
> > > abstract
> > > > class? that means I can't have a resultmap of
> the
> > > > abstract class with submaps of children still
> > > right?
> > > >
> > > > --- Clinton Begin <clinton.begin@gmail.com>
> wrote:
> > > >
> > > > > Well...what would it mean to support
> abstract
> > > type?
> > > > > That would be rather
> > > > > useless.  :-)
> > > > >
> > > > > I think what you're asking is to we support
> > > > > polymorphic queries, and the
> > > > > answer is YES.
> > > > >
> > > > > The wiki notes this as an undocumented
> feature:
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
http://opensource.atlassian.com/confluence/oss/display/IBATIS/Not+Yet+Documented
> > > > >
> > > > > You may find the unit tests helpful though,
> it's
> > > a
> > > > > pretty simple feature to
> > > > > use.
> > > > >
> > > > >
> > > >
> > > >
> > >
> >
> >
>
http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/maps/Documents.xml
> > > > >
> > > >
> > > >
> > >
> >
> >
>
http://svn.apache.org/repos/asf/ibatis/trunk/java/mapper/mapper2/test/com/ibatis/sqlmap/DiscriminatorTest.java
> > > > >
> > > > > Cheers,
> > > > > Clinton
> > > > >
> > > > > On 7/29/06, Bing Lu <mfcplus@yahoo.com>
> wrote:
> > > > > >
> > > > > > hi, does the mapper support abstract
> > > resultmaps?
> > > > > or
> > > > > > the class mapped must be instantiable
> > > > > >
> > > > > > thanks
> > > > > >
> > > > > >
> > >
> __________________________________________________
> > > > > > Do You Yahoo!?
> > > > > > Tired of spam?  Yahoo! Mail has the best
> spam
> > > > > protection around
> > > > > > http://mail.yahoo.com
> > > > > >
> > > > >
> > > >
> > > >
> > > >
> __________________________________________________
> > > > Do You Yahoo!?
> > > > Tired of spam?  Yahoo! Mail has the best spam
> > > protection around
> > > > http://mail.yahoo.com
> > > >
> > >
> >
> >
> > __________________________________________________
> > Do You Yahoo!?
> > Tired of spam?  Yahoo! Mail has the best spam
> protection around
> > http://mail.yahoo.com
> >
> 


__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Mime
View raw message