• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Business Methods + Entity Beans.

 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please guys could you help me with this question :

"Business Methods CANNOT return a reference to the Entity Object."

is this TRUE or FALSE? why??

Tks.
 
sammaiah kyatham
Ranch Hand
Posts: 104
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
The answer is True because the bean itself must never be exposed.

And also,
Arguments and return types for Remote component interface methods must be legal RMI-IIOP types (primitive, Serializable, Remote or arrays/collections of these types)

Thnx,
Sam
 
Camilo Morales
Ranch Hand
Posts: 92
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
With the new Persistence API the entities should (but is not mandatory) to implement the Serializable interface. In that case, and since entities are POJOS, you can serialize them and send them through the network, but if you return a Entity in a session business method, of course it is detached from any persistent context and any changes done in that instance, wont take effect in the database. In other words, you are not returning the Entity, you return a POJO, just a Value Object.

If the caller of your business method is another session bean, in that case you should be more carefull because the transaction scope can be propagated and maybe if you return an entity, this could not be detached and any change made to it, may take effect in the database.

(Im just preparing for the SCBCD 5 ... Im not a JEE expert so please correct if Im wrong.)
 
Steven Colley
Ranch Hand
Posts: 290
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey sammaiah, how are you?

As far this: "The answer is TRUE because the BEAN ITSELF must never be EPOSED."

Yeah ...It does even make sense cause of EJB "Object" itself. I got a little confused between Bean "Object" and "component Interface"..(Component interfaces can normally be sent to the clients...)

Ok, that's right!

Tks ;-)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic