wood burning stoves 2.0
The moose likes EJB and other Java EE Technologies and the fly likes Marinescu Primary Key Generation Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Marinescu Primary Key Generation" Watch "Marinescu Primary Key Generation" New topic

Marinescu Primary Key Generation

Safin Ahmed

Joined: Feb 08, 2006
Posts: 19
i'm using Marinescus Primary Key Generation schema, but i'm having a problem
As i see it in EJB Design Patterns (Marinescus Book), he uses a Hashtable to store the values so that the Bean doesn't have to access the database everytime

My problem is that this Hashtable is not working, because each client when access the Bean, this creates a new bean (just like in the pattern) and thus there is never info on the Hashtable, thus the application has to go to the Database.

If i put the Hashtable as static, i will have Concurrency Problems

But my real problem is that i've seen various implementations of this pattern, and no one seems to talk about this problem
Am i missing something ?

I've thought maybe Marinescus uses only one static SessionBean (resolving the problem), but he create one Bean for each request also

Safin Ahmed

Joined: Feb 08, 2006
Posts: 19
So, i found the problem
I had the SessionBean configured as a Stateful Session Bean
But if i change it to Stateless it starts working
I still didn't figured out why (as no Load, Store, Passivation or Activation code exists to keep or get the Hashtable)

So if any one could explain it to me, it would be nice

Reid M. Pinchback
Ranch Hand

Joined: Jan 25, 2002
Posts: 775
Not familiar with his approach, although I'm always suprised to see "EJB" and "Hashtable" in the same sentence, particularly if it came from an author writing about EJB. Its not like the EJB spec is vague about its prohibitions.

Reid - SCJP2 (April 2002)
I agree. Here's the link: http://aspose.com/file-tools
subject: Marinescu Primary Key Generation
It's not a secret anymore!