EJB2 vs. EJB3

Hi everyone,

I am trying to understand the language when speaking about EJB2 vs. EJB 3. In the course I am taking, the following question or topic was presented:

"Discuss the difference between container-managed and bean-managed persistence and when you would use each."

Now I took this to refer to EJB 2 Entity Beans and answered along those lines. One of the students posted the following:

"When an entity bean does its job of manipulating data, that persistence functionality needs management. We have a choice of container-managed or bean-managed persistence (CMP or BMP). CMP is a function of the EJB container provided by the EJB server. In this scenario, "an entity bean is mapped to a database table that is dedicated to the purpose of storing instances of that entity bean (Mukhar, et al, 2006)." The EntityManager (javax.persistence.EntityManager) interface is used in code to find beans in order to manipulate them (persist, remove, find). All of this gives us a way to manipulate an abstraction of the data we are persisting - for example, rather than performing direct SQL statements, our code performs bean operations, even using the EJB Query Language. We can think of a single entity bean instance using CMP as a a single row on a table. As such, each entity bean must have a unique primary key just as we would expect on a table row. This primary key can be designated by the developer by specifying a bean attribute or the container can maintain the uniqueness via the @Id (javax.persistence.Id) metadata descriptor."

Note the reference to EntityManager, which is, as I understand it, a EJB 3 construct and manages Entity classes (EJB 3) not Entity Beans (EJB 2). Do you think this student is confusing EJB 2 and EJB 3? Or is it I who is totally confused, lol?

Thanks!!

[1844 byte] By [orbacha] at [2007-11-27 6:06:01]
# 1

No takers?

Maybe I just posted too much text. In essence these are my questions:

1) Is Container Managed Persistence (CMP) a EJB 2 concept that does not apply in EJB 3 and JPA? That is, I think in EJB 3 we would have Persistence Provider Managed Persistence, to call it something, instead of CMP.

2) The EntityManager is the EJB 3 Persistence Provider and does not apply to EJB 2 Entity Beans?

I think in my class everyone is very confused between EJB 2 and EJB 3 concepts and I would appreciate any confirmation. It may be I who is confused.

Thanks!

You do not need to continue reading from here. I added the other learner's statement below, without italics this time, for reference. My complaint is he seems to imply EntityManager manages Entity Beans. I think it only manages Entity classes not Entity Beans.

"When an entity bean does its job of manipulating data, that persistence functionality needs management. We have a choice of container-managed or bean-managed persistence (CMP or BMP). CMP is a function of the EJB container provided by the EJB server. In this scenario, "an entity bean is mapped to a database table that is dedicated to the purpose of storing instances of that entity bean (Mukhar, et al, 2006)." The EntityManager (javax.persistence.EntityManager) interface is used in code to find beans in order to manipulate them (persist, remove, find). All of this gives us a way to manipulate an abstraction of the data we are persisting - for example, rather than performing direct SQL statements, our code performs bean operations, even using the EJB Query Language. We can think of a single entity bean instance using CMP as a a single row on a table. As such, each entity bean must have a unique primary key just as we would expect on a table row. This primary key can be designated by the developer by specifying a bean attribute or the container can maintain the uniqueness via the @Id (javax.persistence.Id) metadata descriptor."

orbacha at 2007-7-12 16:53:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2

The terms CMP and BMP apply to EJB2 Entity Beans.

Entity Beans do not exist in EJB3 as they did in EJB2.

EJB3 uses the EntityManager to persist annotated POJOs(Entity classes).

You are correct

See http://www.google.co.za/search?hl=en&q=ejb2+ejb3+difference&meta=

Hope that helped :)

Added google search

Message was edited by:

MichaelW13

MichaelW13a at 2007-7-12 16:53:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3

> Hope that helped :)

>

> Added google search

>

> Message was edited by:

> MichaelW13

Yes, it did and thanks for the google search. I have been reading all kinds of google results and figured I was correct, but still the instructor and learners in the course do not address these issues I bring up... Thanks again!

orbacha at 2007-7-12 16:53:04 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...