Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » J2EE Interest »

Re: How many instance of Entity Bean

Steven Warren

2003-07-02

Replies:

Message
Ok, and sorry for being snapish...
 
You wrote:
 
"If you define it as re-entrant then more than one client can execute operations on it at the same time and transaction, or if defined as non-reentrant then if a client makes a call on the bean, while its in a transaction, the bean will throw an exception."
 
This only holds within a single transaction (period). Now, if you are defining "more then one client" to mean "more then one client using the same transaction", then what you wrote still holds true (that's not how I define "more then one client"). To me, more then one client infers more then one transaction.
 
Now, all that said,
If you're within a single transaction and you reference an entity bean instance. Then throughout that transaction you are guaranteed to always reference the identical instance everytime you ask/receive it. Re-entrancy has nothing to do with that behaviour. By definition you will ALWAYS have 1 bean instance for each db record no matter what your descriptors say.
 
If you have multiple transactions on the fly at the same time, regardless of you re-entrancy deployment definition, a given entity bean instance will only participate in one of the transactions. The other transactions will either 1) wait, or 2) get a different entity bean instance. Again, this has nothing to do with the re-entrancy definition and you will never get an exception in these cases. It is influenced only by the containers selection of commit option A, B, or C.
 
Conclusion: Re-entrancy has nothing to do with "How many instance of Entity Bean" there are.
 
In answer to Sameer's question:
"If 3 seperate clients had to fire a findbyprimarykey(PK) on the same Entity
Bean, then how many instances of Beans are created on the same primary Key.
And how does the Transaction Manager do the Transaction Mgmt on the same."
 
The answer is (I believe, pls I am not on the expert group or anything), "It depends on the containers commit policy (A, B, or C)". In all cases, your application will transact correctly, but depending on the commit option of the container, the container may have 1 or more instances.
 
Cheers
Steve
 
 
-----Original Message-----
From: A mailing list for Java(tm) 2 Platform, Enterprise Edition [mailto:J2EE-INTEREST@JAVA.SUN.COM] On Behalf Of Dimitar Stavrakov
Sent: Wednesday, July 02, 2003 12:15 PM
To: J2EE-INTEREST@JAVA.SUN.COM
Subject: Re: How many instance of Entity Bean

Could you point out why its not true Steven? I don't quite see your point.
 
Thanks,
 
    Dimitar
-----Original Message-----
From: Steven Warren [mailto:steve@MYVEST.COM]
Sent: сряда 02.7.2003 г. 13:44
To: J2EE-INTEREST@JAVA.SUN.COM
Cc:
Subject: Re: How many instance of Entity Bean

Uh, I did dude.
 
You wrote:
"If you define it as re-entrant then more than one client can execute operations on it at the same time and transaction"
 
This isn't true.
 
Cheers
Steve
-----Original Message-----
From: A mailing list for Java(tm) 2 Platform, Enterprise Edition [mailto:J2EE-INTEREST@JAVA.SUN.COM] On Behalf Of Dimitar Stavrakov
Sent: Wednesday, July 02, 2003 11:39 AM
To: J2EE-INTEREST@JAVA.SUN.COM
Subject: Re: How many instance of Entity Bean

Precisely my point Steven. Maybe you should take the time to read the posting before you start replying to it. As for the multiple transactions(clients) I would point you to the specification documents ch. 10.5.11.
 
Cheers,
 
     Dimitar
-----Original Message-----
From: Steven Warren [mailto:steve@MYVEST.COM]
Sent: сряда 02.7.2003 г. 11:11
To: J2EE-INTEREST@JAVA.SUN.COM
Cc:
Subject: Re: How many instance of Entity Bean

Dimitar, re-entry really doesn't have anything to do with the number of bean instances. The re-entrant attribute controls whether a given instance can be called recursively within a transaction. For example:
 
ABean invokes BBean invokes CBean invokes ABean(different method)
 
This is independent of how many bean instances a container will use. As already written, the number of instances is up to the container and which commit option they support/implement (commit option A, B or C). Option A basically guarantees at most a single bean instance per database record. Options B and C allow for (but don't require) multiple bean instances for a given database record to allow for concurrent updating of data.
 
IMO Commit Option A is useless...
 
There is no option (as far as I know) to allow multiple transactions (clients) to access the same bean instance at the same time.
 
Regards
Steve
-----Original Message-----
From: A mailing list for Java(tm) 2 Platform, Enterprise Edition [mailto:J2EE-INTEREST@JAVA.SUN.COM] On Behalf Of Dimitar Stavrakov
Sent: Wednesday, July 02, 2003 5:12 AM
To: J2EE-INTEREST@JAVA.SUN.COM
Subject: Re: How many instance of Entity Bean

It should be up to the container provider to decide how many instances of the bean to create. The transaction management would differ depending on how you define your entity bean in the deployment descriptor. If you define it as re-entrant then more than one client can execute operations on it at the same time and transaction, or if defined as non-reentrant then if a client makes a call on the bean, while its in a transaction, the bean will throw an exception.
 
Regards,
 
    Dimitar
 
-----Original Message-----
From: Sameer Sadanand Menon [mailto:SameerS@VIRTUSA.COM]
Sent: сряда 02.7.2003 г. 06:37
To: J2EE-INTEREST@JAVA.SUN.COM
Cc:
Subject: How many instance of Entity Bean

Hey guys,
One thing has been intriguing me for a long time.
If 3 seperate clients had to fire a findbyprimarykey(PK) on the same Entity
Bean, then how many instances of Beans are created on the same primary Key.
And how does the Transaction Manager do the Transaction Mgmt on the same.

Thanking you.

Regards,

Sameer S Menon
Virtusa Corp
 <mailto:sameers@virtusa.com> sameers@virtusa.com

===========================================================================
To unsubscribe, send email to listserv@java.sun.com and include in the body
of the message "signoff J2EE-INTEREST".  For general help, send email to
listserv@java.sun.com and include in the body of the message "help".

©2008 junlu.com - Jax Systems, LLC, U.S.A.