You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@openjpa.apache.org by "Patrick Linskey (JIRA)" <ji...@apache.org> on 2008/05/16 22:55:55 UTC

[jira] Resolved: (OPENJPA-597) JPQL delete query with an alias for tablename and without any further clauses gives an error on MySQL

     [ https://issues.apache.org/jira/browse/OPENJPA-597?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Patrick Linskey resolved OPENJPA-597.
-------------------------------------

       Resolution: Fixed
    Fix Version/s: 1.1.0

> JPQL delete query with an alias for tablename and without any further clauses gives an error on MySQL
> -----------------------------------------------------------------------------------------------------
>
>                 Key: OPENJPA-597
>                 URL: https://issues.apache.org/jira/browse/OPENJPA-597
>             Project: OpenJPA
>          Issue Type: Bug
>          Components: jdbc
>    Affects Versions: 1.1.0
>         Environment: OpenJPA 1.1.0-SNAPSHOT
> version id: openjpa-1.1.0-SNAPSHOT-r422266:653008
> Apache svn revision: 422266:653008
> os.name: Windows XP
> os.version: 5.1
> os.arch: x86
> java.version: 1.6.0_05
> java.vendor: BEA Systems, Inc.
>            Reporter: Sandeep Shrivastava
>             Fix For: 1.1.0
>
>         Attachments: OPENJPA-597.patch
>
>   Original Estimate: 24h
>  Remaining Estimate: 24h
>
> If we have a JPQL query like this:
> int countDeleted = em.createQuery('Delete from Person o').executeUpdate();
> We get an exception on MySQL because the converted SQL with an alias gives a syntax error :
> [testlogic] java.lang.Exception: org.apache.openjpa.lib.jdbc.ReportingSQLException: 
> You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version 
> for the right syntax to use near '' at line 1 {prepstmnt 2137108 DELETE FROM DYN_DESC_PERSON t0 [reused=0]} [code=1064, state=42000]
> [testlogic] 	at org.apache.openjpa.util.Exceptions.replaceNestedThrowables(Exceptions.java:242)
> [testlogic] 	at org.apache.openjpa.persistence.PersistenceException.writeObject(PersistenceException.java:100)
> For mySQL version 5.0 the MySQLDBDictionary defaults for supportsSubselect and allowsAliasInBulkClause are both true. For these params the DBDictionary.toBulkOperation() generates a sql like DELETE FROM DYN_DESC_PERSON t0 which does not work in mySQL. 
> The syntax for DELETE statements that use table aliases changed between MySQL 4.0 and 4.1. In MySQL 4.0, you should use the true table name to refer to any table from which rows should be deleted: 
> DELETE test FROM test AS t1, test2 WHERE ...
> In MySQL 4.1, if you declare an alias for a table, you must use the alias when referring to the table: 
> DELETE t1 FROM test AS t1, test2 WHERE ...

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.