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
Dear wise & wondeful people: How can I get missing contacts, notes, calendar dates and reminders that are just on my old iphone onto the iCloud for transfer to my new iPhone upgrade? Half of my contacts, notes, ect. were on my iCloud so have happily [More]
I recently got a new computer and I had to download iTunes 11 for my iPod Classic. The problem I'm having is that I plugged it in to sync my music because I had some new songs etc to put on, but when I plugged it in it would say on my iPod that it wa [More]
i want to open jpg files with gpicview isntead of feh in midnight commander, i read that i have to edit the file: /etc/mc/mc.ext in the part that say type/^JPEG i wrote #Include=image-options Open=gpicview %f i restart mc but nothing happen it still [More]
My ipod Touch 4G has been acting weird these past couple of days it changes it's time to my computers time which is wrong it's been deleting songs off my playlist.Try holding down the Sleep/Wake button. Does it ever get to the point where you see the [More]
How do I convert a pdf file to excel format?  I have a new computer and can't find how to convert.To convert a PDF file to Excel, you can subscribe to one of Adobe's services (Adobe ExportPDF or Adobe PDF Pack) or you can purchase Adobe Acrobat.Read [More]
Hi! I'm trying to enter data into a few fields of my ALV but when I press save or double click or try to do any action I'm getting and error and I can't go into my gode to get the data and save it into my tables. I declarated my ALV table like DATA B [More]
I use Elements 9.   I downloaded the Camera Raw plug-in but Elements still does not open an CR2 image.   Am i supposed to do something with the download?   Thank youManual installation on Windows®: 1. Exit Photoshop Elements and Premiere Elements. 2. [More]
Hi, I have a problem. I have a HTTPServlet, and a client that sends soap messages to the servlet, I need to keep trace of the session id, with the http connection i could use the setRequestproperty with cookie, but now I don't know how I can do with [More]
I have noticed that my logo, which is #3cd920, changes to #3bd91f when opened in FW. I first thought it might have been a problem with Illustrator, but when the file is opened in Photoshop it is #3cd920 as it should be. This is really outrageous; is [More]
Hi all. My application uses an increasing amount of memory, and in order to solve the problem I have turned on the -verbosegc option. The output is as follows: <GC: managing allocation failure: need 1040 bytes, type=1, action=1> <GC: 504 millisec [More]