Subject Re: [firebird-support] Hibernate, alter table and single user
Author Helen Borrie
At 09:30 PM 1/03/2005 +0000, you wrote:


>On the Hibernate site, they list as a known issue:
>
>"If you are altering tables you should be in single user mode. This
>can be achieved by running gfix -shut. It's also sufficient to have
>only one database connection open (eg. immediately after starting the
>application). If more than one connection is open, you will see
>errors like "table is in use". To restart your database use gfix -
>online."
>
>I looked at 'gfix -shut' and I think what they are saying is that you
>can shut down your database to see if there are other users using it?

No, you can "shut down" a database in the sense that you take the database
off-line, preventing all users except sysdba or the database owner from
connecting. To understand how it works, you should read Ch. 39 of The
Firebird Book (if you have it); otherwise Google for OpGuide.pdf, download
it, and look up the details of gfix -shut. If you try to guess this one,
or to go by FAQ notes attached to some third party tool, you're fairly
unlikely to get it to work.


>But to address the problem itself, what does "you should be in single
>user mode" mean?

It means the database is shut down (off-line) and you are logged in as
either sysdba or database owner, i.e. you have "exclusive access".

>The paragraph above makes sense if only the admin
>is altering tables on rare occasions, but I originally started
>looking into this because the Hibernate *example code* makes 'alter
>table' calls and it's failing.
>
>And if do use Firebird in single user mode with Hibernate, does that
>make Hibernate less useful in any way?

For a multi-user system, yes, it will make it useless. One and only one
client could log in, and that client would have to be sysdba or owner.

Note the following:

1) You can alter database objects without having exclusive access, but you
will get "object in use" if any transaction is currently using the object.
You can keep trying if you want to.

2) You can not add or drop foreign key constraints UNLESS you have both
exclusive access AND no other transaction running.

I should probably write a How-to for getting exclusive access...

And you should probably start your Firebird career with the employee
database. From a design POV, it is disgusting; but at least it has data
in it and you can use it to get your head around transaction concurrency...

./heLen