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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:17:36+00:00 2026-05-26T21:17:36+00:00

My application uses JPA to access the backend database. I have a Java class

  • 0

My application uses JPA to access the backend database.

I have a Java class mapped to a table. The class has a string field (called status) that consists of a series of “0”s and “1”s. I need to select a few records based on the field’s second character. Here is what I can do without using JPA (I am using MS SQLServer).

SELECT * FROM Machines where SUBSTRING(status, 2, 1) = '1'

How can I do it using JPA?

  • 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-26T21:17:36+00:00Added an answer on May 26, 2026 at 9:17 pm

    There is a SUBSTRING function in JPA:

    http://download.oracle.com/otn-pub/jcp/persistence-2.0-fr-eval-oth-JSpec/persistence-2_0-final-spec.pdf

    4.6.17.2.1 “String functions”

    (…)

    SUBSTRING(string_primary, simple_arithmetic_expression [, simple_arithmetic_expression])

    (…)

    The second and third arguments of the SUBSTRING function denote the starting position and
    length of the substring to be returned. These arguments are integers.
    The third argument is optional. If it is not specified, the substring
    from the start position to the end of the string is returned. The
    first position of a string is denoted by 1. The SUBSTRING function
    returns a string.

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

Sidebar

Related Questions

I have a java application which uses JPA. Say I have an entity called
I have an application that uses hibernate and JPA to handle the database. I
I have a java web application built on Stuts2/Google Guice/JPA. It uses hibernate as
My application uses MS access database to save some sensitive information. Though that information
Has anyone heard of this error before: I have a Java 5 application, that
I have a JPA/Spring application that uses Hibernate as the JPA provider. In one
I try to build simple Java EE application that uses JPA + EJB3 and
I have a Java enterprise application that provides a web service, has a domain
We have implemented JUnit4 in our application which uses Spring core & JPA with
I have an application using hibernate 3.1 and JPA annotations. It has a few

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.