Richard,

The INSERT will acquire a (table) lock depending on the transaction
isolation level you specify for the datasource used by your EJBs.

So, the possible solutions are:
(a) Lower the isolation level (if your application can get away with
    it), Or
(b) Specify that the ejbCreate() needs to run in its own transaction
    (RequiresNew). Therefore, locks will be now be held for a smaller
    duration of time. But you are now breaking up your long running
    transaction into smaller ones; and this might not be acceptable.
(c) Explore the use of lock timeouts (can be set as properties in
    some JDBC drivers).
(d) Explore the use of CMP - here the Container has a lot more control
    over when SQLs are sent to the database and might be option iff
    your EJB Container has the ability to defer writes (INSERTs, etc)
    to the database.

-krish

> -----Original Message-----
> From: A mailing list for Java(tm) 2 Platform, Enterprise Edition
> [mailto:[EMAIL PROTECTED]]On Behalf Of Richard S.Martin
> Sent: Wednesday, July 17, 2002 6:14 PM
> To: [EMAIL PROTECTED]
> Subject: Entity creation locking problem
>
>
> Problem:
>
> 1. The uniqueness of the entity beans is based upon an unique constraint on
> the primary key field in the underyling database.
>
> 2. The ejbCreate method on the BMP entity bean, due to various essential
> business processes, takes a long time to write the data to the table. (in the
> region of 5-10 secs.)
>
> 3.  As soon as the INSERT statement occurs, the transaction acquires a
> table-lock to ensure the uniquness of the primary key.
>
> 4. The lock is only released when the transaction commits or rollsback.
>
> 5. The consequence of this is that every ejbCreate causes the table to be
> exclusively locked for about 5 seconds, meaning we can handle only a single
> ejbCreate at any time!
>
> How can this problem be resolved?
>
>
>
> ==============================================================================
> This email and any files transmitted with it are confidential and intended solely 
>for the use of the individual or entity
> to whom they are addressed. All information is the view of the individual and not 
>necessarily the company. If you are not
> the intended recipient you are hereby notified that any dissemination, distribution, 
>or copying of this communication and
> its attachments is strictly prohibited. If you have received this email in error 
>please notify:
> [EMAIL PROTECTED]
>
>
> ==============================================================================
>
> ===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
> of the message "signoff J2EE-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
>
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff EJB-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to