Return-Path: Delivered-To: apmail-ibatis-user-java-archive@www.apache.org Received: (qmail 72869 invoked from network); 16 Jun 2005 08:55:38 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (209.237.227.199) by minotaur.apache.org with SMTP; 16 Jun 2005 08:55:38 -0000 Received: (qmail 70514 invoked by uid 500); 16 Jun 2005 08:55:34 -0000 Delivered-To: apmail-ibatis-user-java-archive@ibatis.apache.org Received: (qmail 70488 invoked by uid 500); 16 Jun 2005 08:55: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 70372 invoked by uid 99); 16 Jun 2005 08:55:29 -0000 X-ASF-Spam-Status: No, hits=0.1 required=10.0 tests=FORGED_RCVD_HELO,HTML_MESSAGE X-Spam-Check-By: apache.org Received-SPF: pass (hermes.apache.org: local policy) Received: from dsl-083-247-021-091.solcon.nl (HELO wis.nl) (83.247.21.91) by apache.org (qpsmtpd/0.28) with ESMTP; Thu, 16 Jun 2005 01:55:28 -0700 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C57243.E6F77BE2" Subject: RE: Possibilities and/or impossibilities of subclassing X-MimeOLE: Produced By Microsoft Exchange V6.5.7226.0 Date: Thu, 16 Jun 2005 09:20:40 +0200 Message-ID: <50CA25BD6EEA954FA592C097399942E30BCE26@CM1.wis.local> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: Possibilities and/or impossibilities of subclassing Thread-Index: AcVx/zTiS/bBIVHwRQ2XTTD7sMCcrwAP/iZg From: "Niels Beekman" To: , "Roberto R" X-Virus-Checked: Checked X-Spam-Rating: minotaur.apache.org 1.6.2 0/1000/N This is a multi-part message in MIME format. ------_=_NextPart_001_01C57243.E6F77BE2 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable Hi, =20 Actually I only need a solution for select; the other types are handled in the DAO. Let's assume the following classes exist. =20 Class A { id propertyA_1 propertyA_2 type } =20 Class B extends A { propertyB_1 propertyB_2 propertyB_3 } =20 The following resultmaps are defined: =20 =20 What I would like to have is a way to do two things: * writing a statement that joins A and B directly (when I know the type in advance) * writing a statement that queries only A (when I do not know the type) =20 The first one is not a problem and works perfectly well, with and without a discriminator defined. The second one is where my problem is, I want to execute a statement that specifies class A as a result, iBATIS encounters the discriminator and checks which properties are required, when not all properties are available in the resultset, it should execute a second statement which fetches the additional properties required by the subclass (B in the example). This statement could be specified as attribute in the subMap-tag. =20 Below is what I think the resulting sqlMap looks like: =20 =20 =20 When I execute B_get, all values are already available, so no additional statement is required, the query produces class B. When I execute A_get, only the type is available, iBATIS detects which resultMap is required using the discriminator, and checks whether all columns are available, this is not the case, so B_get gets executed, now all columns are available, the query produces class B, when not all columns are available, iBATIS first checks for a nested discriminator, otherwise throws an error. =20 I hope you understand from this lengthy post what I would like to see added to iBATIS. I know iBATIS is not an O/R-mapper, so I don't expect behaviour ala JDO at all, but would really like to see a solution for ISA, as this is a common scenario, especially in our application. =20 Let me know your thoughts, =20 Niels =20 ________________________________ From: Roberto R [mailto:roberto.rabe@gmail.com]=20 Sent: donderdag 16 juni 2005 1:09 To: user-java@ibatis.apache.org Subject: Re: Possibilities and/or impossibilities of subclassing =20 Hi. Would it be possible for you to provide an example of what you'd like the DataMapper to do (select, insert, update, and delete scenarios)? Roberto On 6/15/05, Niels Beekman wrote: Yes, that is also the answer I was looking for but nothing is mentioned about _how_ to implement a table per subclass, and additionally, the .NET-docs are updated again (v1.2.1) and now state the following: * resultMap for each class=20 * resultMap with submaps for a class hierarchy * resultMap with extended resultMaps for each subclass Which does not even state the word 'table' anymore, and the possibilities now listed are what I've figured out myself, but=20 unfortunately these are not sufficient for me. Thanks for the answer, Niels -----Original Message----- From: Ron Grabowski [mailto:rongrabowski@yahoo.com ] Sent: woensdag 15 juni 2005 14:18 To: user-java@ibatis.apache.org Subject: Re: Possibilities and/or impossibilities of subclassing The next message in the thread had a list of three cases where the=20 discriminator might come in handy: * table per class hierarchy * table per subclass * table per concrete class That's the answer I was looking for. I believe both the .Net and Java version now have the same level of suppor for discriminators. Although=20 I did noticed that the Java version specifies them like this: While the .Net version does it like this:=20 Which leads me to believe the .Net version only allows for one discriminator per resultMap ??? That's what I remember seeing at some=20 point. --- Niels Beekman wrote: > Hi, > > Could you guys please clarify some of the possibilities and > unpossibilities of iBATIS when it comes to subclassing?. What I=20 > understand from the various documentation-fragments is that iBATIS > only > supports discriminators when all columns are available in a single > resultset. How would this work when I have an ISA-design with let's=20 > say > 10 different subtables, this would result in enormous amounts of > data... > > Is there any documentation that I have missed somehow? I saw it on > the > undocumented features-list, but maybe there is some after all. I=20 > looked > at the provided Documentation.xml but this is an example with just > one > table, which is not I'm looking for. I even checked the .NET > documentation too, the discriminator is mentioned there, but not in=20 > the > context of subtables (and I heard that iBATIS.NET has more features > when > it comes to subclassing). > > I hope you can shed some light on this, otherwise it requires some=20 > workarounds on my end. > > Thanks for your time, > > Niels > > PS I tried to contact Ron for his solution > ( http://www.mail-archive.com/ibatis-dev%40incubator.apache.org/msg01014 . > html) to this problem, as he said he was helped "off list" but could > not > reach him. > =20 ------_=_NextPart_001_01C57243.E6F77BE2 Content-Type: text/html; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable

Hi,

 

Actually I only need a solution for = select; the other types are handled in the DAO. Let’s assume the following classes exist.

 

Class A = {

  = id

  = propertyA_1

  = propertyA_2

  = type

}

 

Class B extends A = {

  = propertyB_1

  = propertyB_2

  = propertyB_3

}

 

The following resultmaps are = defined:

 

<resultMap = id=3D”resultMap_A” class=3D”A”>

  <result = property=3D”id” column=3D”id”/>

  <result = property=3D”propertyA_1” column=3D”propertyA_1”/>

  <result = property=3D”propertyA_2” column=3D”propertyA_2”/>

  <discriminator = column=3D”type” javaType=3D"int">

    <subMap = value=3D"1" resultMap=3D"resultMap_B"/>

  = </discriminator>

</resultMap>=

<resultMap = id=3D”resultMap_B” class=3D”B” = extends=3D”resultMap_A”>

  <result = property=3D”propertyB_1” column=3D”propertyB_1”/>

  <result = property=3D”propertyB_2” column=3D”propertyB_2”/>

  <result = property=3D”propertyB_3” column=3D”propertyB_3”/>

</resultMap>=

 

What I would like to have is a way = to do two things:

* writing a statement that joins A = and B directly (when I know the type in advance)

* writing a statement that queries = only A (when I do not know the type)

 

The first one is not a problem and = works perfectly well, with and without a discriminator defined. The second one = is where my problem is, I want to execute a statement that specifies class = A as a result, iBATIS encounters the discriminator and checks which properties = are required, when not all properties are available in the resultset, it = should execute a second statement which fetches the additional properties = required by the subclass (B in the example). This statement could be specified as = attribute in the subMap-tag.

 

Below is what I think the resulting = sqlMap looks like:

 

<resultMap = id=3D”resultMap_A” class=3D”A”>

  <result = property=3D”id” column=3D”id”/>

  <result = property=3D”propertyA_1” column=3D”propertyA_1”>

  <result = property=3D”propertyA_2” column=3D”propertyA_2”>

  <discriminator = column=3D”type” javaType=3D"int">

    <subMap = value=3D"1" resultMap=3D"resultMap_B" = select=3D”B_get”/>

  = </discriminator>

</resultMap>=

<resultMap = id=3D”resultMap_B” class=3D”B” = extends=3D”resultMap_A”>

  <result = property=3D”propertyB_1” column=3D”propertyB_1”>

  <result = property=3D”propertyB_2” column=3D”propertyB_2”>

  <result = property=3D”propertyB_3” column=3D”propertyB_3”>

</resultMap>=

 

<select id=3D"A_get" parameterClass=3D"int" = resultClass=3D"A">

  SELECT = type

  FROM = A

  WHERE id =3D = #value#

</select>

<select id=3D"B_get" parameterClass=3D"int" = resultClass=3D"B">

  SELECT = *

  FROM A, = B

  WHERE A.id =3D = B.id

  AND A.id =3D = #value#

</select>

 

When I execute B_get, all values = are already available, so no additional statement is required, the query = produces class B.

When I execute A_get, only the type = is available, iBATIS detects which resultMap is required using the = discriminator, and checks whether all columns are available, this is not the case, so = B_get gets executed, now all columns are available, the query produces class = B, when not all columns are available, iBATIS first checks for a nested = discriminator, otherwise throws an error.

 

I hope you understand from this = lengthy post what I would like to see added to iBATIS. I know iBATIS is not an O/R-mapper, so I don’t expect behaviour ala JDO at all, but would = really like to see a solution for ISA, as this is a common scenario, especially = in our application.

 

Let me know your = thoughts,

 

Niels

 


From: = Roberto R [mailto:roberto.rabe@gmail.com]
Sent: donderdag 16 juni = 2005 1:09
To: = user-java@ibatis.apache.org
Subject: Re: = Possibilities and/or impossibilities of subclassing

 

Hi.  = Would it be possible for you to provide an example of what you'd like the DataMapper = to do (select, insert, update, and delete scenarios)?

Roberto

On 6/15/05, Niels Beekman = <niels@wis.nl> = wrote:

Yes, that is = also the answer I was looking for but nothing is mentioned
about _how_ to implement a table per subclass, and additionally, the
.NET-docs are updated again (v1.2.1) and now state the following:

* resultMap for each class
* resultMap with submaps for a class hierarchy
* resultMap with extended resultMaps for each subclass

Which does not even state the word 'table' anymore, and the
possibilities now listed are what I've figured out myself, but
unfortunately these are not sufficient for me.

Thanks for the answer,

Niels

-----Original Message-----
From: Ron Grabowski [mailto:rongrabowski@yahoo.com ]
Sent: woensdag 15 juni 2005 14:18
To: user-java@ibatis.apache.org
Subject: Re: Possibilities and/or impossibilities of subclassing

The next message in the thread had a list of three cases where the
discriminator might come in handy:

* table per class hierarchy
* table per subclass
* table per concrete class

That's the answer I was looking for. I believe both the .Net and = Java
version now have the same level of suppor for discriminators. Although =
I did noticed that the Java version specifies them like this:

<discriminator>
  <submap />
  <submap />
  <submap />
</discriminator>

While the .Net version does it like this:

<discriminator />
<submap />
<submap />
<submap />

Which leads me to believe the .Net version only allows for one
discriminator per resultMap ??? That's what I remember seeing at some =
point.

--- Niels Beekman <
niels@wis.nl> wrote:

> Hi,
>
> Could you guys please clarify some of the possibilities and
> unpossibilities of iBATIS when it comes to subclassing?. What I =
> understand from the various documentation-fragments is that = iBATIS
> only
> supports discriminators when all columns are available in a = single
> resultset. How would this work when I have an ISA-design with let's =
> say
> 10 different subtables, this would result in enormous amounts = of
> data...
>
> Is there any documentation that I have missed somehow? I saw it = on
> the
> undocumented features-list, but maybe there is some after all. I =
> looked
> at the provided Documentation.xml but this is an example with = just
> one
> table, which is not I'm looking for. I even checked the .NET
> documentation too, the discriminator is mentioned there, but not in =
> the
> context of subtables (and I heard that iBATIS.NET has more features
> when
> it comes to subclassing).
>
> I hope you can shed some light on this, otherwise it requires some =
> workarounds on my end.
>
> Thanks for your time,
>
> Niels
>
> PS I tried to contact Ron for his solution
>
( http://www.mail-archive.com/ibatis-dev%40incubator.apache.org/msg01014.
> html) to this problem, as he said he was helped "off = list" but could
> not
> reach him.
>

 

------_=_NextPart_001_01C57243.E6F77BE2--