max wrote:
read up about bulk updates and you can use HQL to do it with.
Sorry. I made a typo. I didn't mean Bulk update, I meant a mass update. It has nothing to do with Bulk updates.
I see much in HQL about updating one record or even in updating mutiple records but nothing about updating a field in one table with the contents of another table.
I want to update a field in all the records of table A with a field in table B when certain criteria is present in both tables.
Basically my statement would be:
Update tableA set tableAField = (select tableBField from TableB where TableACritiera = TableBCriteria).
I have looked at the documentation on-line and through the book Hibernate in Action. I have tried using named queries, and rewriting the update statement so that it is a more of a join and nothing seems to work.
Note though that I used createQuery.executeUpdate(). I tried using createSQLQuery.executeUpdate() but when I did, I got an error message that said that I had to use HQL update.
If I am overlooking the relevant documentation (and I probably am), if someone would guide me to the appropriate links, that would help as well.
Or are you saying that I need to use Hibernate 3.2? That Hibernate 3.1 doesn't support it but 3.2 does?
Thanks.