Path: csiph.com!optima2.xanadu-bbs.net!xanadu-bbs.net!nntp.club.cc.cmu.edu!feeder.erje.net!1.eu.feeder.erje.net!weretis.net!feeder4.news.weretis.net!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: =?UTF-8?Q?Arne_Vajh=c3=b8j?= Newsgroups: comp.lang.java.programmer Subject: Re: hibernate question (weird problem) Date: Sat, 25 Jul 2015 15:22:38 -0400 Organization: Aioe.org NNTP Server Lines: 25 Message-ID: References: NNTP-Posting-Host: bLmKSxgyEsD8qtT7wjgUDQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:32141 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