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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:54:20+00:00 2026-06-15T08:54:20+00:00

JPA specification says: Only the values of like types are permitted to be compared.

  • 0

JPA specification says:

Only the values of like types are permitted to be compared. A type is like another type if they correspond to the same Java language type, or if one is a primitive Java language type and the other is the
wrappered Java class type equivalent (e.g., int and Integer are like types in this sense). There is one
exception to this rule: it is valid to compare numeric values for which the rules of numeric promotion
apply. Conditional expressions attempting to compare non-like type values are disallowed except for
this numeric case.

Note that the arithmetic operators and comparison operators are permitted to be applied to
state fields and input parameters of the wrappered Java class equivalents to the primitive
numeric Java types.

Two entities of the same abstract schema type are equal if and only if they have the same primary key
value.

Only equality/inequality comparisons over enums are required to be supported.

Comparisons over instances of embeddable class or map entry types are not supported.

Does this mean that queries

where entity1 = entity2

and

where entity1.id = entity2.id

should always give the same result (and have same performance) or are there some edge cases (e.g. if one of entities is null)? Is the behavior the same in all implementations?

  • 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-15T08:54:22+00:00Added an answer on June 15, 2026 at 8:54 am

    These can be different, depending where your entity comes from, and your JPA implementation.

    entity1 = entity2, may allow the JPA implementation to optimize out a join in certain cases.

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

Sidebar

Related Questions

The JPA (Java Persistence API) specification has 2 different ways to specify entity composite
When we write java code we use JPA interfaces as its a java specification
The JPA 2.0 specification says on page 22: The instance variables of a class
I'd like to use jpa repository with specification now I have two tables @Entity
JPA.em(default).createQuery(insert into USER (FULLNAME, EMAIL, USERNAME, PASSWORD) + VALUES (\'+fullname+\',\'+email+\',\'+username+\',\'+password+\');); is it a wrong
My jpa looks like below public class TESTClass implements Serializable { ... private String
I have been reading about JPA and EJB3 and would like to confirm that
I have a JPA object called Customer.java: @NamedQueries({@NamedQuery(name=getAccountWithCheckRangeByService, query=SELECT c FROM Customer}) public Long
I have defined a JPA entity A with a @ManyToOne relationship to another JPA
I am using openjpa runtime of JPA specification. At development time I am using

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.