-->
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.  [ 4 posts ] 
Author Message
 Post subject: "in expected" error when executing session.find
PostPosted: Sun Mar 20, 2005 8:36 pm 
Beginner
Beginner

Joined: Mon Dec 06, 2004 4:20 pm
Posts: 34
I'm getting the following error:
Code:
net.sf.hibernate.QueryException: in expected: i [from item i where ? in i.description]
   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:1572)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1531)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1527)
   at ftest.ItemRetrievalFTest.testRetrieveByFind(ItemRetrievalFTest.java:88)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)



when I execute this method:

Code:
   public void testRetrieveByFind() throws HibernateException {
      Session session = getSession();
      String query = "from item i where ? in i.description";
      String value = "Old Guitar";
      List results = session.find(query, value, new StringType());
      assertNotNull(results);
      assertTrue(results.size() > 0);
      System.out.println("Size of Find list: " + results.size());
      session.close();
   }


Any ideas anyone?

Hibernate version:2.1:


Mapping documents:<hibernate-mapping>
<class name="domain.Item" table="item" dynamic-insert="true" dynamic-update="true" lazy="true">
<id name="id" unsaved-value="0" column="ITEM_ID" type="long">
<generator class="identity" />
</id>
<bag name="bids" cascade="all-delete-orphan" inverse="true">
<key column="ITEM_ID" />
<one-to-many class="domain.Bid" />
</bag>
<property name="description" type="java.lang.String" column="description" />
<property name="price" type="float" column="price" />
</class>
<class name="domain.Bid" table="bid" lazy="true">
<id name="id" unsaved-value="0" column="BID_ID" type="long">
<generator class="identity" />
</id>
<many-to-one name="item" column="ITEM_ID" class="domain.Item" />
<property name="amount" column="amount" type="float" />
</class>
</hibernate-mapping>


Code between sessionFactory.openSession() and session.close():
String query = "from item i where ? in i.description";
String value = "Old Guitar";
List results = session.find(query, value, new StringType());
assertNotNull(results);
assertTrue(results.size() > 0);
System.out.println("Size of Find list: " + results.size());


Full stack trace of any exception that occurs:

Name and version of the database you are using:

The generated SQL (show_sql=true):
Hibernate: select item0_.ITEM_ID as ITEM_ID, item0_.description as descript2_, item0_.price as price from item item0_ where (item0_.description=? )
Hibernate: select bids0_.ITEM_ID as ITEM_ID__, bids0_.BID_ID as BID_ID__, bids0_.BID_ID as BID_ID0_, bids0_.ITEM_ID as ITEM_ID0_, bids0_.amount as amount0_ from bid bids0_ where bids0_.ITEM_ID=?
Hibernate: select bids0_.ITEM_ID as ITEM_ID__, bids0_.BID_ID as BID_ID__, bids0_.BID_ID as BID_ID0_, bids0_.ITEM_ID as ITEM_ID0_, bids0_.amount as amount0_ from bid bids0_ where bids0_.ITEM_ID=?
Hibernate: select item0_.ITEM_ID as ITEM_ID0_, item0_.description as descript2_0_, item0_.price as price0_ from item item0_ where item0_.ITEM_ID=?
Hibernate: select bids0_.ITEM_ID as ITEM_ID__, bids0_.BID_ID as BID_ID__, bids0_.BID_ID as BID_ID0_, bids0_.ITEM_ID as ITEM_ID0_, bids0_.amount as amount0_ from bid bids0_ where bids0_.ITEM_ID=?


Debug level Hibernate log excerpt:


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2005 9:29 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 7:19 pm
Posts: 2364
Location: Brisbane, Australia
Try:

Code:
String query = "from item i where i.description like ?";
String value = "Old Guitar";
List results = session.find(query, "%"+value+"%", new StringType());


Top
 Profile  
 
 Post subject: re: "in expected"
PostPosted: Sun Mar 20, 2005 9:50 pm 
Beginner
Beginner

Joined: Mon Dec 06, 2004 4:20 pm
Posts: 34
Thanks for the reply David. I tried that, and no luck. Still the same error:

Code:
net.sf.hibernate.QueryException: in expected: i [from item i where i.description like ?]
   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:1572)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1543)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1531)
   at net.sf.hibernate.impl.SessionImpl.find(SessionImpl.java:1527)
   at ftest.ItemRetrievalFTest.testRetrieveByFind(ItemRetrievalFTest.java:88)
   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
   at java.lang.reflect.Method.invoke(Method.java:324)
   at junit.framework.TestCase.runTest(TestCase.java:154)
   at junit.framework.TestCase.runBare(TestCase.java:127)
   at junit.framework.TestResult$1.protect(TestResult.java:106)
   at junit.framework.TestResult.runProtected(TestResult.java:124)
   at junit.framework.TestResult.run(TestResult.java:109)
   at junit.framework.TestCase.run(TestCase.java:118)
   at junit.framework.TestSuite.runTest(TestSuite.java:208)
   at junit.framework.TestSuite.run(TestSuite.java:203)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:421)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:305)
   at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:186)


Anything else I can try?


Top
 Profile  
 
 Post subject:
PostPosted: Sun Mar 20, 2005 11:50 pm 
Hibernate Team
Hibernate Team

Joined: Tue Aug 26, 2003 12:50 pm
Posts: 5130
Location: Melbourne, Australia
Your class is called "Item" not "item".


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 4 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.