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 7691787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:42:11+00:00 2026-05-31T20:42:11+00:00

I do have a static metamodel with a NUMBER (actually, BigDecimal, don’t ask why)

  • 0

I do have a static metamodel with a NUMBER (actually, BigDecimal, don’t ask why) column. Now I would like to do a LIKE query against that number column:

CriteriaBuilder cb;
cb.like(entity.get(Entity_.numbercol), "123%");

where entity.get(Entity_.numbercol) returns a Path<BigDecimal>. Naturally, I get a compile error: ...like(Expression<String>, ...) ... not applicable for the arguments (Path<BigDecimal>, ...)

Casting the column with .as(String.class) fails due to some Bug in JPA, but I don’t have the bug number at hands right now. It is not fixed in the latest version of JPA/Hibernate, though. Anyway, it results in a runtime exception about some invalid SQL statement being generated.

Now I just need a way to get the criteria API equivalent of the SQL

... WHERE numbercol LIKE '123%';

Searching for the topic already brought up the following responses, which don’t help because I have a static metamodel:
NHibernate – easiest way to do a LIKE search against an integer column with Criteria API? and JPA/Criteria API – Like & equal problem

Any ideas?

Thanks in advance
Dominik

  • 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-05-31T20:42:13+00:00Added an answer on May 31, 2026 at 8:42 pm

    No, it does not fail because of bug, it works as specified (for example in Javadoc):

    Perform a typecast upon the expression, returning a new expression
    object. This method does not cause type conversion: the runtime type
    is not changed. Warning: may result in a runtime failure.

    Method you use performs cast and you need conversion. In general there is no support to convert from BigDecimal to String in JPA.

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

Sidebar

Related Questions

I have a static class that I would like to raise an event as
I got a Utility module since VB.NET doesn't have static class like C# and
Right now we have static code to a XML schema file. But now we
Can I call(access) non static method from static method ?? Like I have static
I have static left column and right column on right. The problem is when
In my CakePHP app I have static pages set up like this: Router::connect( '/terms',
I have static content like html,css javascript stored in DB. when a user requests
I have several service classes that have static methods and offer a service to
Suppose I have static ip in a subnet that has DHCP server. If i
Why can we have static final members but cant have static method in an

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.