• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Marinescu Primary Key Generation

 
Safin Ahmed
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Thanks
 
Safin Ahmed
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

Thanks
 
Reid M. Pinchback
Ranch Hand
Posts: 775
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic