Re: Locking entire table

Armin Waibel <[email protected]> Fri, 25 Jan 2008 03:04:00 +0100
Newsgroups gmane.comp.jakarta.ojb.user
Message-ID <[email protected]>
Hi JohnE,

johne wrote:
> I am using the OJB 1.0.3 PB with MySql 5.0.
> 
> I have a series of processes that work off of a common table.  This common
> table is refreshed regularly.  During this refresh, I would like to do to
> the affect of:
>                 1. Begin a transaction.
>                 2. Lock the entire table.
>                 3. Delete entire table.
>                 4. Unlock entire table.
>                 5. End transaction.
> 
> While a single process on a single server does this, it would be great if
> the other read only processes seeking to use it were to fail fast with
> exception.
> 
> Can anybody give me an example on how to do this?
> 
> So far I have to the affect of:
>                Query query = new QueryByCriteria(objectClass, null);
>                broker.beginTransaction();
>                broker.deleteByQuery(query);
>                broker.commitTransaction();
> 
> I am not sure how to do the fail fast table level locking.   

I'm not sure that I get your point. Doesn't this depend on the database 
isolation level? Or do you want to lock a database table by hand before 
deleting all rows?

regards,
Armin

> I feel I am
> missing other things as well.  I can use some help filling in the gaps.  If
> you have a better idea on how to implement, I am open.  I was thinking I
> could just put a locking record in another table, but thought this might be
> better.
> 
> Thanks for any help.
> 
> JohnE
>