Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 16982 invoked from network); 30 Jul 2006 01:04:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 30 Jul 2006 01:04:38 -0000 Received: (qmail 91560 invoked by uid 500); 30 Jul 2006 01:04:33 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 91543 invoked by uid 500); 30 Jul 2006 01:04:33 -0000 Mailing-List: contact user-java-help@ibatis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: user-java@ibatis.apache.org Delivered-To: mailing list user-java@ibatis.apache.org Received: (qmail 91532 invoked by uid 99); 30 Jul 2006 01:04:32 -0000 Received: from asf.osuosl.org (HELO asf.osuosl.org) (140.211.166.49) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jul 2006 18:04:32 -0700 X-ASF-Spam-Status: No, hits=0.5 required=10.0 tests=DNS_FROM_RFC_ABUSE,HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (asf.osuosl.org: domain of clinton.begin@gmail.com designates 64.233.182.185 as permitted sender) Received: from [64.233.182.185] (HELO nf-out-0910.google.com) (64.233.182.185) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 29 Jul 2006 18:04:31 -0700 Received: by nf-out-0910.google.com with SMTP id c31so165835nfb for ; Sat, 29 Jul 2006 18:04:09 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=t1/arB+P8mgWLhaGfa8yKi2yNhqf3ByDwgCsNmwtr7ioDih77KcQz8LKBMBgdom2LJB5lbqE4bT8r1bLSUUuEWhO0W/k7txCcAsWkydjE3vdeVXVYhcl4TO+VajJZ1K7KXbrmXevTXXVZk4xwNE6YjbvXARTB1hv+WetkHoY6WY= Received: by 10.78.193.19 with SMTP id q19mr199773huf; Sat, 29 Jul 2006 18:04:09 -0700 (PDT) Received: by 10.78.138.1 with HTTP; Sat, 29 Jul 2006 18:04:09 -0700 (PDT) Message-ID: <16178eb10607291804i1d210d94i9e065ed2b1a45639@mail.gmail.com> Date: Sat, 29 Jul 2006 19:04:09 -0600 From: "Clinton Begin" To: user-java@ibatis.apache.org Subject: Re: abstract resultmap? In-Reply-To: <20060730004005.97251.qmail@web60512.mail.yahoo.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_40562_2463949.1154221449416" References: <16178eb10607291730y6305d85ds5097d7cc4c6640e2@mail.gmail.com> <20060730004005.97251.qmail@web60512.mail.yahoo.com> X-Virus-Checked: Checked by ClamAV on apache.org X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N ------=_Part_40562_2463949.1154221449416 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline 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 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 > > > > > > javaType="string" > > > > > > > --- Clinton Begin wrote: > > > Yes, you can. > > > > > > On 7/29/06, Bing Lu 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 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 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 > ------=_Part_40562_2463949.1154221449416 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline 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

------=_Part_40562_2463949.1154221449416--