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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:33:21+00:00 2026-06-13T03:33:21+00:00

Again, posting and answering a question for the benefit of others based on a

  • 0

Again, posting and answering a question for the benefit of others based on a problem I had the other day. Hopefully this saves someone a bit of time. I was a little surprised this wasn’t built into JPA’s EntityManager.

How can I determine if an Entity has a NamedQuery annotation with a specific name?

I need to determine if an Entity has a particular @NamedQuery before I try executing it.

  • 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-13T03:33:22+00:00Added an answer on June 13, 2026 at 3:33 am

    When annotations are nested, you can get the properties of the annotation to get it’s children. In the case of @NamedQueries, it’s .value().

    public boolean hasNamedQuery(Class<?> clazz, String nameOfQuery) {
        boolean foundQueryByName = false;
        NamedQueries namedQueries = clazz.getAnnotation(NamedQueries.class);
        if (namedQueries != null && namedQueries.value() != null) {
            NamedQuery[] values = namedQueries.value();
            for (int i = 0; i < values.length && !foundQueryByName; i++) {
                foundQueryByName |= (nameOfQuery.equals(values[i].name()));
            }
        }
        return foundQueryByName;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am again posting the same question. Please help me in this problem. Here
I posting this again, trying to make the question/problem clearer: ListView lv; List<Item> items;
Before you all get pissy about me posting this question again, let me explain
Sorry for posting this question again. I rephrased my question a little bit. I
I tried posting this question earlier but was unsuccessful so I'm trying again I
I am posting this question again because I didn't explain clear enough. Here are
I'm posting this question again but this time I'm including the full code. It's
Note: I ended up answering my own question shortly after posting this. Thanks and
Again, I was creating buttons dynamically based on this post and now I need
Again I have a question regarding this plugin: http://t.wits.sg/2008/06/20/jquery-progress-bar-11/ What I want to achieve

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.