-->
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.  [ 3 posts ] 
Author Message
 Post subject: Error with FullTextQuery
PostPosted: Thu Nov 12, 2009 7:36 pm 
Newbie

Joined: Fri Jul 27, 2007 4:24 pm
Posts: 5
Hi,

When I do:
Code:
  FullTextQuery hibQuery = fullTextSession.createFullTextQuery(query, MyBean.class);
  List<MyBean> tmp = hibQuery.list();


I get:
Code:
org.hibernate.exception.SQLGrammarException: could not execute query
   at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:67)
   at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:43)
   at org.hibernate.loader.Loader.doList(Loader.java:2223)
   at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2104)
   at org.hibernate.loader.Loader.list(Loader.java:2099)
   at org.hibernate.loader.criteria.CriteriaLoader.list(CriteriaLoader.java:94)
   at org.hibernate.impl.SessionImpl.list(SessionImpl.java:1569)
   at org.hibernate.impl.CriteriaImpl.list(CriteriaImpl.java:283)
   at org.hibernate.search.engine.QueryLoader.load(QueryLoader.java:79)
   at org.hibernate.search.query.FullTextQueryImpl.list(FullTextQueryImpl.java:244)
   at com.my.MyDAOImpl.fullTextSearch(MyDAOImpl.java:239)
   ... 166 more
Caused by: java.sql.SQLException: [SQL0104] Token ? was not valid. Valid tokens: (.
   at com.ibm.as400.access.JDError.throwSQLException(JDError.java:650)
   at com.ibm.as400.access.JDError.throwSQLException(JDError.java:621)
   at com.ibm.as400.access.AS400JDBCStatement.commonPrepare(AS400JDBCStatement.java:1557)
   at com.ibm.as400.access.AS400JDBCPreparedStatement.<init>(AS400JDBCPreparedStatement.java:193)
   at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:2025)
   at com.ibm.as400.access.AS400JDBCConnection.prepareStatement(AS400JDBCConnection.java:1824)
   at com.mchange.v2.c3p0.impl.NewProxyConnection.prepareStatement(NewProxyConnection.java:213)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:505)
   at org.hibernate.jdbc.AbstractBatcher.getPreparedStatement(AbstractBatcher.java:423)
   at org.hibernate.jdbc.AbstractBatcher.prepareQueryStatement(AbstractBatcher.java:139)
   at org.hibernate.loader.Loader.prepareQueryStatement(Loader.java:1547)
   at org.hibernate.loader.Loader.doQuery(Loader.java:673)
   at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:236)
   at org.hibernate.loader.Loader.doList(Loader.java:2220)
   ... 174 more


However it works fine when I do just:
Code:
  FullTextQuery hibQuery = fullTextSession.createFullTextQuery(query);
  List<MyBean> tmp = hibQuery.list();


MyBean has a composite id, which is defined like this:
Code:
@Entity
@Table(name = "myTable")
@Indexed(index = "indexes/mybean")
public class MyBean implements Serializable {

    private MyBeanId myBeanId;

    // other fields

    @EmbeddedId
    @DocumentId
    @FieldBridge(impl = MyBeanIdFieldBridge.class)
    public MyBeanId getMyBeanId() {
        return myBeanId;
    }

    public void setMyBeanId(MyBeanId myBeanId) {
        this.myBeanId= myBeanId;
    }

    // other getters/setters
}

@SuppressWarnings("serial")
@Embeddable
public class MyBeanId implements Serializable, Comparable<MyBeanId> {

    private long id;
    private long secondId;

    @Field(index = Index.TOKENIZED, store = Store.NO)
    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public long getSecondId() {
        return secondId;
    }

    public void setSecondId(long secondId) {
        this.secondId= secondId;
    }

    @Override
    public String toString() {
        return "" + id;
    }

    @Override
    public boolean equals(Object in) {
        return EqualsBuilder.reflectionEquals(this, in);
    }

    @Override
    public int hashCode() {
        return HashCodeBuilder.reflectionHashCode(this);
    }

    public int compareTo(MyBeanId o) {
        return ((Long) id).compareTo(o.getId());
    }
}


The generated SQL looks like this (trimmed):
Code:
select this_.id as id7_16_, this_.secondId as second2_7_16_, /*other stuff*/ from myTable this_ left outer join /*other stuff*/ where ((this_.id, this_.secondId) in ((?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?), (?, ?)))


It looks like DB2/400 doesn't like those tuples... It works fine on MySQL, so I'm kinda suspecting DB2400Dialect. Any ideas/suggestions are very appreciated.

Thanks,

Pavel

PS: using the latest-latest Hibernate (3.3.2) and Search (3.1.1) jar files.


Top
 Profile  
 
 Post subject: Re: Error with FullTextQuery
PostPosted: Fri Nov 13, 2009 3:38 am 
Hibernate Team
Hibernate Team

Joined: Thu Apr 05, 2007 5:52 am
Posts: 1689
Location: Sweden
Hi,

Sounds a like http://opensource.atlassian.com/project ... SEARCH-306. Can you try your code against the latest trunk build. You can find a SNAPSHOT here http://snapshots.jboss.org/maven2/org/h ... -SNAPSHOT/

--Hardy


Top
 Profile  
 
 Post subject: Re: Error with FullTextQuery
PostPosted: Fri Nov 13, 2009 11:11 am 
Newbie

Joined: Fri Jul 27, 2007 4:24 pm
Posts: 5
hardy.ferentschik wrote:
Hi,

Sounds a like http://opensource.atlassian.com/project ... SEARCH-306. Can you try your code against the latest trunk build. You can find a SNAPSHOT here http://snapshots.jboss.org/maven2/org/h ... -SNAPSHOT/

--Hardy


Hardy, thanks for the reply.

It actually sounds more like http://opensource.atlassian.com/project ... SEARCH-248

I'll give the 3.2.0-SNAPSHOT a try.

Thanks again,

Pavel


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