Sitemap

Amicuk Programming Answers

How do I reducing the amount of joining when using one-to-one mappings?

2015-10-11   Views:0

Advertisement

Examine the following example; class Person Address address; String firstName, lastName; class Address Long addressId; String state, city, zip; Assume that both of these classes are mapped to tables in a database. Attributes such as Staff's name and

Examine the following example;
class Person
Address address;
String firstName, lastName;
class Address
Long addressId;
String state, city, zip;
Assume that both of these classes are mapped to tables in a database. Attributes such as Staff's name and Address's addressId, state, city, and zip are direct-to-field mappings. Staff's address attribute is a one-to-one mapping.
If you write the following expression:
Expression exp = new ExpressionBuilder(Person.class).get("address").get("addressId").equal(4L);
Toplink will create a query like the following:
select first_name, last_name, address_id, ...
from person t0, address t1
where t0.address_id = t1.address_id
and t1.address_id = 4;
This is an unneccesary join because the person table already has the column with the data in it since it has a foriegn key. Is there someway to tell toplink to not join the tables when the only thing you are querying on is if a foriegn key that already exists in the referenced table? What I would want/expect to see is the following:
select first_name, last_name, address_id, ...
from person t0
where t0.address_id = 4;
I beleive we are using TopLink version 10.1.3.1

The replay answer
Advertisement
In your initial query you're actually saying "find the Person who has an Address who's id is 4". Your second query is "find the Person who references an address who's id is 4". The first query requires there be an Address with ID 4, the other does not.
If you define a query key "addressId" for the ADDRESS_ID column on the Person descriptor you can write this query as:
Expression exp = new ExpressionBuilder(Person.class).get("addressId").equal(4L);This will result in the SQL you want.
--Shaun                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Go to See the other 2 answers

How do I reducing the amount of joining when using one-to-one mappings?

Category:DefaultRelease time:2015-10-11Views:130

Examine the following example; class Person Address address; String firstName, lastName; class Address Long addressId; String state, city, zip; Assume that both of these classes are mapped to tables in a database. Attributes such as Staff's name and[More]

AP:selected payment schedules report "Credit reduces payment amount  below

Category:DefaultRelease time:2015-10-11Views:130

Hi all: I have a PPR reject one Debit memo with reason "Credit reduces payment amount below zero" at first and shows out in report "selected payment schedules report" as Unselected Scheduled Payments. PPR Pay through date: 28-Nov-2011[More]

How can I reduce the amount of storage my iPhone uses for messages?

Category:DefaultRelease time:2015-10-11Views:130

Is there any way to reduce the amount of storage space my iPhone uses for Messages?  Can I limit the storage to the last year or some other limit (specific date, specific amount of storage etc.)? Thank youI'm not sure there is a solution to your ques[More]

HT201774 How do I reduce the amount of email being sent to my iPhone 5 with iOS 7.0?

Category:DefaultRelease time:-0001-11-30Views:130

How do I reduce the amount of email being sent to my iPhone 5 with iOS 7.0As I delete email more mail populates on the phone.Read other 3 answers[More]

SQL Query to reduce Commission amount on a Sales Order

Category:DefaultRelease time:-0001-11-30Views:130

I hope that this is the right forum to post this and hope that someone may be able to help? I have a customer who wants to manipulate the amount of commission given on a sales order for some specific items. I have set up a UDF on the item master reco[More]

How can I reduce the amount of space between paragraphs in Pages?

Category:DefaultRelease time:-0001-11-30Views:130

How can I reduce the amount of space between paragraphs in Pages?Let's pretend that you told us which version of Pages you are talking about, and that you are using Pages 5: click in the text > Format > Spacing > click on triangle to expand optio[More]

Reducing the amount of code in htm pages :-)

Category:DefaultRelease time:-0001-11-30Views:130

Hi, I recently had to reduce the amount of abap business logic in a view. The view was in a large multifunctional bsp that someone else had written, and to which I needed to add some code. That view consisted of many htm includes, each include having[More]

How do you reduce the amount of mb used by other i dont know what this is?

Category:DefaultRelease time:-0001-11-30Views:130

how do i reduce the amount of mb used by other on my itunes do i can record more videos?http://osxdaily.com/2013/07/24/remove-other-data-storage-iphone-ipad/Read other 2 answers[More]

How to reduce budgeted amount from IM program

Category:DefaultRelease time:-0001-11-30Views:130

HI, Is it possible to reduce budgeted amount from IM program (after distribution is done)? eg. original budget is 30k, need to reduce to 15k.. Is this possible? Or are there other means to reduce the budget? Many thanks in advance.Hi Irene, If the am[More]

Reducing the amount of space

Category:DefaultRelease time:-0001-11-30Views:130

I'm attempting to use some code like this to make a tabbed page. <cfformgroup type="tabnavigator" style="indicatorGap:0; verticalGap:3;"> <cfformgroup type="page" label="Contact Summary"> <cfformgroup[More]

When I look in Add/Remove Programs in the Control Panel it reports Firefox as 5.44GB. Could this be true? If so how do I reduce the amount of space it is taking up?

Category:DefaultRelease time:-0001-11-30Views:130

When I look in Add/Remove Programs in the Control Panel it reports Firefox as 5.44GB. Could this be true? If so how do I reduce the amount of space it is taking up?It is quite common for the program size listings to be wrong. To check the actual size[More]

Hot
Hi, I have to update the key mapping of a flat table. My problem is that I have more than 30 remote systems. Is it possible to import the key mapping of more than one system in one step? If there is now way to do it with Import Manager can I use APAP [More]
I setup a test environment, it appears the SCVMM always use BITS to clone VM that was painfully slow SCVMM1: SCVMM 2012 R2 with the latest windows update VHOST1 and VHOST2: Hyper-V Host. Windows Server 2012 R2 with the latest update SERVER1: Windows [More]
Hi, in the master data of the GL account, the check box 'only balance in local currency' should be unchecked it to set that account as Valuation account, i.e in the OI exchange rate defferences? or , if the account takes only in local balance also se [More]
I want to run two related C programs. The second one reads a text file that the first created. So I need to wait until the first is completed. I use "system exec.vi" and I know I can set "wait until completeion" to true, but this way I [More]
Hello all, I need some clarification.  Can a ASM +FRADG shared between RAC 2 nodes 11gR2 Primary and RAC 2 nodes 11gR2 Physical Standby Database in order to use it for backup and recovery on both databases. Thank you.Hi, If you are looking this docum [More]
...is there anything that can't be done?  One good thing about having to replace my ipad months ago was not having to update to ios 7.  I really hurts my eyes, it messes with my app data, and the design of ios 6 is just way better. This is a nightmar [More]
I like the ease of use and options in iDVD, but not the quality of video when importing XVID avi files. They end up very blocky, regardless of the settings (already using "best quality", and I'm not out of room on the disc build). VisualHub prov [More]
I created a web dynpro project which implement a KM file repository constructs by recursion child node. If the node is collection (folder) there is no problem to open it,But if it is not (for example if it is a *.pdf or *.doc or *.txt), I don’t know [More]
Friends, For down payment processing, we configure the steps maintain data proposal for billing plan types. where we mention as 30% should be down payment collected before order processing and 70% should be before shipment. when i am creating invoice [More]
Just like the titre, Can I use Microsoft Project Professional to connect hyperlink to some documents in the server of our company?  I want to share some documents not in my computer, which is in the server of our company. Hello, Sure you can, right c [More]