El S�b 07 Jul 2001 00:22, escribiste:
> cd.getLocation() is not returning the Location object? This should
> work, please show the code you using to access the Location.
>
> john mcnally
Sorry to have got you worried there,
but I wasn't using the aCD.getLocation() method, because I thought that the
extra code after doSelectJoinLocation() was for retrieving the Location
object for 1 CD object. I assumed, most probably wrongly that
doSelectJoinLocation() would return both CD and Location objects when it's
only returning the CD objects that are related to Location objects.
So now I should just have to step through the results vector with
aCD.getLocation() , save it to another vector and add it to the context..
I beg forgiveness, I'm beginning to see the light now. What I wanted was a
select like so
SELECT * FROM CD,LOCATION
WHERE CD.LOCATION_ID = LOCATION.LOCATION_ID
This of course would return something like this
CD_ID TITLE LOCATION_ID LOCATION_ID SHELF
1 CD1 1 1 TOP
However, we're working with the tables mapped to objects, and vectors of one
particular type of mapped-object (one object for each row in result set)
which will be added to the context. If we want to add more than one type
then, using the first type (e.g. CD) and for each row we aCD.getLocation()
and put into another vector which we also add to the context.
Sorry for thinking out loud here, but it helps when I've got my mind bogged
down.
If my thinking is right I can now work out the details...
Thanks John,
Saimon
> Saimon Moore wrote:
> > El Vie 06 Jul 2001 23:41, escribiste:
> > > make it public in CDPeer (or if that does not work, give it a new name)
> > >
> > > CDPeer.java
> > >
> > > public Vector doSelectJoinLocation(...)
> > > {
> > > return super.doSelectJoinLocation(...);
> > > }
> >
> > I'm afraid It didn't work
> > I did this...
> >
> > in CDPeer.java
> >
> > public static Vector doSelectJoinLocation(Criteria c) throws Exception
> > {
> >
> > return BaseCDPeer.doSelectJoinLocation(c);
> >
> > }
> >
> > in Screen1.java
> >
> > private Vector getEntries()
> > {
> > try
> > {
> > Criteria criteria = new Criteria();
> > criteria.addJoin(CDPeer.LOCATION_ID, LocationPeer.LOCATION_ID
> > ); return CDPeer.doSelectJoinLocation(criteria);
> > }
> > catch (Exception e)
> > {
> > return null;
> > }
> > }
> >
> > Only the CD data was made available to the velocity screen. I was under
> > the impresion that doSelectWithJoin() would return both CD and
> > Location...
> >
> > > Saimon Moore wrote:
> > > > El Vie 06 Jul 2001 22:49, escribiste:
> > > > > Try for 3) results = CDPeer.doSelectJoinLocation(crit);
> > > > >
> > > > > Then you can get the Location by
> > > > >
> > > > > aCD = results.get(0);
> > > > > aLocation = aCD.getLocation();
> > > > >
> > > > > john mcnally
> > > >
> > > > The compiler complains about 'CDPeer.doSelectJoinLocation(crit)'
> > > > being a protected method.
> > > >
> > > > [javac]
> > > > /home/saimon/tdk/webapps/newapp/WEB-INF/src/java/org/mycompany/newapp
> > > >/mod ules/screens/CdAdminView.java:106:
> > > > doSelectJoinLocation(org.apache.turbine.util.db.Criteria) has
> > > > protected access in org.mycompany.newapp.om.BaseCDPeer
> > > > [javac] results =
> > > > CDPeer.doSelectJoinLocation(criteria); [javac]
> > > > ^
> > > > [javac] 1 error
> > > >
> > > > I'm writing a method to add the results to the context within a
> > > > screen class, which is not of the same package as the
> > > > doSelectJoinLocation method. So should I define it in a public method
> > > > within CDPeer and call it from within my screen class.
> > > >
> > > > One other thing,
> > > > Am I right in saying that from, what I can understand, your code
> > > > provides the Location for the first 1st row of the CD resultset. Does
> > > > the doSelectJoinLocation() method give you all the cd and their
> > > > corresponding location objects?
> > > >
> > > > > Saimon Moore wrote:
> > > > > > Thanks for you help folks. I managed to insert allright,
> > > > > > although I had to first save the location table
> > > > > >
> > > > > > aLocation.save();
> > > > > >
> > > > > > and then
> > > > > >
> > > > > > aCD.setLocation(aLocation);
> > > > > > aCD.save();
> > > > > >
> > > > > > This works great!
> > > > > >
> > > > > > I have tried retrieving the same data using the following code
> > > > > >
> > > > > > <code>
> > > > > > 1 Criteria criteria = new Criteria();
> > > > > > 2 criteria.addJoin(CDPeer.LOCATION_ID, LocationPeer.LOCATION_ID
> > > > > > ); 3 return CDPeer.doSelect(criteria);
> > > > > > </code>
> > > > > > However, the result set only includes the CD table data and not
> > > > > > as I expected both CD and Location.
> > > > > >
> > > > > > ie I'm getting SELECT CD FROM CD,LOCATION
> > > > > > WHERE CD.LOCATION_ID = LOCATION.LOCATION_ID
> > > > > >
> > > > > > instead of
> > > > > >
> > > > > > ie SELECT * FROM CD,LOCATION
> > > > > > WHERE CD.LOCATION_ID = LOCATION.LOCATION_ID
> > > > > >
> > > > > > If I change 3 for
> > > > > >
> > > > > > return LocationPeer.doSelect(criteria);
> > > > > >
> > > > > > I get only the Location data
> > > > > >
> > > > > > ie SELECT LOCATION FROM CD,LOCATION
> > > > > > WHERE CD.LOCATION_ID = LOCATION.LOCATION_ID
> > > > > >
> > > > > > How can I define the pre-WHERE part of the sql statement?
> > > > > >
> > > > > > _________________________________________________________
> > > > > >
> > > > > > Do You Yahoo!?
> > > > > >
> > > > > > Get your free @yahoo.com address at http://mail.yahoo.com
> > > > > >
> > > > > > -----------------------------------------------------------------
> > > > > >---- 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]
> > > >
> > > > _________________________________________________________
> > > >
> > > > Do You Yahoo!?
> > > >
> > > > Get your free @yahoo.com address at http://mail.yahoo.com
> > > >
> > > > ---------------------------------------------------------------------
> > > > 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]
> >
> > _________________________________________________________
> >
> > Do You Yahoo!?
> >
> > Get your free @yahoo.com address at http://mail.yahoo.com
> >
> > ---------------------------------------------------------------------
> > 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]
_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]