I am just starting with these technologies and I am coming from older EJB systems. I created a data model using POJO and mapped it to the database tables. Created repositories and wrapped everything in a Service which has transactional annotations. My relationships are mostly lazy so that I don't suck up the entire database when retrieving one object. So far, so good. I like it.
The question I have is regarding returning my POJO model beans from the Service interface.
If the service is accessed locally, then trying to read collections which have not been "touched" during transaction kicks off the Lazy loading process which by that time no longer has the session causing an exception to happen. Meanwhile most of the examples I saw tend to declare the POJO model objects as implementing Serializable which seems to indicate that no special Data Transfer objects are needed and the model POJOs can be used directly by the client of the Service.
Of course in the old EJB model we never returned the EntityBean to the client outside of the SessionBean and always used Data Transfer Objects to communicate between external client and internal EntityBeans through the SessionBeans. Is this still the case with Spring->Hibernate->JPA? According to my short experience with this technology it seems that Data Transfer Objects still should be used as a main interface between the client and the Service.
Is there something that I am missing?
Hot dog! An advertiser loves us THIS much:
the new thread boost feature brings a LOT of attention to your favorite threads