This week's book giveaway is in the Agile and Other Processes forum.
We're giving away four copies of The Little Book of Impediments (e-book only) and have Tom Perry on-line!
See this thread for details.
Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PetStore: About UniqueIdGeneratorEJB

 
Renaud FLORQUIN
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Another question about PetStore 1.4

The PetStore uses one SessionBean (com.sun.j2ee.blueprints.uidgen.ejb.UniqueIdGeneratorEJB) and one EntityBean (com.sun.j2ee.blueprints.uidgen.counter.ejb.CounterEJB) to obtain a unique id.
Although it seems "overkill" to use this approach, this design requires to use a 'read commited' lock as transaction isolation level to avoid conflicts in case of roolback. If those counter table is used by several components, this design can be a bottleneck!
Most of the modern DBs have a "SEQUENCE" concept to implement counter, it should be easier to use a DAO object to implement this service or to use the HIGH-LOW strategy explained by Scott Ambler to obtain an OID.
Is it right ?

Renaud
 
Tomi Tuomainen
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Transaction level read-committed is the second fastest (after read-uncommitted) so I'm not sure if that'll be the problem. Using database sequences just by a single query (for example "select seq.nextval from dual") is fast and easy way to create unique keys, but I'm not sure if all the databases have this feature. Using a separate entity bean should be more database-independent way.
 
Renaud FLORQUIN
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Tomi for your answer.
I agree with you; it is a balance between portability and performance and the performance depends on the context (# of concurrent users, transaction duration, ...).
FYI there is an article about ID generator using session bean at theServerSide.com site (http://www.theserverside.com//patterns/thread.tss?thread_id=4228).

Renaud
 
Tomi Tuomainen
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Renauld,

Thanks for the article. Interesting that the solution uses singletone-pattern but also states that JVM's can be destroyed dynamically by some servers. I wonder if we should stress about unique relational database keys in SCEA assignment or can we leave the problem to designers...
 
Renaud FLORQUIN
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The border between architecture and design can depend on the context (knowledge, size, ... of the team). For example the detail of an architecture will differ if we have a 3-people team with limited knowledge or if the architecture is related to a large development with senior developpers.
In the context of a certification, we can't evaluate this context and we have to make assumptions.
For me an architecture should cover the global organization of an application (static/dynamic/deployment) but also give "common mechanisms" used for the development. The choice of Unique ID generation strategy can be a common mechanism.

Renaud
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic