[GLASSFISH-17283] @NamedQuery is not able to resolve query names Created: 09/Sep/11  Updated: 24/Jan/12

Status: Open
Project: glassfish
Component/s: entity-persistence
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Bug Priority: Major
Reporter: arungupta Assignee: tware
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Tags: 3_1_2-exclude

 Description   

In NetBeans:

  • Create a Java EE 6 project, enable CDI and JSF
  • Use jdbc/sample database and generate JPA entities for any table
  • Add the named queries as:

@NamedQueries({
@NamedQuery(name = "Sezzion.findAll", query = "SELECT s FROM Sezzion s"),
@NamedQuery(name = "Sezzion.findAllTracks", query = "SELECT DISTINCT s.TRACK FROM Sezzion s"),

The names should be "findAll" and other name should be "findAllXXX".

  • Create an EJB and inject EntityManager:

@PersistenceContext
EntityManager em;

  • Invoke any of the query in an EJB
  • Use this EJB in an .XHTML page and view the page in a browser to see the error below:

Exception Description: Cannot add a query whose types conflict with an existing query. Query To Be Added: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments [[]].The existing conflicting query: [ReadAllQuery(name="Sezzion.findAll" referenceClass=Sezzion jpql="SELECT s FROM Sezzion s")] is named: [Sezzion.findAll] with arguments: [[]].
at org.eclipse.persistence.exceptions.ValidationException.existingQueryTypeConflict(ValidationException.java:902)
at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:422)
at org.eclipse.persistence.internal.sessions.AbstractSession.addQuery(AbstractSession.java:395)
at org.eclipse.persistence.internal.sessions.AbstractSession.processJPAQueries(AbstractSession.java:2148)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.initializeDescriptors(DatabaseSessionImpl.java:442)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.postConnectDatasource(DatabaseSessionImpl.java:673)
at org.eclipse.persistence.internal.sessions.DatabaseSessionImpl.login(DatabaseSessionImpl.java:631)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryDelegate.createEntityManagerImpl(EntityManagerFactoryDelegate.java:284)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManagerImpl(EntityManagerFactoryImpl.java:290)
at org.eclipse.persistence.internal.jpa.EntityManagerFactoryImpl.createEntityManager(EntityManagerFactoryImpl.java:275)
at com.sun.enterprise.container.common.impl.EntityManagerWrapper._getDelegate(EntityManagerWrapper.java:208)

if "Sezzion.findAllTracks" query is removed then everything works as expected.



 Comments   
Comment by arungupta [ 09/Sep/11 ]

Filed as: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357177

Comment by Joe Di Pol [ 24/Jan/12 ]

No progress since submitted. Excluding from 3.1.2

Generated at Mon Feb 15 00:08:28 UTC 2016 using JIRA 6.2.3#6260-sha1:63ef1d6dac3f4f4d7db4c1effd405ba38ccdc558.