openjpa-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandeep Shrivastava (JIRA)" <>
Subject [jira] Updated: (OPENJPA-597) JPQL delete query with an alias for tablename and without any further clauses gives an error on MySQL
Date Fri, 09 May 2008 03:10:56 GMT


Sandeep Shrivastava updated OPENJPA-597:

    Attachment: OPENJPA-597.patch

Patch to optionally include either the table names or the aliass as the delete targets in
the DELETE sql that is generated based on the requiresTargetForDelete that defaults to false
and set to true in the mysql dictionary.

> JPQL delete query with an alias for tablename and without any further clauses gives an
error on MySQL
> -----------------------------------------------------------------------------------------------------
>                 Key: OPENJPA-597
>                 URL:
>             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
> Windows XP
> os.version: 5.1
> os.arch: x86
> java.version: 1.6.0_05
> java.vendor: BEA Systems, Inc.
>            Reporter: Sandeep Shrivastava
>         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(
> [testlogic] 	at org.apache.openjpa.persistence.PersistenceException.writeObject(
> 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.

View raw message