Uploaded image for project: 'OpenJPA'
  1. OpenJPA
  2. OPENJPA-216

ArgumentException when no identification variable given in UPDATE clause

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 1.0.0
    • None
    • query
    • None

    Description

      According to the spec - 4.10 Bulk Update and Delete Operations page 104:

      update_statement ::= update_clause [where_clause]
      update_clause ::= UPDATE abstract_schema_name [[AS] identification_variable] SET update_item

      {, update_item}

      *
      update_item ::= [identification_variable.]

      {state_field | single_valued_association_field}

      = new_value

      The identification_variable is optional, but it doesn't seem to be true for OpenJPA 0.9.8-SNAPSHOT rev 528437.

      $ svn up
      Updated to revision 528437.

      $ mvn -Dtest=false clean install
      ...
      [INFO] ------------------------------------------------------------------------
      [INFO] ------------------------------------------------------------------------
      [INFO] BUILD SUCCESSFUL
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 2 minutes 12 seconds
      [INFO] Finished at: Fri Apr 13 13:00:04 CEST 2007
      [INFO] Final Memory: 35M/254M
      [INFO] ------------------------------------------------------------------------

      $ mvn -Dtest=OpenJPATest clean test
      ...
      0 derbyPU INFO [main] openjpa.Runtime - Starting OpenJPA 0.9.8-incubating-SNAPSHOT
      ...
      [INFO] ------------------------------------------------------------------------
      [ERROR] BUILD FAILURE
      [INFO] ------------------------------------------------------------------------
      [INFO] There are test failures.
      [INFO] ------------------------------------------------------------------------
      [INFO] For more information, run Maven with the -e switch
      [INFO] ------------------------------------------------------------------------
      [INFO] Total time: 33 seconds
      [INFO] Finished at: Fri Apr 13 13:02:11 CEST 2007
      [INFO] Final Memory: 11M/254M
      [INFO] ------------------------------------------------------------------------

      $ cat target/surefire-reports/pl.jaceklaskowski.jpa.issue.OpenJPATest.txt
      -------------------------------------------------------------------------------
      Test set: pl.jaceklaskowski.jpa.issue.OpenJPATest
      -------------------------------------------------------------------------------
      Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.437 sec <<< FAILURE!
      testUpdate(pl.jaceklaskowski.jpa.issue.OpenJPATest) Time elapsed: 0.063 sec <<< FAILURE!
      <0.9.8-incubating-SNAPSHOT nonfatal user error> org.apache.openjpa.persistence.ArgumentException: An error occurred while parsing the query filter 'UPDATE Osoba SET imie = 'JACEK'
      WHERE imie = 'Jacek''. Error message: <0.9.8-incubating-SNAPSHOT nonfatal user error> org.apache.openjpa.kernel.jpql.ParseException: Encountered "=" at character 23, but expected:
      ["."].
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.parse(JPQLExpressionBuilder.java:1656)
      at org.apache.openjpa.kernel.jpql.JPQLExpressionBuilder$ParsedJPQL.<init>(JPQLExpressionBuilder.java:1636)
      at org.apache.openjpa.kernel.jpql.JPQLParser.parse(JPQLParser.java:44)
      at org.apache.openjpa.kernel.ExpressionStoreQuery.newCompilation(ExpressionStoreQuery.java:141)
      at org.apache.openjpa.kernel.QueryImpl.newCompilation(QueryImpl.java:645)
      at org.apache.openjpa.kernel.QueryImpl.compilationFromCache(QueryImpl.java:613)
      at org.apache.openjpa.kernel.QueryImpl.compileForCompilation(QueryImpl.java:593)
      at org.apache.openjpa.kernel.QueryImpl.compileForExecutor(QueryImpl.java:655)
      at org.apache.openjpa.kernel.QueryImpl.getOperation(QueryImpl.java:1480)
      at org.apache.openjpa.kernel.DelegatingQuery.getOperation(DelegatingQuery.java:120)
      at org.apache.openjpa.persistence.QueryImpl.executeUpdate(QueryImpl.java:297)
      at pl.jaceklaskowski.jpa.issue.OpenJPATest.testUpdate(OpenJPATest.java:23)

      $ cat src/test/java/pl/jaceklaskowski/jpa/issue/OpenJPATest.java
      package pl.jaceklaskowski.jpa.issue;

      import javax.persistence.Query;

      import org.testng.annotations.Test;

      import pl.jaceklaskowski.jpa.BaseTest;

      public class OpenJPATest extends BaseTest {

      @Test(dependsOnMethods =

      { "utworzPracownikow" }

      )
      public void testUpdate() {
      Query query;

      em.getTransaction().begin();
      try

      { String identificationVariableUpdateQL = "UPDATE Osoba o SET o.imie = 'JACEK' WHERE o.imie = 'Jacek'"; query = em.createQuery(identificationVariableUpdateQL); assert query.executeUpdate() == 1; String noIdentificationVariableUpdateQL = "UPDATE Osoba SET imie = 'JACEK' WHERE imie = 'Jacek'"; query = em.createQuery(noIdentificationVariableUpdateQL); assert query.executeUpdate() == 1; }

      finally

      { em.getTransaction().rollback(); }

      }
      }

      Attachments

        Activity

          People

            Unassigned Unassigned
            jlaskowski Jacek Laskowski
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated: