I would like to do some update operation, say updating a column of all (or subset) or rows of the table. There are 2 approaches
1. Retreieve all the data objects, update the state of the data objects one by one, and the save
2. Use a single SQL statement to do the update
For approach 1, it would be having too much overhead. So certainly I prefer approach 2.
However, I have some question and not sure whether Hibernate supports it.
a. Can the "named query" be those update statement?
b. if not, can I (or by what mean) use Hibernate to do these kinds of update?
c. if I cannnot use Hibernate to do that, I can do the update through JDBC. However I would like to ask, after I do the update, would the cache in the Hibernate know about that? (say the update statement would update attributes of some data objects in the cache, would there be inconsistences?)
d. There is an update class in the Java API. Could anyone points me to some documentation or resources where I can find its detail usage?
Maybe someone has asked similar questions or there are documentation about these issues. If this is the case, could anyone point me to the related information? Many Thank!
|