glassfish
  1. glassfish
  2. GLASSFISH-990

? AND # SYMBOLS CAN'T BE USED IN NATIVE QUERY

    Details

    • Type: Bug Bug
    • Status: Open
    • Priority: Minor Minor
    • Resolution: Unresolved
    • Affects Version/s: 9.1pe
    • Fix Version/s: not determined
    • Component/s: entity-persistence
    • Labels:
      None
    • Environment:

      Operating System: All
      Platform: All

    • Issuezilla Id:
      990
    • Status Whiteboard:
      Hide

      HIGH

      Show
      HIGH

      Description

      Also logged as TopLink Also logged as TopLink bug 5472919.
      ? denotes positional parameter in native queries:
      "select * from CMP3_ADDRESS where city=?"
      or
      "select * from CMP3_ADDRESS where city=?1"

      However if ? are found in a literal - where it shouldn't be interpreted as a
      parameter - the query fails:
      "select * from CMP3_ADDRESS where city='?'"
      The same with #:
      "select * from CMP3_ADDRESS where city='#'".
      ? denotes positional parameter in native queries:
      "select * from CMP3_ADDRESS where city=?"
      or
      "select * from CMP3_ADDRESS where city=?1"

      However if ? are found in a literal - where it shouldn't be interpreted as a
      parameter - the query fails:
      "select * from CMP3_ADDRESS where city='?'"
      The same with #:
      "select * from CMP3_ADDRESS where city='#'"

        Activity

        Hide
        pkrogh added a comment -

        Reprioritized based on BUG triage. P4 HIGH.

        Show
        pkrogh added a comment - Reprioritized based on BUG triage. P4 HIGH.
        Hide
        gfbugbridge added a comment -

        <BT6540683>

        Show
        gfbugbridge added a comment - <BT6540683>
        Hide
        mb124283 added a comment -
            • Issue 2747 has been marked as a duplicate of this issue. ***
        Show
        mb124283 added a comment - Issue 2747 has been marked as a duplicate of this issue. ***
        Hide
        gyorke added a comment -

        A simple work around is to convert the query to use a positional parameter and
        provide the failing literal as a parameter.

        Query query = em.createNativeQuery("select * from CMP3_ADDRESS where city=?1",
        Address.class);
        query.setParameter(1, "?");

        Show
        gyorke added a comment - A simple work around is to convert the query to use a positional parameter and provide the failing literal as a parameter. Query query = em.createNativeQuery("select * from CMP3_ADDRESS where city=?1", Address.class); query.setParameter(1, "?");
        Hide
        Tom Mueller added a comment -

        Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

        Show
        Tom Mueller added a comment - Bulk update to change fix version to "not determined" for all issues still open but with a fix version for a released version.

          People

          • Assignee:
            ailitche
            Reporter:
            ailitche
          • Votes:
            1 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

            • Created:
              Updated: