| Author |
DISTINCT in EJB-QL
|
Carlos Llona
Greenhorn
Joined: Apr 09, 2004
Posts: 15
|
|
Hello: I have a doubt about the clause DISTINCT, I dont understand what exactly does!!!. What criteria does distinct uses to determine what object is repited? Example SELECT DISTINCT OBJECT(p) FROM Player p in this example what does distinct serch to determinate if one object is repeated? it searches all the fields??? except primary keys or what?javascript: x() I expect that all opf you understand the question, if no, please show an example of distinct and exactly what things it does. thanks a lot carlos
|
 |
Valentin Crettaz
Gold Digger
Sheriff
Joined: Aug 26, 2001
Posts: 7610
|
|
If you have a look at the EJB spec section 11.2.8 (SELECT clause), it states:
The DISTINCT keyword is used to specify that duplicate values must be eliminated from the query result.
In clear it means, that if the query you make against the DB ever returns duplicate values, only one of them will show up in the result set.
|
SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
|
 |
Carlos Llona
Greenhorn
Joined: Apr 09, 2004
Posts: 15
|
|
thanks Valentin! but then, Distinc eliminates my entities repeated? if my query bring me for example the player with the primary key="00001" 5 times. with distinc I will only recive 1 record. is that right? but!!!. are there any different for example if I do this?: SELECT DISTINCT OBJECT(p) FROM Player p or SELECT OBJECT(p) FROM Player p In my database sample there are only 10 records. I suposse that the two queries always bring me 10 records. I dont imagine in what case (maybe using the clouse where) I could get a record repeated. can you give me one sample plz thanks a lot Carlos
|
 |
 |
|
|
subject: DISTINCT in EJB-QL
|
|
|