Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #32137 > unrolled thread
| Started by | Peter <mcheung63@hotmail.com> |
|---|---|
| First post | 2015-07-25 17:10 +0800 |
| Last post | 2015-07-25 23:25 -0700 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.java.programmer
hibernate question (weird problem) Peter <mcheung63@hotmail.com> - 2015-07-25 17:10 +0800
Re: hibernate question (weird problem) Arne Vajhøj <arne@vajhoej.dk> - 2015-07-25 15:22 -0400
Re: hibernate question (weird problem) mcheung63@gmail.com - 2015-07-25 23:25 -0700
| From | Peter <mcheung63@hotmail.com> |
|---|---|
| Date | 2015-07-25 17:10 +0800 |
| Subject | hibernate question (weird problem) |
| Message-ID | <movjpe$tvk$1@speranza.aioe.org> |
Hi
I am using hibernate, i got two class "JMPDATA" and "PARAMETER",
they are linked together. Then I execute :
session.createSQLQuery("SELECT a.* from JMPDATA").addEntity(JmpData.class);
I didn't join table parameter, but i still able to get the value of it, why?
iterator = query.list().iterator();
while (iterator.hasNext()) {
JmpData d = iterator.next();
for (Parameter p : d.parameters) {
System.out.println("\t" + p.name);
}
}
I am using H2 database, and i enable the trace log, i saw the h2 is
receive this sql command from hibernate. I am sure it didn't left join
the parameter table.
SELECT a.* from JMPDATA as a limit ?
thanks
from Peter (cmk128@hotmail.com)
[toc] | [next] | [standalone]
| From | Arne Vajhøj <arne@vajhoej.dk> |
|---|---|
| Date | 2015-07-25 15:22 -0400 |
| Message-ID | <mp0nlu$ee6$1@speranza.aioe.org> |
| In reply to | #32137 |
On 7/25/2015 5:10 AM, Peter wrote:
> I am using hibernate, i got two class "JMPDATA" and "PARAMETER",
> they are linked together. Then I execute :
>
> session.createSQLQuery("SELECT a.* from JMPDATA").addEntity(JmpData.class);
>
> I didn't join table parameter, but i still able to get the value of it,
> why?
>
> iterator = query.list().iterator();
> while (iterator.hasNext()) {
> JmpData d = iterator.next();
> for (Parameter p : d.parameters) {
> System.out.println("\t" + p.name);
> }
> }
You are using an OO model not plain SQL.
There is a relationship between the classes and
Hibernate correctly handles that.
Arne
[toc] | [prev] | [next] | [standalone]
| From | mcheung63@gmail.com |
|---|---|
| Date | 2015-07-25 23:25 -0700 |
| Message-ID | <24cf7f9c-2169-4cf2-a66d-75776b21b7b7@googlegroups.com> |
| In reply to | #32141 |
i think i got the answer, if i just run that query only, hilbernate will invoke sql to get the data from subtable. if i queried those row before, then it wont. i think hibernate cached it already. thanks from Peter
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.java.programmer
csiph-web