简体   繁体   中英

How to handle JPA entities in EJB beans

Regularly in a non-JavaEE application, I would create some sort of persistence-facade/persistence layer (located in a folder containing all persistence handling code). Since I just started with JavaEE I don't understand what is the best way to create that "layer":

  • Should I use the same Persistence facade/interface and create an EJB from it?
  • Should I create and EJB for each entity (eg an EJB for Employee and EJB for Department)?
  • How to separate the code to projects/folders? what does the client side needs to "know" from the server side code? should the entities be in a separate "common" project that will be used by server & client?
  • ...

It would be great if you could help me sort it out, or even point me to the right manual.

EJB3 introdice EntityManager which takes control entities. EntityManager inject into busness logic service (stateless EJB ) and takes over management entity. No need to create a façade for each entity class, but if you need you can make separate services for each entity class. More details and example see in book "Thinking in Enterprise Java by Bruce Eckel"

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM