glassfish
  1. glassfish
  2. GLASSFISH-17283

@NamedQuery is not able to resolve query names

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 3.1.1
    • Fix Version/s: None
    • Component/s: entity-persistence
    • Labels:
      None

      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.

        Activity

        Hide
        arungupta added a comment -
        Show
        arungupta added a comment - Filed as: https://bugs.eclipse.org/bugs/show_bug.cgi?id=357177
        Hide
        Joe Di Pol added a comment -

        No progress since submitted. Excluding from 3.1.2

        Show
        Joe Di Pol added a comment - No progress since submitted. Excluding from 3.1.2

          People

          • Assignee:
            tware
            Reporter:
            arungupta
          • Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: