• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

Business Methods + Entity Beans.

 
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.
 
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
 
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 ;-)
 
Get me the mayor's office! I need to tell her about this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic