• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How many entity beans to create for more than one table?

 
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
When I need to pull data from several tables with joins, I use one sql query string with join clauses. Can I create a single entity bean to present this “joined table”?
Thanks
 
Ranch Hand
Posts: 580
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Bruce Jin:
When I need to pull data from several tables with joins, I use one sql query string with join clauses. Can I create a single entity bean to present this “joined table”?
Thanks


It depends on your Object-to-Relational mapping implementation (or you, yourself if you're using BMP). Most implementations map one entity bean to a single table, though.
 
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may want to take a look at "Core J2EE Patterns". It does a nice job discussing things like this at a high level and even provides a section on design considerations and bad practices. On the the practices the book says should be avoided is "Mapping Relational Model Directly to Entity Bean Model". EJB was intended to be for course-grained objects. Created entity beans at the table level produces (in general) a very fine grained approach. Modeling a entity bean for a row in a single table can result in scalabilty problems if your processing results in the retrieval/manipulation of a large result set where each row is an entity bean.
Regards,
 
Bruce Jin
Ranch Hand
Posts: 672
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks!
I just got Core J2EE Patterns and I will go through it.
 
Byron Estes
Ranch Hand
Posts: 313
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome. After you read it, if you still have questions or want to discuss it, feel free to email me directly.
Best,
 
I am Arthur, King of the Britons. And this is a tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic