What is the proper way to map your object model with interfaces?
The way I have my model mapped currently is to map as follows:
<class-descriptor
class="FooInterface">
<extent-class class-ref="Foo" />
</class-descriptor>
<class-descriptor
class="Foo"
table="tblFoo" >
...
</class-descriptor>
And then add a reference descriptor as follows:
<reference-descriptor
name="foo"
class-ref="uwec.fpm.persistence.mm.FooInterface"
auto-retrieve="true"
auto-update="true"
auto-delete="false"
proxy="true" >
<foreignkey field-ref="fooId" />
</reference-descriptor>
I've determined that mapping the interface with the implementing class
as an extent breaks nested queries (although I haven't dug in to find
out why). I still want to proxy my collections and references however
and I thought I needed to map the interface in the repository somehow.
Any best practices on how to do this?
TIA
Wallace J Gelhar
Facilities Planning & Management
Computer Information Systems
[EMAIL PROTECTED]
(715) 836-3411
-----Original Message-----
From: Gelhar, Wallace Joseph
Sent: Thursday, July 10, 2003 11:34 AM
To: OJB Users List
Subject: RE: Nested Queries
Hi Jakob,
Are there any known issues with extents and nested queries?
My actual object model is as follows (somewhat simplified):
[A] <-1--n-> [B] -1--1-> [C] -1--1-> [D]
| | | |
[A1] [A2] [B1] [B2]
-All references and collections are proxied.
-All classes are referenced through their respective interface
The strange part is
1. I can query for C objects using a D field as criteria
2. I can query for B (or B1) objects using a C field as criteria
3. I can query for A objects using a B field as criteria
4. I cannot query for A objects using C or D fields as criteria
I've made a simplified test case without interfaces, proxies or extents
and the query works as you described. I'm still digging to try and
break it in a controlled manner.
Any thoughts?
Wallace J Gelhar
Facilities Planning & Management
Computer Information Systems
[EMAIL PROTECTED]
(715) 836-3411
-----Original Message-----
From: Jakob Braeuchi [mailto:[EMAIL PROTECTED]
Sent: Wednesday, July 09, 2003 10:47 AM
To: OJB Users List
Subject: Re: Nested Queries
hi wallace,
nested queries are supported:
[Konto] <-1--1-> [Person] <-1--n-> [Telefon]
the following queries all accounts (konto) with a balance > 100
belonging to a person with a phonenumber like 031%
crit = new Criteria();
crit.addGreaterThan("saldo", new BigDecimal(100));
crit.addLike("inhaber.telefone.nummer", "031%");
query = new QueryByCriteria(Konto.class, crit, true); //
DISTINCT
SELECT DISTINCT A0.idPerson,A0.saldo,A0.nummer,A0.id FROM tabKonto A0
INNER JOIN tabPerson A1 ON A0.idPerson=A1.id
INNER JOIN tabTelefon A2 ON A1.id=A2.idPerson
WHERE (A0.saldo > '100' ) AND A2.tel_nr LIKE '031%'
hth
jakob
Gelhar, Wallace Joseph wrote:
>I am trying to execute a multiple nested PB query against an object
>model such as follows:
>
>[A] <-1--n-> [B] <-1--1-> [C] -1--1-> [D]
>
>Criteria criteria = new Criteria();
>criteria.addEqualTo("bCollection.c.d.value", "constant");
>Query query = new QueryByCriteria(A.class, criteria);
>Collection aCollection = Broker.getCollectionByQuery(query);
>...
>
>This should produce the SQL such as
>
>SELECT A.field
>FROM A A0 INNER JOIN B A1
>ON A0.fk = A1.pk
>INNER JOIN C A2
>ON A1.fk = A2.pk
>INNER JOIN D A3
>ON A2.fk = A3.pk
>WHERE A3.value = 'constant'
>
>But instead it produces only a single join
>
>SELECT A.field
>FROM A A0 INNER JOIN B A1
>ON A0.fk = A1.pk
>WHERE value = 'constant'
>
>My question is if this type of multiple nested queries is supported?
Or
>is only a single level of nesting supported? How would you suggest
>working around this problem?
>
>Wallace J Gelhar
>Facilities Planning & Management
>Computer Information Systems
>[EMAIL PROTECTED]
>(715) 836-3411
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]