Domanda

Say I execute a query such as the following:

select a.some_column                           
from table_a a                                              
join table_b b
on b.id = a.b_id                     
left join table_c c 
on c.id = a.c_id

In which order will h2 lock the tables?

È stato utile?

Soluzione

For a join, there is no reliable way to tell or ensure in what order tables are locked. If you need an explicit order, then you would need to execute multiple statements, for example

select * from table_a where ... for update;
select * from table_b where ... for update;
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top