How to search JPA entities by referenced entity's id without additional SQL queries issued?

Solution Verified - Updated -

Issue

There is an entity named "Foo" containing a reference to another entity (let's name it "Bar") in a many-to-one relationship. Is it possible in JPA to search for all Foos referencing a specific Bar so that only one SQL query would be issued to the database?

Environment

  • Red Hat JBoss Enterprise Application Platform (EAP)
    • 6.x

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content