| Author |
How many entity beans to create for more than one table?
|
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
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
|
BJ - SCJP and SCWCD
We love Java programming. It is contagious, very cool, and lot of fun. - Peter Coad, Java Design
Crazy Bikes created by m-Power
|
 |
James Carman
Ranch Hand
Joined: Feb 20, 2001
Posts: 580
|
|
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.
|
James Carman, President<br />Carman Consulting, Inc.
|
 |
Byron Estes
Ranch Hand
Joined: Feb 21, 2002
Posts: 313
|
|
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,
|
Byron Estes<br />Sun Certified Enterprise Architect<br />Senior Consulant<br />Blackwell Consulting Services<br />Chicago, IL<br /><a href="http://www.bcsinc.com" target="_blank" rel="nofollow">www.bcsinc.com</a>
|
 |
Bruce Jin
Ranch Hand
Joined: Sep 20, 2001
Posts: 666
|
|
Thanks! I just got Core J2EE Patterns and I will go through it.
|
 |
Byron Estes
Ranch Hand
Joined: Feb 21, 2002
Posts: 313
|
|
You're welcome. After you read it, if you still have questions or want to discuss it, feel free to email me directly. Best,
|
 |
 |
|
|
subject: How many entity beans to create for more than one table?
|
|
|