• Post Reply Bookmark Topic Watch Topic
  • New Topic

ejb3 - questions from a newbie

 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi there,
I've just finished to have a look on the j2ee tutorial, but I stll dont get a couple of points:
1- when should I use simple Entity beans instead of CMP entity beans?
2- could you give me a classic scenario where to use Message Driven bean?

Thanks in advance
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 35743
412
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alessandro,
1) In EJB 2.X, there was CMP (container managed persistence) entity beans which people mainly used over BMP (bean managed - aka you write the code yourself.) In EJB 3.0, entity beans use JPA (Java persistence architecture.) So you would choose "simple" entity beans in EJB 3.0 because that's what is available. You would choose CMP in EJB 2.1 because it is the best alternative supported at the time.
2) You need to do something asynchronously. For example, you need to send a file for processing on a remote machine, but don't need to result immediately.
 
Jon Wetherbee
author
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Alessandro-
I assume your tutorial covered J2ee 1.4, which defines EJB 2.1. In this version of EJB, Entity beans come in two types -- container-managed persistence (CMP) and bean-managed persistence (BMP). Are these the two types you are contemplating? If so, CMP beans let you define the object/relational (O/R) mapping metadata in XML, whereas BMP beans do not, and require you to provide your own persistence layer, commonly using directly JDBC calls.

In the latest version of EJB, 3.0, which is defined in Java EE 5, entity beans have been replaced by simple plain old Java object (POJO) entity classes. This new entity specification is defined by the Java Persistence API (JPA), and is widely seen as a great improvement over the EJB 2.1 and earlier entity bean model. I mention this because if you are new to EJB, I suggest you jump to EJB 3.0 and JPA entities instead of developing with EJB 2.1 entity beans.

Most commercial vendors now provide, or will provide shortly, production servers that support Java EE 5, which includes EJB 3.0 and JPA 1.0. Of course, if you are currently required to use a J2ee 1.4 server, then you can shelve away this knowledge for the future...

Regards,
Jon

P.S. For more info on EJB 3.0 and JPA 1.0, you may enjoy:
http://www.apress.com/book/bookDisplay.html?bID=10129
 
Alessandro Ilardo
Ranch Hand
Posts: 218
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for your replyes.

Yes, I am new with EJB and I spent the last week reading the tutorials and articles about it.
I think that after a basic knowledge acquired from tutorials and stuff out there, the best way to get into this is start to code.

I would start to develop a multi tier application which manages users account
let Hibernate manage the persistence and EJB3 the business logic (session).

I'd like to know your opinion, as I'm going to invest a lot of my resources and I don't want be disapointed in having learnt something useless.

[ February 21, 2007: Message edited by: Alessandro Ilardo ]
[ February 21, 2007: Message edited by: Alessandro Ilardo ]
 
Pradeep bhatt
Ranch Hand
Posts: 8933
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Alessandro ,

It makes sense to use EJB 3 for your application.Put your business logic in session bean ans use entity beans for persistent objects.

You use MDB when you want some business logic to be executed asynchronusly.For e.g. send email to partners (or invoke some partner WS)when stock in inventory goes below some number etc.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!