Re: how to generate multiple aliases in a SELECT
Re: how to generate multiple aliases in a SELECT
- Subject: Re: how to generate multiple aliases in a SELECT
- From: Jonathan Rochkind <email@hidden>
- Date: Wed, 20 Aug 2003 10:26:01 -0500
Normally you would define relationships in EOModeler from the TABLE1 entity
to the TABLE2 and TABLE3 entities. These relationships would be defined
based on the attributes in your SQL join---presumably, they represent some
meaningful relationship.
That's the first part. Then you want to create a qualifier based on the
relationship. It looks like the relatoniships will probably be to-many;
sometimes qualifiers accross to-many relationships can be tricky, so if you
have trouble at that point, ask more questions. But I believe the following
pattern would work:
EOQualifier qual = EOQualifier.withQualifierFormat(
"relationshipToEntity2.pkAttribute = 1 AND
relationshipToEntity3.pkAttribute = 2", null);
Okay, so that's the "WHERE" part of your SQL. Now in the "SELECT" part,
you say you ONLY want T1.PK. You can do that, but you aren't going to get
back full EOEnterpriseObject (EO) Java objects representing your
rows. Normally in WO programming, you want to get full EOs, so you can do
things with them. Occasionally, you might just want raw rows with limited
data, not the full EO. If this is really what you want, you can set the
fetch spec to just fetch raw rows, with just the attributes you are
interested in.
EOFetchSpecification spec = new EOFetchSpecification("Entity1", qual, null);
spec.setRawRowKeyPaths( new NSArray("pkAttribute") );
That should produce an SQL query of the form you ask for, if that's really
what you want.
--Jonathan
At 10:54 AM 8/20/2003 +0300, Alex Blaj wrote:
Hi there,
I need to create a fetchSpecification that would generate a SELECT statement
like this:
"SELECT T1.PK FROM TABLE1 T1, TABLE2 T2, TABLE2 T3 WHERE
T1.PK = T2.TABLE1_ID AND T2.PK = 1 AND
T1.PK = T3.TABLE1_ID AND T3.PK = 2;"
The difficult thing is to create 2 qualifiers for this fetchSpecification that
would generate the "FROM TABLE2 T2, TABLE2 T3" (2 aliases for the same table
TABLE2).
Everything I tried so far led me to a single alias to TABLE2 in the FROM
part.
Or, if there is anyone specialized in FrontBase (or some other database
support which supports "(SELECT ... ) INTERSECT (SELECT ...);"), could you
tell me how to implement the INTERSECT into my fetchSpecifiction?
I'm using WO 5.2 with FrontBase.
Any hint would be highly appreciated.
Alex.
===================================================================Lettrix bv,
P.O. Box 5, 6980 AA Doesburg,
The Netherlands -- Tel: +31 313 478 000,
Fax: +31 313 478 080 -- Check our website at:
http://www.lettrix.com
===================================================================Disclaimer
:
The information contained in this communication is confidential and
may be legally privileged. It is intended solely for the use of the
individual or entity to whom it is addressed and others authorised to
receive it. If you are not the intended recipient you are hereby
notified that any disclosure, copying, distribution or taking any
action in reliance on the contents of this information is strictly
prohibited and may be unlawful. Lettrix B.V. is neither liable for
the proper and complete transmission of the information contained in
this communication nor for any delay in its receipt.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.