aspose file tools
The moose likes EJB and other Java EE Technologies and the fly likes How many entity beans to create for more than  one table? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Reply Bookmark "How many entity beans to create for more than  one table?" Watch "How many entity beans to create for more than  one table?" New topic
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,
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: How many entity beans to create for more than one table?
 
Similar Threads
Can some one help me with Entity Beans
entity classes in UML
Can I map single table to different Entity Bean?
forgein keys
hibernate mapping issue