Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9058105
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T14:38:16+00:00 2026-06-16T14:38:16+00:00

I wanna use the named parameters with CONTAINS like that : select p from

  • 0

I wanna use the named parameters with CONTAINS like that :

select p from person p
where CONTAINS(p.name , :myName)

String myName = "Bob Jones";
q.setString("myName", "*" + myName + "*");  

It doesn’t work, the error:

org.hibernate.exception.GenericJDBCException: could not execute query
    at org.hibernate.exception.SQLStateConverter.handledNonSpecificException(SQLStateConverter.java:140)
    at org.hibernate.exception.SQLStateConverter.convert(SQLStateConverter.java:128)
    at org.hibernate.exception.JDBCExceptionHelper.convert(JDBCExceptionHelper.java:66)
    at org.hibernate.loader.Loader.doList(Loader.java:2536)
    at org.hibernate.loader.Loader.listIgnoreQueryCache(Loader.java:2276)
    at org.hibernate.loader.Loader.list(Loader.java:2271)
    at org.hibernate.loader.custom.CustomLoader.list(CustomLoader.java:316)
    at org.hibernate.impl.SessionImpl.listCustomQuery(SessionImpl.java:1842)
    at org.hibernate.impl.AbstractSessionImpl.list(AbstractSessionImpl.java:165)
    at org.hibernate.impl.SQLQueryImpl.list(SQLQueryImpl.java:157)
Caused by: java.sql.SQLException: Erreur de syntaxe près de 'Jones*' dans la condition de recherche en texte intégral '*Bob Jones*'.
    at net.sourceforge.jtds.jdbc.SQLDiagnostic.addDiagnostic(SQLDiagnostic.java:368)
    at net.sourceforge.jtds.jdbc.TdsCore.tdsErrorToken(TdsCore.java:2820)
    at net.sourceforge.jtds.jdbc.TdsCore.nextToken(TdsCore.java:2258)
    at net.sourceforge.jtds.jdbc.TdsCore.getMoreResults(TdsCore.java:632)
    at net.sourceforge.jtds.jdbc.JtdsStatement.executeSQLQuery(JtdsStatement.java:477)
    at net.sourceforge.jtds.jdbc.JtdsPreparedStatement.executeQuery(JtdsPreparedStatement.java:778)
    at com.mchange.v2.c3p0.impl.NewProxyPreparedStatement.executeQuery(NewProxyPreparedStatement.java:76)
    at org.hibernate.jdbc.AbstractBatcher.getResultSet(AbstractBatcher.java:208)
    at org.hibernate.loader.Loader.getResultSet(Loader.java:1953)
    at org.hibernate.loader.Loader.doQuery(Loader.java:802)
    at org.hibernate.loader.Loader.doQueryAndInitializeNonLazyCollections(Loader.java:274)
    at org.hibernate.loader.Loader.doList(Loader.java:2533)
    ... 8 more

I use hibernate 3.6
What should I do?
Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T14:38:18+00:00Added an answer on June 16, 2026 at 2:38 pm

    I assume you’re using SQL Server. Then your query contains a problem that has nothing to do with Hibernate or Java. It’s just about the syntax of the CONTAINS operator. Just try it with any tool that can directly query the database.

    If you want to query for two words, the syntax is either of the following:

    select * from person where contains(name, 'Bob AND Jones');
    select * from person where contains(name, 'Bob OR Jones');
    select * from person where contains(name, '"Bob Jones"');
    

    If you additionally want to query for prefixes, it’s:

    select * from person where contains(name, 'Bob* AND Jones*');
    select * from person where contains(name, 'Bob* OR Jones*');
    select * from person where contains(name, '"Bob Jones*"');
    

    You cannot put the asterisk in front of a word or phrase.

    I recommend you have a look at the description of the CONTAINS operator.

    Update:

    Thanks for your comment. If you look at your old code, you’ll note the extra pair of double quotes that enclosed the second argument to CONTAINS, similar to my third and last example. That’s what’s missing in your current code. So to fix it:

    String myName = "Bob Jones";
    q.setString("myName", "\"*" + myName + "*\"");
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wanna execute this query: String query = select login,full_name from users where team_id='
It's like this, I created a UITableViewCell subclass called NewsItemCell, then I wanna use
I wanna use temporary table to avoid field names enumeration inside SELECT clause. And
just for knowledge sake, i wanna know that how good is to use a
I have a project that I wanna use codeigniter to resize the uploaded image
I wanna use powershell to get all the file in sharepoint library EM_DOC_LIBRARY and
In my Asp.Net project I wanna use Property Auto-wiring, e.g. for my ILogger. Basically
i had use the spring3.1 ibatis2.x and mysql5.5. then i wanna use the replication
I have a Class CButtonCreate without get & set Methode. But i wanna use
Use case: Wanna insert custom annotation to fields in java class generated by JAXB

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.