Hello!

> In CMP ejbLoad() is called just after the container loads the
> data, and
> ejbStore is called just before the container will save the data.
> IMHO it is possible to do some JDBC-update here, but I am not
> sure if this
> is good practice.

Sounds good, but to be really sure: My scenario (not implemented yet, but in
my head) is, that I've several clients who work against a growing queue.
This queue is data on table, let's call it "QUEUE".  The nature of a queue
is, that only one client will get some entries, and the next client will get
(by using the same finder-method) other entries in this queue.

So I would have QueueCMPEntityBean with
ejbLoad()

        Statement statement=getConnection().prepareStatement("SELECT FOR UPDATE id
FROM QUEUE WHERE id=?")
        statement.setInteger(1,id);
        statement.execute(); //set the lock on this entity
}

ejbStore() {
        // how to release the lock here?
}

This will cause the entry to be locked, so that when another client calls
the same finder (even in worst-case only 1 cpu cycle later) will NOT get the
QueueCMPEntityBean that was returned right now, but another one (the next
one).

A call to such a finder could be:
findByIdRange(1000,1300); this returns NOT 300 entities, but only 200, since
another client could have called findByIdRange(900,1100); before

Question: Does this scenario work? How to implement ejbStore() ?


thank you very much,
Heiko

===========================================================================
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