Hello!
The following code fragment works for MySQL, but does not for SAP-DB:
Code:
getExtHibernateTemplate().bulkUpdate("UPDATE AbstractOrder SET recent = false WHERE mainOrderId = :mainOrderId OR id = :mainOrderId", new String[]{"recent"}, new Object[]{false, order.getMainOrderId()});
The query Hibernate generates is:
Code:
update abstract_order set recent=0 where (id) IN (select id from temp.HT_abstract_order)
The MaxDB error is "Constant must be compatible with column type and length". The following query works (I tried it on the sqlcli console):
Code:
update abstract_order set recent=false where (id) IN (select id from temp.HT_abstract_order)
A workaround that works both with MySQL and MaxDB:
Code:
getExtHibernateTemplate().bulkUpdate("UPDATE AbstractOrder SET recent = :recent WHERE mainOrderId = :mainOrderId OR id = :mainOrderId", new String[]{"recent", "mainOrderId"}, new Object[]{false, order.getMainOrderId()});
This generates the following code:
Code:
update abstract_order set recent=? where (id) IN (select id from temp.HT_abstract_order)
Is there something I can do about this issue? (Passing a constant as a variable parameter doesn't seam too clever.) Can I change the way Hibernate converts the UPDATE HQL query to a SQL query? Is this a bug I should file in the JIRA?
Thanks for any help,
Matthias