-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 
Author Message
 Post subject: What is wrong with this query??
PostPosted: Fri Jan 14, 2005 1:29 pm 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
I am trying to execute the following querry and getting a weird exception that I dont understand. Can anyone give me a hand?

The query is:
Code:
select issue from SubscriptionIssue issue
where issue.subscription.ID = :subscriptionID
and issue.issueNumber > :lastIssue


This query says "net.sf.hibernate.QueryException: in expected: issue [select issue from SubscriptionIssue issue where issue.subscription.ID = :subscriptionID and issue.issueNumber > :lastIssue]"

The full exception is:
Code:
java.lang.RuntimeException: net.sf.hibernate.QueryException: in expected: issue [select issue from SubscriptionIssue issue where issue.subscription.ID = :subscriptionID and issue.issueNumber > :lastIssue]
   at com.bmw.candy.candiedServices.SubscriptionAccess.fetchNewIssues(SubscriptionAccess.java:308)
   at com.bmw.candy.candiedServices.tags.FetchNewIssuesTag.doTag(FetchNewIssuesTag.java:41)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx._jspx_meth_cs_fetchNewIssues_0(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:388)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx._jspx_meth_c_forEach_0(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:300)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx.access$2(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:271)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx$UpdatedSubscriptions_jspxHelper.invoke0(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:460)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx$UpdatedSubscriptions_jspxHelper.invoke(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:477)
   at org.apache.jsp.tag.web.menu_tag.doTag(org.apache.jsp.tag.web.menu_tag:117)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx._jspx_meth_site_menu_0(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:225)
   at org.apache.jsp.JSPs.UpdatedSubscriptions_jspx._jspService(org.apache.jsp.JSPs.UpdatedSubscriptions_jspx:90)
   at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:99)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:325)
   at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)
   at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:245)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:802)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:237)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:157)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:214)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:178)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:126)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:105)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:107)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:148)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:825)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.processConnection(Http11Protocol.java:731)
   at org.apache.tomcat.util.net.PoolTcpEndpoint.processSocket(PoolTcpEndpoint.java:526)
   at org.apache.tomcat.util.net.LeaderFollowerWorkerThread.runIt(LeaderFollowerWorkerThread.java:80)
   at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
   at java.lang.Thread.run(Unknown Source)
Caused by: net.sf.hibernate.QueryException: in expected: issue [select issue from SubscriptionIssue issue where issue.subscription.ID = :subscriptionID and issue.issueNumber > :lastIssue]
   at net.sf.hibernate.hql.FromParser.token(FromParser.java:102)
   at net.sf.hibernate.hql.ClauseParser.token(ClauseParser.java:87)
   at net.sf.hibernate.hql.PreprocessingParser.token(PreprocessingParser.java:123)
   at net.sf.hibernate.hql.ParserHelper.parse(ParserHelper.java:29)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:149)
   at net.sf.hibernate.hql.QueryTranslator.compile(QueryTranslator.java:138)
   at net.sf.hibernate.impl.SessionFactoryImpl.getQuery(SessionFactoryImpl.java:295)
   at net.sf.hibernate.impl.SessionImpl.getQueries(SessionImpl.java:1571)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1542)
   at net.sf.hibernate.impl.QueryImpl.list(QueryImpl.java:39)
   at com.bmw.candy.candiedServices.SubscriptionAccess.fetchNewIssues(SubscriptionAccess.java:303)
   ... 29 more



Hibernate version:
Current Production

Mapping documents:
Code:
<?xml version="1.0" encoding='utf-8'?>
<!DOCTYPE hibernate-mapping PUBLIC "-//Hibernate/Hibernate Mapping DTD//EN"
  "http://hibernate.sourceforge.net/hibernate-mapping-2.0.dtd">

<hibernate-mapping schema="CandiedServices"
   package="com.bmw.candy.candiedServices.data">

   <class name="Subscription" table="SUBSCRIPTION">
      <id name="ID" type="long" unsaved-value="null" column="ID">
         <generator class="native" />
      </id>
      <property name="name" length="16" not-null="true" unique="true"/>
      <property name="description" length="256" not-null="true" />
      <set name="issues" sort="natural" table="SUBSCRIPTION_ISSUES" lazy="true">
         <key column="_issueID" />
         <composite-element class="SubscriptionIssue">
            <property name="issueNumber" not-null="true" unique="true"/>
            <property name="issueURL" length="512" not-null="true"/>
            <many-to-one name="subscription"/>
         </composite-element>
      </set>
   </class>

   <class name="Subscriber" table="SUBSCRIBER" lazy="true">
      <id name="ID" type="long" unsaved-value="null" column="ID">
         <generator class="native" />
      </id>
      <property name="username" length="15" not-null="true" unique="true"/>
      <property name="password" length="30" not-null="true" />
      <property name="familyName" length="30" not-null="true" />
      <property name="givenName" length="30" not-null="true" />
      <set name="subscriptions" sort="natural" table="SUBSCRIBER_SUBSCRIPTIONS">
         <key column="_statusID" />
         <composite-element class="SubscriptionStatus">
            <property name="lastIssue" not-null="true"/>
            <many-to-one name="subscription" not-null="true"/>
            <many-to-one name="subscriber" not-null="true"/>
         </composite-element>
      </set>
   </class>

</hibernate-mapping>


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 6:27 am 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
wow, I dont believe that NO ONE knows the answer to this.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 10:53 am 
Newbie

Joined: Mon Jan 17, 2005 9:23 am
Posts: 15
the answer is right in the exception message: "in" expected!!!!!111
read the simple example queries in the documentation


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 12:35 pm 
Hibernate Team
Hibernate Team

Joined: Tue Sep 09, 2003 2:10 pm
Posts: 3246
Location: Passau, Germany
Did you try using the full class name?


Top
 Profile  
 
 Post subject:
PostPosted: Mon Jan 17, 2005 1:06 pm 
Hibernate Team
Hibernate Team

Joined: Thu Dec 18, 2003 9:55 am
Posts: 1977
Location: France
i can be wrong but i think ID is a protected word, try changing the property name

_________________
Anthony,
Get value thanks to your skills: http://www.redhat.com/certification


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:24 am 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
ynnor wrote:
the answer is right in the exception message: "in" expected!!!!!111
read the simple example queries in the documentation


Gee that was helpful; or actually NOT. I never knew I would come to a professional forum and find a troll like this. I read the samples of course and I read everything in the manual. There is no place I could imagine putting the keyword "in" at.

Next he will suggest that i google for the word "in".

*rolleyes*


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:25 am 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
anthony wrote:
i can be wrong but i think ID is a protected word, try changing the property name


I use it in other searches and it works fine.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 7:25 am 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
michael wrote:
Did you try using the full class name?


No but I shouldnt have to according to the Hibernate docs. It must be something to do with searching wihtin a component collection.


Top
 Profile  
 
 Post subject:
PostPosted: Tue Jan 18, 2005 10:56 am 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
You can't query a composite-element class that way.

Use:

Code:
from Subscription subscription join s.issues issue
where subscription.ID = :subscriptionID
and issue.issueNumber > :lastIssue


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 19, 2005 4:40 am 
Newbie

Joined: Thu Dec 30, 2004 7:44 am
Posts: 15
gavin wrote:
You can't query a composite-element class that way.

Use:

Code:
from Subscription subscription join s.issues issue
where subscription.ID = :subscriptionID
and issue.issueNumber > :lastIssue


Thanks gavin .. can you point me to where I can find documentation on that ?


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 10 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.