• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: getting the results of a sub select
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: getting the results of a sub select


  • Subject: Re: getting the results of a sub select
  • From: Ken Anderson <email@hidden>
  • Date: Tue, 15 Mar 2005 07:55:38 -0500

Ted,

You need to think of jobs and clients as objects that have relationships to each other. If you continue to think about things in terms of SQL and specialized queries, you're going to have a hard time with EOF (the database layer of WebObjects).

What you need to do is define a relationship in EOModeler between job and client, using ccode and acode to define the relationship.

If you call the relationship 'client', then you can display the client name with:

client.cname

When you fetch a bunch of jobs, EOF creates something called a fault in place of the client relationship. When you ask a job for client.cname, if client is still a fault, it will go to the database and fetch that particular client.

One thing that's important to realize here is that, by default, EOF will make a trip to the database for each client you need to fetch. If you're displaying client.cname in a table or something, that can become very inefficient. I suggest you inspect the Client entity in EOModeler, choose the advanced entity inspector, and set the batch faulting size to a number you find reasonable. What this will do is fetch that many clients when one is fetched, which will improve your performance significantly.

I highly suggest reading this to get more familiar with how EOF works:

http://developer.apple.com/documentation/WebObjects/Enterprise_Objects/ index.html

Ken

On Mar 15, 2005, at 7:45 AM, Theodore Petrosky wrote:

I am rather new to this so  please  be gentle....

I finally have an interface with webobjects talking to
my postgresql db. I am having a problem with a sub
select.. in schema, i have a job table and a client
table. the job table of course has a primary key of
the jobnumber. the client table has a PK of the
clientcode. each job row is assigned to a clientcode.

in cocoa I can do...

select jobnumber, (select cname from clientinfo ci
where ci.ccode = j.acode) as clientname, shortdesc
from jobinfo j order by jobnumber;

works great...

I am using the marker book and a few others and I just
can not seem to grasp how to populate my table in
webobjects. It appears to be a WOtoOneRelationship (I
think).

the end result should be:

jobnumber     clientname    shortdesc

of course I can easily get

jobnumber   clientcode  shortdesc

could someone point me in the right direction.....

thanks,

Ted



__________________________________
Do you Yahoo!?
Yahoo! Sports - Sign up for Fantasy Baseball.
http://baseball.fantasysports.yahoo.com/
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
email@hidden


This email sent to email@hidden

_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: This email sent to email@hidden
  • Follow-Ups:
    • Re: getting the results of a sub select
      • From: Arturo Perez <email@hidden>
References: 
 >getting the results of a sub select (From: Theodore Petrosky <email@hidden>)

  • Prev by Date: getting the results of a sub select
  • Next by Date: Re: getting the results of a sub select
  • Previous by thread: getting the results of a sub select
  • Next by thread: Re: getting the results of a sub select
  • Index(es):
    • Date
    • Thread