File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes EJB and other Java EE Technologies and the fly likes Entity Bean Best Practice Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Entity Bean Best Practice" Watch "Entity Bean Best Practice" New topic
Author

Entity Bean Best Practice

Kelly Walker
Greenhorn

Joined: Sep 09, 2003
Posts: 24
I have read that direct replication of the relational model with entity beans is bad practice. Good practice is to reduce inter entity bean communication and to create coarse grained entity beans.
I am using EJB2.x specification - CMP and CMR to model my business data. It seems a natural thing to simply replicate the existing relational model with entity beans. Why is this such bad practice.
How should I go about this in practice??
Thank you.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Kelly Walker II:
I have read that direct replication of the relational model with entity beans is bad practice. Good practice is to reduce inter entity bean communication and to create coarse grained entity beans.

This was definitely true with regards to EJB 1.1. However EJB 2.0 is a large step forward and this best practice does not really hold true now that we have things like local interfaces, CMP 2.0, and CMR.
However, the current trend of best practices is to not use Entity Beans at all.
Kelly Walker
Greenhorn

Joined: Sep 09, 2003
Posts: 24
So are you saying that CMP and CMR are a bad thing? How then should I create, update, delete, select data from my RDBMS. Do you advocate using only session beans and direct JDBC calls? Or did I muisunderstand?
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
First off, since I don't know anything about your application, it is not clear that you need EJB at all.
Assuming that you are using EJB... I prefer to go with Session Bean + Hibernate (or plain JDBC if it is a simple application) over Entity Beans.
[ September 09, 2003: Message edited by: Chris Mathews ]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Hibernate is a free software.


Groovy
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Pradeep Bhat:
Hibernate is a free software.

To be more exact... it is OSS licensed under LGPL.
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

Does it mean that it is not free?
Kelly Walker
Greenhorn

Joined: Sep 09, 2003
Posts: 24
Sticking with just the J2EE specification, are you saying that I should give entity beans a wide berth? I use weblogic 8.1 btw.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Originally posted by Pradeep Bhat:
Does it mean that it is not free?

No it is definitely free, however it is good to know what license you will have to abide by. For example, LGPL is less restraining than the standard GPL but still not as flexible as BSD or ASF licenses.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
LGPL-licenced software is free and it allows your application to be closed-source and for-profit unlike with GPL, which is considered a "viral" licence (forcing your application to be GPL'd as well).


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Entity Bean Best Practice