Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #33571 > unrolled thread
| Started by | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| First post | 2016-02-03 08:46 +0100 |
| Last post | 2016-02-03 13:32 -0800 |
| Articles | 3 — 2 participants |
Back to article view | Back to comp.lang.java.programmer
A few JPQL questions Cecil Westerhof <Cecil@decebal.nl> - 2016-02-03 08:46 +0100
Re: A few JPQL questions Cecil Westerhof <Cecil@decebal.nl> - 2016-02-03 09:28 +0100
Re: A few JPQL questions Lew <lewbloch@gmail.com> - 2016-02-03 13:32 -0800
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2016-02-03 08:46 +0100 |
| Subject | A few JPQL questions |
| Message-ID | <871t8ume1f.fsf@Equus.decebal.nl> |
I do not have very much experience with JPA and especially with JPQL.
Yesterday shortly before leaving my colleague told me that he could
not use an embedded key in JPQL. He told me that when he used
something like:
a.id = b.id
he got more records as when he used:
a.id.first = b.id.first AND a.id.second = b.id.second …
I had not the time to evaluate this, but it seems very strange to me.
Could this be true? If so, what would be the reason? Otherwise, which
mistake has he likely made?
He also told me it was not possible to do a JOIN on a sub-query in
JPQL. He said it is only possible to use WHERE and HAVING. I assume he
made a mistake. What is most likely he did wrong?
--
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [next] | [standalone]
| From | Cecil Westerhof <Cecil@decebal.nl> |
|---|---|
| Date | 2016-02-03 09:28 +0100 |
| Message-ID | <87si1akxjq.fsf@Equus.decebal.nl> |
| In reply to | #33571 |
On Wednesday 3 Feb 2016 08:46 CET, Cecil Westerhof wrote: > I do not have very much experience with JPA and especially with > JPQL. Yesterday shortly before leaving my colleague told me that he > could not use an embedded key in JPQL. He told me that when he used > something like: a.id = b.id he got more records as when he used: > a.id.first = b.id.first AND a.id.second = b.id.second … > > I had not the time to evaluate this, but it seems very strange to > me. Could this be true? If so, what would be the reason? Otherwise, > which mistake has he likely made? I just spoke with him through instant message. He made an error regarding the conditions. So he thought he was doing the same, but he was not. This problem is solved. > He also told me it was not possible to do a JOIN on a sub-query in > JPQL. He said it is only possible to use WHERE and HAVING. I assume > he made a mistake. What is most likely he did wrong? Probably it will turn out that here he also made a mistake. -- Cecil Westerhof Senior Software Engineer LinkedIn: http://www.linkedin.com/in/cecilwesterhof
[toc] | [prev] | [next] | [standalone]
| From | Lew <lewbloch@gmail.com> |
|---|---|
| Date | 2016-02-03 13:32 -0800 |
| Message-ID | <08d3c750-b199-4c4f-8297-0baef02df38f@googlegroups.com> |
| In reply to | #33571 |
On Tuesday, February 2, 2016 at 11:59:11 PM UTC-8, Cecil Westerhof wrote: > I do not have very much experience with JPA and especially with JPQL. > Yesterday shortly before leaving my colleague told me that he could > not use an embedded key in JPQL. He told me that when he used > something like: > a.id = b.id > he got more records as when he used: > a.id.first = b.id.first AND a.id.second = b.id.second ... This is the wrong way to use JPQL anyway. You should be comparing objects for equality, not IDs. In fact, IDs have no place in the object model, generally. Example from the Java EE 7 Tutorial: SELECT DISTINCT p FROM Player p JOIN p.teams t This joins on the annotated relationship between Player and Team, and uses object equivalence, not relational table models, to resolve the link. *Object* equality, not relational table join logic. JPA is not SQL. Object orientation is not data orientation. -- Lew
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web