Almost right on, but not exactly.

What I was getting to is using BMP to do this.  CMP doesn't really provide
an easy way to synchronize access to a single row in a table, which BMP can
do for you.

This is why BMP is still viable.  Problems like this are outside the range
of common CMP implementations.  With BMP you can take complete control of
the read and update process, and use that to solve your parallel access
problem.

And, as a final thought, if you are concerned about mapping to the database
dynamically from within the server, just set up the database, table, and
column information as JNDI environment variables.  That would give you
flexibility in deployment for a BMP system.


Jonathan Baker
Internet Applications Division
Sybase, Inc.



Suresh Ajja wrote:
>
> Thank you, Jonathan,
>
> I did "reqiures new" for ejbLoad(),
> and wrote
> this.value = value+1;
> inside ejbLoad(), [which was in getValue() earlier.]
> I think that is what u meant, but even by this i get same value, clint
> accessing at same time.
> Suresh
>
> ----- Original Message -----
> From: "Jonathan Baker" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Wednesday, November 29, 2000 2:10 PM
> Subject: Re: unique int value generation thru' CMP entity Bean
>
> > 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".
> >
>
> ===========================================================================
> 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".

Reply via email to