Return-Path: Delivered-To: apmail-openjpa-users-archive@locus.apache.org Received: (qmail 55792 invoked from network); 7 Oct 2008 17:21:43 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 7 Oct 2008 17:21:43 -0000 Received: (qmail 55439 invoked by uid 500); 7 Oct 2008 17:21:42 -0000 Delivered-To: apmail-openjpa-users-archive@openjpa.apache.org Received: (qmail 55421 invoked by uid 500); 7 Oct 2008 17:21:42 -0000 Mailing-List: contact users-help@openjpa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@openjpa.apache.org Delivered-To: mailing list users@openjpa.apache.org Received: (qmail 55410 invoked by uid 99); 7 Oct 2008 17:21:41 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Oct 2008 10:21:41 -0700 X-ASF-Spam-Status: No, hits=0.3 required=10.0 tests=DNS_FROM_SECURITYSAGE,SPF_PASS,WHOIS_MYPRIVREG X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mtylenda@o2.pl designates 193.17.41.11 as permitted sender) Received: from [193.17.41.11] (HELO mailout1.go2.pl) (193.17.41.11) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 07 Oct 2008 17:20:36 +0000 Received: from o2.pl (unknown [10.0.0.68]) by mailout1.go2.pl (Postfix) with SMTP id 113285F004C for ; Tue, 7 Oct 2008 19:21:11 +0200 (CEST) Subject: =?UTF-8?Q?Re:_Subqueries_in_JPQL?= From: =?UTF-8?Q?Mi=C5=82osz_Tylenda?= To: users@openjpa.apache.org In-Reply-To: <1223321928205-1301743.post@n2.nabble.com> References: <1223321928205-1301743.post@n2.nabble.com> Mime-Version: 1.0 Message-ID: <5d08f388.6f48e5bb.48eb9a87.e68c@o2.pl> Date: Tue, 07 Oct 2008 19:21:11 +0200 X-Originator: 77.254.47.214 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Virus-Checked: Checked by ClamAV on apache.org Hello! I=20am=20afraid=20you=20can't=20do=20that=20in=20a=20single=20JPQL=20stat= ement=20-=20currently=20JPQL=20allows=20subqueries=20only=20in=20WHERE=20= and=20HAVING=20clauses.=20Maybe=20we=20will=20get=20something=20more=20in= =20JPA=202.0... Regards, Milosz >=20Hello,=20 >=20 >=20I=20am=20looking=20for=20some=20assistance=20in=20converting=20a=20pr= etty=20complex=20SQL >=20statement=20involving=20subqueries=20to=20JPQL.=20I=20am=20looking=20= to=20use=20a=20constructor >=20statement=20so=20I=20can=20return=20multiple=20values=20(essentially=20= most=20of=20an=20entity >=20plus=20a=20few=20values),=20but=20am=20at=20a=20loss=20as=20to=20how=20= to=20connect=20the=20pieces. >=20 >=20 >=20SELECT=20NEW=20entity.helper.LeftConfList(conf.title,=20 >=20=09COUNT(cnr)=20>,=20COUNT(cn)=20>) >=20 >=20=09=09=09=09> >=20 >=20=09FROM=20Conference=20conf,=20 >=20=09WHERE=20conf.courseSectionUID=20=3D=20?1=20 >=20=09AND=20conf.deleted=20<>=201=20ORDER=20BY=20conf.displaySequence >=20 >=20 >=20The=20original=20(working)=20SQL=20is: >=20 >=20SELECT=20conf.CONFERENCE=5FTITLE,=20(SELECT=20COUNT(*)=20FROM=20CONFE= RENCE=5FNOTES=20cn, >=20LAST=5FEDIT=20le >=20WHERE=20cn.U=5FOBJECT=5FID=20NOT=20IN=20( >=20SELECT=20cn.U=5FOBJECT=5FID=20 >=20FROM=20CONFERENCE=5FNOTES=20cn,=20UNREAD=20ur >=20WHERE=20cn.U=5FOBJECT=5FID=20=3D=20ur.READ=5FOBJECT=5FID=20 >=20AND=20cn.U=5FCONFERENCE=5FID=20=3D=20conf.U=5FOBJECT=5FID >=20AND=20ur.U=5FUSER=5FID=20=3D=20?1) >=20AND=20cn.U=5FCONFERENCE=5FID=20=3D=20conf.U=5FOBJECT=5FID >=20AND=20le.DELETED=20<>=201=20AND=20cn.U=5FOBJECT=5FID=20=3D=20le.U=5FO= BJECT=5FID)=20AS=20unread=5Fcount,=20 >=20 >=20(SELECT=20COUNT=20(*)=20 >=20FROM=20CONFERENCE=5FNOTES=20cn,=20LAST=5FEDIT=20le >=20WHERE=20cn.U=5FCONFERENCE=5FID=20=3D=20conf.U=5FOBJECT=5FID >=20AND=20le.DELETED=20<>=201=20AND=20cn.U=5FOBJECT=5FID=20=3D=20le.U=5FO= BJECT=5FID)=20AS=20total=5Fcount >=20 >=20FROM=20CONFERENCES=20conf,=20LAST=5FEDIT=20le >=20WHERE=20conf.U=5FCOURSE=5FSECTION=5FID=20=3D=20?2 >=20AND=20le.DELETED=20<>=201=20AND=20conf.U=5FOBJECT=5FID=20=3D=20le.U=5F= OBJECT=5FID=20ORDER=20BY >=20conf.DISPLAY=5FSEQUENCE >=20 >=20Any=20help=20would=20be=20greatly=20appreciated. >=20 >=20Thanks. >=20 >=20 >=20--=20 >=20View=20this=20message=20in=20context:=20http://n2.nabble.com/Subqueri= es-in-JPQL-tp1301743p1301743.html >=20Sent=20from=20the=20OpenJPA=20Users=20mailing=20list=20archive=20at=20= Nabble.com. >=20 >=20