1

I'm new in EJB & persistence at all, so excuse me please if I'll ask a stupid question. I read a book about EJB and JPA, and faces phrase that I don't understand at all:

Intended to fully insulate developers from dealing directly with persistence, it (EJB) introduced an interface-based approach, where the concrete bean class was never directly used by client code. Instead, a specialized bean compiler generated an implementation of the bean interface to facilitate such things as persistence, security, and transaction management, delegating the business logic to the entity bean implementation.

and

The notion of container-managed entity beans was introduced, where bean classes became abstract and the server was responsible for generating a subclass to manage the persistent data.

What does it mean:

  1. Specialized bean compiler generated an implementation of the bean interface

  2. server was responsible for generating a subclass to manage the persistent data Actually I can't grasp what mean generate implementation/subclass, does it mean in runtime?

Thank you in advance.

EDITED:

Finally, entity beans were modeled as remote objects that used RMI and CORBA, introducing network overhead and restrictions that should never have been added to a persistent object to begin with.

Does it also sink into nothingness?

VB_
  • 45,112
  • 42
  • 145
  • 293
  • Which version of EJB the book is talking about? – SJuan76 Jun 22 '13 at 10:03
  • It talks about the evolution of EJB. The first phrase was about EJB1.0, the second - about EJB2.0. It is differ in EJB3.0? – VB_ Jun 22 '13 at 10:07
  • Unless specificly needed for your workplace, forget about anything earlier than EJB 3. That was a nightmare. – SJuan76 Jun 22 '13 at 10:13

2 Answers2

1
  1. Specialized Bean: Since Java EE 5, EJB turn into annotation @EJB. All annotaion works like interface. This simple annotaion provide security, and transaction management, delegating the business logic at compile time.

  2. JPA: No more entity bean remain since Java EE 5. Now if you put @Entity to on pojo than server will generate container-managed entity beans and communicate with database through persistance context.

Masudul
  • 21,823
  • 5
  • 43
  • 58
1

1) Interfaces: To define a bean, you had to declare a Local interface and a Remote interface (if you were writting bean MyEJB, they had to be MyEJBLocal and MyEJBRemote; MyEJB would implement both). With that, the compiler generated some derived class implementing the methods, such methods would just connect to the EJB server to retrieve a bean and execute its methods.

I am not so sure about 2, since we had so many performance issues that we ended implementing JDBC logic in the Session beans (I know, I know)...

SJuan76
  • 24,532
  • 6
  • 47
  • 87
  • and one more question about RMI (see EDITED section of my question) – VB_ Jun 22 '13 at 10:23
  • 1
    It just means that the `stub` classes generated by the compiler internally used `RMI` and `CORBA` to connect to the server. From the client POV, the entity or session bean was the remote object, accessible through the stubs. – SJuan76 Jun 22 '13 at 10:27
  • Does it differ in nowadays? How? – VB_ Jun 22 '13 at 10:30
  • 1
    It will be easier to say that what has not changed is the name, and that there are still Session (Stateless and Stateful) and Entity means, with the same meaning (but different implementation techniques). – SJuan76 Jun 22 '13 at 10:55