glassfish
  1. glassfish
  2. GLASSFISH-1416

valid query fails with "invalid query key"

    Details

    • Type: Bug Bug
    • Status: Resolved
    • Priority: Major Major
    • Resolution: Duplicate
    • Affects Version/s: 9.1pe
    • Fix Version/s: 9.1pe
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: Windows XP
      Platform: PC

    • Issuezilla Id:
      1,416

      Description

      The following query fails:

      SELECT ex FROM Exhibition AS ex, Showpiece AS sh WHERE sh.enamelId = :enamelId
      AND sh.showId = ex.id ORDER BY ex.year

      with the following exception:

      Exception [TOPLINK-6015] (Oracle TopLink Essentials - 2006.8 (Build 060830)):
      oracle.toplink.essentials.exceptions.QueryException
      Exception Description: Invalid query key [enamelId] in expression.

      However I believe this is a valid query as all the refernced entities and
      properties exist.

      The identical code works if I switch from the Toplink entity manager to the
      Hibernate entity manager.

      platform: Win Xp Pro SP2, glassfish 9.0 U1, MySQL 5, NetBeans 5.5

      The attached server log shows the full stack trace.

      The attached NetBeans project contains an ejb module and a JUnit test.

      To replicate the error, deploy the ejb jar and run the the unit test.

      1. GL2Bug server.log
        25 kB
        schwarcz
      2. GLBUG2_log2.txt
        157 kB
        schwarcz

        Activity

        Hide
        mb124283 added a comment -

        Created an attachment (id=575)
        J2SE test case

        Show
        mb124283 added a comment - Created an attachment (id=575) J2SE test case
        Hide
        schwarcz added a comment -

        While the reordered query does generate SQL, the results are pretty worrisome
        from a performance view and quality view.

        Hibernate, as expected generates a single SELECT. As shown in the attached log,
        Toplink generates a huge number of selects and then dies trying to insert into
        the join table. It is unaccountable to me that a straight forward join results
        in an a attempt to insert into the join table.

        Show
        schwarcz added a comment - While the reordered query does generate SQL, the results are pretty worrisome from a performance view and quality view. Hibernate, as expected generates a single SELECT. As shown in the attached log, Toplink generates a huge number of selects and then dies trying to insert into the join table. It is unaccountable to me that a straight forward join results in an a attempt to insert into the join table.
        Hide
        schwarcz added a comment -

        Created an attachment (id=576)
        server log

        Show
        schwarcz added a comment - Created an attachment (id=576) server log
        Hide
        mf125085 added a comment -

        Looks like you are trying to model a ManyToMany relationship btw. Enamel and
        Exhibition, which has an attribute changedBy on the relationship.

        In your POJOs, there is a ManyToMany relationship owned by Exhibition. The
        Showpiece class is introduced to model the attribute on the ManyToMany
        relationship.

        The problem is, that the join table is mapped twice: to the relationship and
        as a POJO (Showpiece) at the same time. You can not map a join table to a
        relationship and a POJO at the same time. The ManyToMany relationship btw.
        Enamel and Exhibition should be mapped as two relationships:

        A OneToMany relationship btw. Enamel and Showpiece, owned by Showpiece
        and a OneToMany relationship btw. Exhibition and Showpiece, owned by Showpiece

        The primary key for Showpiece should be (showId, enamelId).

        Show
        mf125085 added a comment - Looks like you are trying to model a ManyToMany relationship btw. Enamel and Exhibition, which has an attribute changedBy on the relationship . In your POJOs, there is a ManyToMany relationship owned by Exhibition. The Showpiece class is introduced to model the attribute on the ManyToMany relationship. The problem is, that the join table is mapped twice: to the relationship and as a POJO (Showpiece) at the same time. You can not map a join table to a relationship and a POJO at the same time. The ManyToMany relationship btw. Enamel and Exhibition should be mapped as two relationships: A OneToMany relationship btw. Enamel and Showpiece, owned by Showpiece and a OneToMany relationship btw. Exhibition and Showpiece, owned by Showpiece The primary key for Showpiece should be (showId, enamelId).
        Hide
        pkrogh added a comment -

        2333 - being targetted for 9.1 FCS

            • This issue has been marked as a duplicate of 2333 ***
        Show
        pkrogh added a comment - 2333 - being targetted for 9.1 FCS This issue has been marked as a duplicate of 2333 ***

          People

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

            Dates

            • Created:
              Updated:
              Resolved: