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

  • SEARCH
  • Home
  • 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 8726289
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T08:12:57+00:00 2026-06-13T08:12:57+00:00

I am using oracle 10g and hibernate 3.3.2 . I have used regular expression

  • 0

I am using oracle 10g and hibernate 3.3.2. I have used regular expression in sql before, now for the first time I am using it in HQL.

Query query = getSession().createQuery("From Company company 
where company.id!=:companyId and 
regexp_like(upper(rtrim(ltrim(company.num))), '^0*514619915$' )");

This is my hql, when i run it without regex_like function it runs as expected. But I am not able to execute it with regex_like expression.

It says..

nested exception is org.hibernate.hql.ast.QuerySyntaxException:
unexpected AST node: ( near line 1, column 66…..

Kindly help, how can I use regex_like in hibernate native query? OR some other alternative to do so.

  • 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-13T08:12:58+00:00Added an answer on June 13, 2026 at 8:12 am

    Actually, you can’t compare the result of REGEXP_LIKE to anything except in conditional statements in PL/SQL.

    Hibernate seems to not accept a custom function without a returnType, as you always need to compare the output to something, i.e:

    REGEXP_LIKE('bananas', 'a', 'i') = 1
    

    As Oracle doesn’t allow you to compare this function’s result to nothing, I came up with a solution using case condition:

    public class Oracle10gExtendedDialect extends Oracle10gDialect {
    
        public Oracle10gExtendedDialect() {
            super();
            registerFunction(
              "regexp_like", new SQLFunctionTemplate(StandardBasicTypes.BOOLEAN,
              "(case when (regexp_like(?1, ?2, ?3)) then 1 else 0 end)")
            );
        }
    
    }
    

    And your HQL should look like this:

    REGEXP_LIKE('bananas', 'a', 'i') = 1
    

    It will work 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am using hibernate 3 , oracle 10g. I have a table: subject. The
I am using Ejb3 and JPA (based on Hibernate and Oracle 10g at the
I am using Oracle 10g and I have the following stored procedure: CREATE OR
I am using oracle 10g and wrote a query like this: SELECT presenttime, employeeid
I'm using Oracle 10g. Question: How can I write query to return just ID
I have a hibernate project which interacts with Oracle 10g database, and have a
I'm using Hibernate v4.1.4.final.jar using Java 1.7 to connect to Oracle 10g server. And
I have the following HQL in Hibernate using Spring MVC. List<Colour>list=session.createQuery(from Colour order by
I am using Oracle 10g, and I have a view that joins two large
I am using oracle 10g. I tried to merge two tables. At that time

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.