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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T15:19:33+00:00 2026-06-11T15:19:33+00:00

When I am declaring named query via annotations Hibernate Session is not able to

  • 0

When I am declaring named query via annotations Hibernate Session is not able to find it but when I put into hbm.xml it works fine.

It is a legacy system where all the hibernate entities are defined via hbm.xml and I am slowly trying to migrate it to annotations.

Is it possible to distribute hibernate metadata via both hbm.xml and annotations?

Exception is

org.hibernate.MappingException: Named query not known: queryName

Entity Class is

@Entity
@NamedQueries({

    @NamedQuery(name="queryName", queryString="from Product pro")
})

public class Product extends HibernateEntity

Getting the Session

        SessionFactory hibernateSessionFactory = (SessionFactory) hibernateSessionFactories.get(targetDB);

        if (hibernateSessionFactory != null) 
        {
            session = hibernateSessionFactory.openSession(new HibernateEntityDifferenceInterceptor());

            session.setFlushMode(FlushMode.COMMIT);
        }
  • 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-11T15:19:35+00:00Added an answer on June 11, 2026 at 3:19 pm

    With Spring support it’s definitely possible, so if you don’t use Spring, you can look at the sources inside of it and figure out how it was implemented there.

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

Sidebar

Related Questions

I find myself declaring bunch of class variables and it is really tiring to
Is there a way to get any query parameter without explicitly declaring its name
Is there any viable reason why serialVersionUID field is not named SERIAL_VERSION_UID? According to
I have a query about strings. I'm declaring my string array as: private static
Declaring a class for (fast) testing purposes is great: require 'fast_helper' require 'site_search' class
When declaring any primitive type data like int or double they get initialized to
Is declaring an attribute of a table as UNIQUE equivalent to declaring it as
When declaring external ant tasks using taskdef, for instance ant-contrib, the proposed setup is
hi all i am declaring id and class when creating table dynamically as below
I'm declaring a varchar variable in T-SQL declare @var varchar(max); I have a select

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.