Re: findBy referencing another entity reference

2001-04-18 Thread Eddie

Adam,

Thanks, this looks nice. However I have the problem that I want to use
"GROUP BY" in my statements which is a kind of a problem as the "defined
finder" methods requires that exact the same parameters are returned which
isn't true  in case of "GROUP BY" (the Sum() returns something that isn't in
the orginally resultset).
How can I still receive the result set form this Group by statement ?

I was thinking about defining an entity bean that contains the fields that
the Group by statement returns, but how ??? (Just like the elefantwalker
mentioned: have another entitybean that performs all the heavy stuff)
Can someone help me with this, as I don't knwo what the xml definition of
this entity bean should look like, as untill now was using simple entity
beans that are directly related to database tables, which isn't true in this
case.

Eddie

- Original Message -
From: Adam Cassar <[EMAIL PROTECTED]>
To: Orion-Interest <[EMAIL PROTECTED]>
Sent: Tuesday, April 17, 2001 3:41 AM
Subject: Re: findBy referencing another entity reference


>
> I found this reply to an earlier posting quite usefull.
>
> http://www.mail-archive.com/orion-interest@orionserver.com/msg12085.html
>
> On 16 Apr 2001 17:23:15 -0700, Rian Schmidt wrote:
> > Oh boy... OK, maybe that was a bad example.  "Read more about entity
beans"
> > is not very useful advice in any case.  I just didn't want to explain
our
> > business model to ask the question.
> >
> > Try the situation where the top level is Vehicle -> Manufacturer ->
Model or
> > something many-to-many on each layer.  My point is that I want to be
able to
> > "skip a layer" in the finder.  Is that possible?  If you don't know, or
the
> > answer is no, please just say that or ignore my question and move on.
If
> > you have an actual answer or alternative approach that might work, I'd
be
> > very appreciative to hear it.
> >
> > For what it's worth, I want to do it this way, as opposed to using some
kind
> > of bean-based (logical model) test or pseudo-BMP thing because, due to
the
> > volume of "3rd level (in my example)" entities running a findAll on them
is
> > performance-limiting and I'd rather not stick SQL directly in my beans.
> >
> > Thanks,
> > Rian
> > --
> > Rian Schmidt
> > [EMAIL PROTECTED]
> >
> > - Original Message -
> > From: "elephantwalker" <[EMAIL PROTECTED]>
> > To: "Orion-Interest" <[EMAIL PROTECTED]>
> > Sent: Monday, April 16, 2001 2:54 PM
> > Subject: RE: findBy referencing another entity reference
> >
> >
> > > Rian,
> > >
> > > This is much too sql centric. You should resolve your entity beans
around
> > > business methods. So I would start off by reading more about entity
beans.
> > > Theserverside.com, for example has a download on an excellent book for
> > > entity beans. As for the sql, you are talking a one to one
relationship
> > for
> > > the car/model and a one to many relationship for the
manufacturer/model.
> > > There should be some examples of this on the sun's j2ee site. I know
that
> > > they specifically discuss this issue.
> > >
> > > Regards,
> > >
> > > the elephantwalker
> > >
> > >
> > > -Original Message-
> > > From: [EMAIL PROTECTED]
> > > [mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
> > > Sent: Monday, April 16, 2001 2:23 PM
> > > To: Orion-Interest
> > > Subject: findBy referencing another entity reference
> > >
> > >
> > > Hi all,
> > >
> > > How about this scenario:
> > > There are three entities: manufacturer, model, car (as an example)
> > > model knows directly which manufacturer it is, car knows which model
it
> > is,
> > > but car has to do a model.getManufacturer to find out its
manufacturer...
> > >
> > > OK, so what I wanna know is can I  a findByManufacturer for car?  I'd
> > > like to be able to do something like this:
> > > query="$model.manufacturer = $1"
> > >
> > > Now, I know that I could specify a sub-query with the actual
persistence
> > > name of the other entity's thang, something like:
> > > query="$model in (select $model from model where manufacturer_id =
$1)"
> > > but it strikes me that Orion won't know what I'm going on about, and
best
> > > case, will have to talk to the database each time.  Either way, I had
to
> > put
> > > the persistence name into the orion-ejb-jar.xml file, which is not
> > goodness.
> > >
> > > Is it possible maybe to say something like:
> > > query="model in ($1)"
> > > where $1 is a Collection of models taken from
> > ModelHome.findByManufacturer?
> > >
> > > Any thoughts on the best way to approach this?
> > >
> > > Thanks,
> > > Rian
> > > --
> > > Rian Schmidt
> > > [EMAIL PROTECTED]
> > >
> > >
> > >
> >
> >
> >
>
>
>
> --
>
> Adam Cassar
> Technical Development Manager
> ___
> NetRegistry http://www.netregistry.au.com
> Tel: +61 2 9641 8609 | Fax: +61 2 9699 6088
> PO Box 270 Broadway NSW 2007 Australia
>
>
>




RE: findBy referencing another entity reference

2001-04-16 Thread Jeff Schnitzer

This is the right idea; you want to do a join in the finder.  Relational
databases were designed to do exactly this sort of thing.  Putting extra
information in the EJBs would just lead to consistency problems, IMHO.  

The EJB 2.0 specification defines EJB QL, which is a
database-independent query language reminiscent of SQL and the preferred
solution to your problem.  Unfortunately Orion does not yet support EJB
QL, so you need to manually specify the join in SQL in the
orion-ejb-jar.xml finder definition.

You will need to use a partial="false" finder to do a join, which means
you need to be very careful about how you specify the select.  Select
table.* should work if you allowed Orion to create the table in the
first place.  Otherwise you'll need to make sure that the columns are
specified in the same order as the fields in ejb-jar.xml.

You will probably want to put this new finder definition in an
orion-ejb-jar.xml fragment included in your ejb jar file so that
deploying your j2ee app on a new server will automatically include the
changes.  There is much discussion in the archives about how to do this.

Good luck!

Jeff

>-Original Message-
>From: Adam Cassar [mailto:[EMAIL PROTECTED]]
>Sent: Monday, April 16, 2001 6:41 PM
>To: Orion-Interest
>Subject: Re: findBy referencing another entity reference
>
>
>
>I found this reply to an earlier posting quite usefull.
>
>http://www.mail-archive.com/orion-interest@orionserver.com/msg1
>2085.html
>




Re: findBy referencing another entity reference

2001-04-16 Thread Adam Cassar


I found this reply to an earlier posting quite usefull.

http://www.mail-archive.com/orion-interest@orionserver.com/msg12085.html

On 16 Apr 2001 17:23:15 -0700, Rian Schmidt wrote:
> Oh boy... OK, maybe that was a bad example.  "Read more about entity beans"
> is not very useful advice in any case.  I just didn't want to explain our
> business model to ask the question.
> 
> Try the situation where the top level is Vehicle -> Manufacturer -> Model or
> something many-to-many on each layer.  My point is that I want to be able to
> "skip a layer" in the finder.  Is that possible?  If you don't know, or the
> answer is no, please just say that or ignore my question and move on.  If
> you have an actual answer or alternative approach that might work, I'd be
> very appreciative to hear it.
> 
> For what it's worth, I want to do it this way, as opposed to using some kind
> of bean-based (logical model) test or pseudo-BMP thing because, due to the
> volume of "3rd level (in my example)" entities running a findAll on them is
> performance-limiting and I'd rather not stick SQL directly in my beans.
> 
> Thanks,
> Rian
> --
> Rian Schmidt
> [EMAIL PROTECTED]
> 
> - Original Message -
> From: "elephantwalker" <[EMAIL PROTECTED]>
> To: "Orion-Interest" <[EMAIL PROTECTED]>
> Sent: Monday, April 16, 2001 2:54 PM
> Subject: RE: findBy referencing another entity reference
> 
> 
> > Rian,
> >
> > This is much too sql centric. You should resolve your entity beans around
> > business methods. So I would start off by reading more about entity beans.
> > Theserverside.com, for example has a download on an excellent book for
> > entity beans. As for the sql, you are talking a one to one relationship
> for
> > the car/model and a one to many relationship for the manufacturer/model.
> > There should be some examples of this on the sun's j2ee site. I know that
> > they specifically discuss this issue.
> >
> > Regards,
> >
> > the elephantwalker
> >
> >
> > -Original Message-
> > From: [EMAIL PROTECTED]
> > [mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
> > Sent: Monday, April 16, 2001 2:23 PM
> > To: Orion-Interest
> > Subject: findBy referencing another entity reference
> >
> >
> > Hi all,
> >
> > How about this scenario:
> > There are three entities: manufacturer, model, car (as an example)
> > model knows directly which manufacturer it is, car knows which model it
> is,
> > but car has to do a model.getManufacturer to find out its manufacturer...
> >
> > OK, so what I wanna know is can I  a findByManufacturer for car?  I'd
> > like to be able to do something like this:
> > query="$model.manufacturer = $1"
> >
> > Now, I know that I could specify a sub-query with the actual persistence
> > name of the other entity's thang, something like:
> > query="$model in (select $model from model where manufacturer_id = $1)"
> > but it strikes me that Orion won't know what I'm going on about, and best
> > case, will have to talk to the database each time.  Either way, I had to
> put
> > the persistence name into the orion-ejb-jar.xml file, which is not
> goodness.
> >
> > Is it possible maybe to say something like:
> > query="model in ($1)"
> > where $1 is a Collection of models taken from
> ModelHome.findByManufacturer?
> >
> > Any thoughts on the best way to approach this?
> >
> > Thanks,
> > Rian
> > --
> > Rian Schmidt
> > [EMAIL PROTECTED]
> >
> >
> >
> 
> 
> 



-- 

Adam Cassar
Technical Development Manager
___  
NetRegistry http://www.netregistry.au.com
Tel: +61 2 9641 8609 | Fax: +61 2 9699 6088
PO Box 270 Broadway NSW 2007 Australia





RE: findBy referencing another entity reference

2001-04-16 Thread elephantwalker

Rian,

There are two ways to do this. You can have an entity bean which reflects
all of the relationships shown. That is,
car can have a reference to an entity bean for the manufacturer, and
manufactuer can have a reference to an entity bean for model. But somehow, I
thought the relationship for model and manufacturer to car are the same. So
you could have a reference to both entity beans in you car bean.

Starting from car, you can have "findCarByManufacturer", which would, of
course, return a list of cars. You could also have, "findCarByModel", which
would also return a list of cars. You could also have a
"findCarByManufacturerandModel", which would also return a list of cars.

A second way is to come up with an entity bean that has some but not all of
the data that is in the main beans. You could then use this "lite" bean to
do your heavy duty finding. Especially if its only names you are looking
for, versus engine size, hp, photographs, etc. This is the approach I use
when representing chemical component information in a website. Each chemical
component has 50 or more doubles in the main component bean for chemical
thermodynamic data (very uninteresting for the website)...but for most of
the web presentation, all we need is the name, molecular weight, and maybe a
little gif. The underlying database information doesn't change, since I
disable the "create" and "store" methods in the lite bean to make the
information immutable from this bean. This makes presentation of the
component list blazingly fast on the website versus the "heavy" component
ejb.

Sorry about the "readme" post, but it wasn't clear that you were using ejbs
from your post, and we usually discuss j2ee implementation here. I have
found the Understanding EJB's from Theserverside.com very useful. The sun
j2ee site clued me into the idea of using a "lite" entity bean.

Regards,

The elephantwalker





-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
Sent: Monday, April 16, 2001 5:23 PM
To: Orion-Interest
Subject: Re: findBy referencing another entity reference


Oh boy... OK, maybe that was a bad example.  "Read more about entity beans"
is not very useful advice in any case.  I just didn't want to explain our
business model to ask the question.

Try the situation where the top level is Vehicle -> Manufacturer -> Model or
something many-to-many on each layer.  My point is that I want to be able to
"skip a layer" in the finder.  Is that possible?  If you don't know, or the
answer is no, please just say that or ignore my question and move on.  If
you have an actual answer or alternative approach that might work, I'd be
very appreciative to hear it.

For what it's worth, I want to do it this way, as opposed to using some kind
of bean-based (logical model) test or pseudo-BMP thing because, due to the
volume of "3rd level (in my example)" entities running a findAll on them is
performance-limiting and I'd rather not stick SQL directly in my beans.

Thanks,
Rian
--
Rian Schmidt
[EMAIL PROTECTED]

----- Original Message -
From: "elephantwalker" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Monday, April 16, 2001 2:54 PM
Subject: RE: findBy referencing another entity reference


> Rian,
>
> This is much too sql centric. You should resolve your entity beans around
> business methods. So I would start off by reading more about entity beans.
> Theserverside.com, for example has a download on an excellent book for
> entity beans. As for the sql, you are talking a one to one relationship
for
> the car/model and a one to many relationship for the manufacturer/model.
> There should be some examples of this on the sun's j2ee site. I know that
> they specifically discuss this issue.
>
> Regards,
>
> the elephantwalker
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
> Sent: Monday, April 16, 2001 2:23 PM
> To: Orion-Interest
> Subject: findBy referencing another entity reference
>
>
> Hi all,
>
> How about this scenario:
> There are three entities: manufacturer, model, car (as an example)
> model knows directly which manufacturer it is, car knows which model it
is,
> but car has to do a model.getManufacturer to find out its manufacturer...
>
> OK, so what I wanna know is can I  a findByManufacturer for car?  I'd
> like to be able to do something like this:
> query="$model.manufacturer = $1"
>
> Now, I know that I could specify a sub-query with the actual persistence
> name of the other entity's thang, something like:
> query="$model in (select $model from model where manufacturer_id 

Re: findBy referencing another entity reference

2001-04-16 Thread Rian Schmidt

Oh boy... OK, maybe that was a bad example.  "Read more about entity beans"
is not very useful advice in any case.  I just didn't want to explain our
business model to ask the question.

Try the situation where the top level is Vehicle -> Manufacturer -> Model or
something many-to-many on each layer.  My point is that I want to be able to
"skip a layer" in the finder.  Is that possible?  If you don't know, or the
answer is no, please just say that or ignore my question and move on.  If
you have an actual answer or alternative approach that might work, I'd be
very appreciative to hear it.

For what it's worth, I want to do it this way, as opposed to using some kind
of bean-based (logical model) test or pseudo-BMP thing because, due to the
volume of "3rd level (in my example)" entities running a findAll on them is
performance-limiting and I'd rather not stick SQL directly in my beans.

Thanks,
Rian
--
Rian Schmidt
[EMAIL PROTECTED]

- Original Message -
From: "elephantwalker" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Monday, April 16, 2001 2:54 PM
Subject: RE: findBy referencing another entity reference


> Rian,
>
> This is much too sql centric. You should resolve your entity beans around
> business methods. So I would start off by reading more about entity beans.
> Theserverside.com, for example has a download on an excellent book for
> entity beans. As for the sql, you are talking a one to one relationship
for
> the car/model and a one to many relationship for the manufacturer/model.
> There should be some examples of this on the sun's j2ee site. I know that
> they specifically discuss this issue.
>
> Regards,
>
> the elephantwalker
>
>
> -Original Message-
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
> Sent: Monday, April 16, 2001 2:23 PM
> To: Orion-Interest
> Subject: findBy referencing another entity reference
>
>
> Hi all,
>
> How about this scenario:
> There are three entities: manufacturer, model, car (as an example)
> model knows directly which manufacturer it is, car knows which model it
is,
> but car has to do a model.getManufacturer to find out its manufacturer...
>
> OK, so what I wanna know is can I  a findByManufacturer for car?  I'd
> like to be able to do something like this:
> query="$model.manufacturer = $1"
>
> Now, I know that I could specify a sub-query with the actual persistence
> name of the other entity's thang, something like:
> query="$model in (select $model from model where manufacturer_id = $1)"
> but it strikes me that Orion won't know what I'm going on about, and best
> case, will have to talk to the database each time.  Either way, I had to
put
> the persistence name into the orion-ejb-jar.xml file, which is not
goodness.
>
> Is it possible maybe to say something like:
> query="model in ($1)"
> where $1 is a Collection of models taken from
ModelHome.findByManufacturer?
>
> Any thoughts on the best way to approach this?
>
> Thanks,
> Rian
> --
> Rian Schmidt
> [EMAIL PROTECTED]
>
>
>





RE: findBy referencing another entity reference

2001-04-16 Thread elephantwalker

Rian,

This is much too sql centric. You should resolve your entity beans around
business methods. So I would start off by reading more about entity beans.
Theserverside.com, for example has a download on an excellent book for
entity beans. As for the sql, you are talking a one to one relationship for
the car/model and a one to many relationship for the manufacturer/model.
There should be some examples of this on the sun's j2ee site. I know that
they specifically discuss this issue.

Regards,

the elephantwalker


-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]On Behalf Of Rian Schmidt
Sent: Monday, April 16, 2001 2:23 PM
To: Orion-Interest
Subject: findBy referencing another entity reference


Hi all,

How about this scenario:
There are three entities: manufacturer, model, car (as an example)
model knows directly which manufacturer it is, car knows which model it is,
but car has to do a model.getManufacturer to find out its manufacturer...

OK, so what I wanna know is can I  a findByManufacturer for car?  I'd
like to be able to do something like this:
query="$model.manufacturer = $1"

Now, I know that I could specify a sub-query with the actual persistence
name of the other entity's thang, something like:
query="$model in (select $model from model where manufacturer_id = $1)"
but it strikes me that Orion won't know what I'm going on about, and best
case, will have to talk to the database each time.  Either way, I had to put
the persistence name into the orion-ejb-jar.xml file, which is not goodness.

Is it possible maybe to say something like:
query="model in ($1)"
where $1 is a Collection of models taken from ModelHome.findByManufacturer?

Any thoughts on the best way to approach this?

Thanks,
Rian
--
Rian Schmidt
[EMAIL PROTECTED]