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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:51:18+00:00 2026-05-31T18:51:18+00:00

How to write a JPA query that make a join between 2 entities that

  • 0

How to write a JPA query that make a join between 2 entities that doesn’t share any reference between them I mean no Relation has been defined in the mapping

EntityA
@Id
long id

String field1
String field2

EntityB
@Id
String field1
@Id
String field2

How can I write a join like This in JPQL

select entityB from entityA,entityB
where entityB.field1 = entityA.field1
and entityB.field2 = entityA.field2

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-05-31T18:51:19+00:00Added an answer on May 31, 2026 at 6:51 pm

    You’re thinking in SQL, not ORM. In ORM, you create relationships between entities (@OneToMany, @ManyToOne, @ManyToMany, etc.), and the ORM uses those relationships to determine how it should join them together.

    You need to update your entities to have those relationships, and then traverse the object model to do what your want to do.

    Here is a place to get started: http://docs.jboss.org/hibernate/annotations/3.5/reference/en/html_single/#entity-mapping-association

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

Sidebar

Related Questions

Learning how to write JPA query. Please advise me whether it possible to write
I am trying to write the following SQL query as a JPA query. The
I'm trying to write some unit tests for a JPA model that I've built
In the JPA, how to write a query to load child class. For example,
I'm using JPA and I am using second-level cache for all the reference entities.
I am writing a JPA QL named query that would search for documents. This
What is the best way to change n-to-n relationships between two entities in JPA.
What is the correct way to write this JPA query? I am just guessing
write a script that takes two optional boolean arguments,--verbose‚ and ‚--live, and two required
I write programs used internally by our company. I've created several support DLLs that

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.