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

  • Home
  • SEARCH
  • 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 9018605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T04:34:10+00:00 2026-06-16T04:34:10+00:00

JPA is giving me an error when my application goes up. The error is

  • 0

JPA is giving me an error when my application goes up. The error is in the named query:

org.hibernate.HibernateException: Errors in named queries: MyEntity.MyQuery org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:435)
org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.java:1385)
org.hibernate.cfg.AnnotationConfiguration.buildSessionFactory(AnnotationConfiguration.java:954)
org.hibernate.ejb.Ejb3Configuration.buildEntityManagerFactory(Ejb3Configuration.java:883)
org.hibernate.ejb.HibernatePersistence.createEntityManagerFactory(HibernatePersistence.java:56)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:48)
javax.persistence.Persistence.createEntityManagerFactory(Persistence.java:32)

The Entity code:

@NamedQuery(name = "MyEntity.MyQuery", query = "SELECT r FROM MyEntity r WHERE r.cdSecao = :secao AND r.cdPublico IN :publico")


// other class stuff declarations...


    @JoinColumn(name = "cd_publico", referencedColumnName = "cd_publico")
@ManyToOne
private TbPublico cdPublico;

@JoinColumn(name = "cd_secao", referencedColumnName = "cd_secao")
@ManyToOne
private TbSecao cdSecao;

// getters setters and assorted shenanigans...

Then in the DAO, I invoke it with this method, even though the exception is being thrown at the init of the EntityManager (because its a named query and stuff). But for the sake of completeness, here it goes:

public List<MyEntity> listMyEntity(String idPublico, TbSecao secao) {
    List<TbPublico> listaPublico = OtherClass.doMcGuffin(idPublico);

    EntityManager em = EMFactory.getEntityManager();
    TypedQuery<MyEntity> theQuery= em.createNamedQuery("MyEntity.MyQuery", MyEntity.class);
    theQuery.setParameter("secao", secao);
    theQuery.setParameter("publico", listaPublico);

    return theQuery.getResultList();

}   

Back to the named query… if I remove the AND r.cdPublico IN :publico it works, but I need 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-16T04:34:12+00:00Added an answer on June 16, 2026 at 4:34 am

    Modify the query like this

    SELECT r FROM MyEntity r WHERE r.cdSecao = :secao AND r.cdPublico IN (:publico)

    When you use the IN statemet in your query then it should come into the ().

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

Sidebar

Related Questions

In JPA/Hibernate , we can write type-safe queries and accumulate our query predicates one
In my Hibernate JPA Sample code.. public List<AttendeesVO> addAttendees(String searchKeyword) { TypedQuery<AttendeesVO> query =
JPA/Hibernate missing column I am using JPA with Hibernate as the provider. I had
testing Play framework and JPA. I eclipsify my very simple test application. Import the
Using the JPA EntityManager and the JPA Query object, how can I override something
I have a JPA/Hibernate object which uses a composite key as the primary key.
Env: JPA 1, Hibernate 3.3.x, MySQL 5.x We auto generate database schema using hbm2ddl
I am using JPA, Hibernate and Spring MVC. In the controller class all the
In JPA, is there any way you can replicate Hibernate's saveOrUpdate behavior , saveOrUpdate
Every JPA-Provider (at least hibernate, eclipselink and openjpa) gives the possibility to create the

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.