I’m working on a JSF project.Our development based on MySql 5.1, JBoss 4.22GA and i got some trouble today and hope someone can help me to figure it out.
Here‘s the situation:for some reasons i have to do some update to a table and then see if we can find these changes out.To do so, i call the method something like below.
create table `table` (
id int,
update_date datetime,
);
// consider this method as one transaction
somemethod() {
A. select max(update_date) from table where id = 1;
B. update table set update_date = now() where id = 1;
C. select max(update_date) from table where id = 1;
}
Note that :
1.we break after A (you know using break point in eclipse)
2.we execute B from somewhere outside application (which means execute update in something like GUI DB manager)
3.after B we proceed to execute C (same we did as A)
and we got same result as we did at A. But we can confirm that change in the GUI DB manager. Dose any one can tell me why did this happen? I’ll be very appreciate for any helping. Thank you! (And thus my bad english i hope i’ve already made myself clear enough.)
The default transaction isolation level in MySQL is REPEATABLE READ, this is what the manual tells about it
In short that means if you read something during a transaction, all following reads of the same data in the same transaction will return the same result, which is exactly what you’re seeing.