Our book Java Persistence with Hibernate
is now available in German. You can get it from Hanser Verlag and they also have an eBook edition available. This is a literal translation of the English original. However, to finish the translation faster we decided to cut the bonus chapter with the Seam introduction. Sorry folks, I will ask Manning if we can get this chapter published for free in the English original version. With Seam 2.0 approaching final release this is a bit outdated anyway.
Tags: Books
Created: 10. Oct 2007, 15:59 CET (Christian Bauer)
Last Modified: 10. Oct 2007, 16:07 CET (Christian Bauer)
Hi Christian, I am currently using your book . I notice the book discusses persistence of entities with state only, but in my case i have business entities with both hebavior and state. So the problem comes on how to access the session bean DAO from the business methods of my entities?
Here is my scenario, I have modelled my business domain which is an order service with entities {order, product, lineItem, customer, address...}. My entities have both behaviour (business methods) and state(properties). I am implementing my order service with EJB 3.0.
Since I want to use JPA to manage my object states persistence, I have implement my entities as JPA entity (marking my entity objects with @Entity). Also, becuase I want to take the work of managing sessions, transactions ... off my hands I decided to use session bean for implementing my DAO (there have been some fierce debate on whether i should call my entity managers DAO or Repository but that is another story). my DAO use hibernate ORM behind the scene. So now I have {orderDAO productDAO} which according to my use cases is enough to do all the persistence jobs.
Questions
1) Now I do stuffs like Order order equals DAOFactory.getOrderDAO.getOrder(long OrderID); I compile with no errors but i can not deploy completely. It seem as if I can not call my OrderDAO ( session bean ) from my Order entity ( JPA entity @Entity); It is possible to call sessions bean from JPA entities and how can we do it ?
2) Must I implement a session bean in order to use container managed persistence? if my orderDAO is not a session bean, how do I manage transaction transperently ?
3) I am doing some thing wrong? I don't see people injecting session beans into JPA entities ( i deliberately avoid the use of the term entity beans). How do you usually implement your domain model, how do you take care of transaction and sessions within the DAO?
As an aside, do you have any mailing list? or facebook account?
Waiting for your replies. Best Wishes, Leonard.