I have a session bean where I create an object which implements an interface and returns same object. Is this a good approach or should I create a dto out the object and return the dto ?
Hi, whether the object you create inside the session bean is implementing an interface or not it is a good idea to encapsulate the data you return from a session bean into a DTO, specially when you call this bean using its remote object interfac or - interms of EJB3.0 - remote business interface. But it is a good thing also to define an interface for this DTO to implement or a base class as a kind of agreement between the service and the service consumer. But you have to take care of the serializability of the returned DTO object and its contained objects as well.