-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 
Author Message
 Post subject: Optimization issue
PostPosted: Wed Oct 25, 2006 6:51 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 1:48 pm
Posts: 20
I am having troubles with an optimization issue.

Let's imagine that I have to map PERSON owning CARS
I have 2 tables : PERSON and CAR, CAR having a foreign key, the PERSON key.
Now, let's say that I only need the CAR licence plate number in the frame of a one-to-many relation between PERSON and CAR.
How can I map such a relation? Is there a way to map only one particular attribute of an entity?

If I map the Car class, then I will get useless information (other cars attributes) that uses resources...


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 7:25 am 
Newbie

Joined: Mon Dec 05, 2005 4:17 am
Posts: 3
u can use named query for that.
u can select select number_plate from car where car.person_id = :person_id.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 7:30 am 
Beginner
Beginner

Joined: Thu Jun 29, 2006 8:41 am
Posts: 41
As far as I'm concerned (and that ain't much) when you have a relation, all primary keys from one table go to the other as Foreign keys.

There's no way to avoid this.


If you want to only have the plate sent to the other table, you gotta make it the only primary key on the car table.

_________________
Falci - Heavy Worker!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Oct 25, 2006 7:46 am 
Beginner
Beginner

Joined: Tue Sep 19, 2006 1:48 pm
Posts: 20
Ok, licence number was maybe not a good example!
No matters if I get all the primary keys.
I want only one property, let's say the car's gas type, ONLY when I am manipulating Persons.
Then what I don't want is for example the car brand, the car price ect... even if those are mapped in the Car Class :

PERSON
id
name
adress

CAR
licenceNumber
Person_id
brand
price
gasType

I will give a try to Named Query


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.