|
This also shows as failed tests in BulkManipulationTest when run on MySQL. I'm guessing that this may not work in oracle, at least with the current version of Oracle9Dialect and OracleDialect So I have what I believe to be appropriate changes to have this work on MySQL and still work on others. However, I do still get 2 failures that I cannot explain. For example: causes: I think it is trying to complain that you cannot do a delete from a table and restrict the deletions based on a select from that same table? Anyone know if this is valid on MySQL? Or is this something else? ORIGINAL DESCRIPTION: I've created the following test (in JoinedSubclassTest) which reporduced the problem: public void testBulkUpdateJoinedSubclass() { Session s = openSession(); Transaction t = s.beginTransaction(); Employee mark = new Employee(); mark.setName("Mark"); mark.setTitle("internal sales"); mark.setSex('M'); mark.setAddress("buckhead"); mark.setZip("30305"); mark.setCountry("USA"); s.save(mark); String hql = "update Employee employee set employee.sex=:newSex where employee.id in (:ids)"; Query query = s.createQuery(hql); query.setCharacter("newSex", 'F'); List ids = new ArrayList(); ids.add(Long.valueOf(mark.getId())); query.setParameterList("ids", ids); query.executeUpdate(); s.delete(mark); t.commit(); s.close(); } and run it with the following properties: This produces the following error: org.hibernate.exception.SQLGrammarException: could not insert/select ids for bulk update This works fine in hibernate 3.1.3. The problem seems to be in AbstractStatementExecutor. It seems to assume that if a DDL statement, in general, results in a commit that this will also happen for a temporary table. In the case of MySQL, at least, this is not the case. The code in AbstractStatementExecutor goes and creates the temporary table in a new connection, which, in the case of MySQL, will Steve, these 2 failures are MySQL "features". Section "DELETE syntax" in their manual says: "Currently, you cannot delete from a table and select from the same table in a subquery." The similar restriction applies to UPDATE with subquery syntax: "Incorrectly used table in subquery: Error 1093 (ER_UPDATE_TABLE_USED) This error occurs in cases such as the following: UPDATE t1 SET column2 = (SELECT MAX(column1) FROM t1); You can use a subquery for assignment within an UPDATE statement because subqueries are legal in UPDATE and DELETE statements as well as in SELECT statements. However, you cannot use the same table (in this case, table t1) for both the subquery's FROM clause and the update target." My local MySQL5 install shows these changes as fixing the problem. Please try from SVN and verify |
|||||||||||||||||||||||||||||||||||||||||||||||||
This issue came up on the hibernate forum too:
http://forum.hibernate.org/viewtopic.php?t=965949