• Post Reply Bookmark Topic Watch Topic
  • New Topic

Difference between fine-grained and coarse-grained  RSS feed

 
srinivas k
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
what is a fine-grained bean and a coarse-grained bean,what is the difference between them
Thanks in advance
 
Paul Lester
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fine-grained and coarse-grained refer to Entity Beans.
As an entity bean usually represents one row in a given table, a fine grained bean would have one getter/setter per column that could be changed. A coarse-grained entity bean would have one or more getter/setter methods that would each take a value object that would represent the entire row.
The advantage in this, before local beans and CMP, was that it cut down on the number of calls to ejbLoad and ejbStore.
Each time that you call setXXX the bean is changed and then saved to the database and then ejbLoad is called. This keeps all of the entity beans in synch. So, if you had 20 set methods you'd have 20 calls to ejbStore and 20 calls to ejbLoad. Using a coarse-grained object would reduce that to one call to ejbStore and one to ejbLoad.
With the advent of CMP the bean can make certain optimizations to make this less of a problem.
Regards,
Paul
[ May 20, 2003: Message edited by: Paul Lester ]
 
Matthew Phillips
Ranch Hand
Posts: 2676
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
srinivas k,
We don't have many rules at Javaranch, but our display name policy is one of them. Please read this policy and change your display name to comply with it if you wish to continue posting. Thanks.
You can change your display name here.
 
Chris Mathews
Ranch Hand
Posts: 2712
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this thread from a few months ago.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!