I want to know whether I can join 2 named queries in JPA. As an example I have two following named queries
1 - Get all the active users
2 - get all the users for a given company
Is it possible for me to join above two named queries and get get all the active users for a given company.
Don't use NamedQuery
for this. Directly passing a query string to the method is your best bet.
You must understand that the method createNamedQuery(String name)
takes name of a named query. Whereas, createNamedQuery(String qlString)
takes a query string, so this fits your need.
Or
Create a separate NamedQuery
for this very purpose.