Suresh:
I think this will work for you:
Try setting up the Entity bean so that the ejbLoad() method first runs an
update statement to increment the counter by one, and then select the value
into the entity bean (and the EJBStore method should do nothing). Then set
the transaction attribute for this bean to 'requires new'.
Now, when the entity is activated it will call ejbLoad() from a new
transaction. The update will get an exclusive lock on the database table,
which means no one else can update or read the data at the same time. Then,
the select statement will read the value. Once the method call to get the
value returns, the transaction will be completed and the database locks
released.
That should get you a unique value for every call, even if you have multiple
containers.
Jonathan Baker
Internet Applications Division
Sybase, Inc.
Suresh Ajja wrote:
>
> I m having a counter Ejb entity, CMP which has one field "value"- int.
> I have a getValue() remote method which increments the value=value+1, and
> returns it.
> I am callingthe ejb thru' servlet, and i call the getValue(), but when I am
> running, two clients at the SAME TIME, it gives me same count, which i don't
> want.
> How can i get unique values.
> need help........somebody pls..........
>
> ===========================================================================
> 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".
===========================================================================
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".