I'm creating a web app using JEE7. My question is about the architecture of my application. Basically, I have several entity classes (business class) that represent what will be stored in my database. For example I've got an entity class Book and an entity class Comic.
To access the database I want to create an EJB (kindda like the DAO design pattern). And here is my problem, I couldn't find a precise answer online.
Should I create one @remote interface and one @stateless class with all the methods to add/delete/get/update for both the Book class and the comic class ?
Or should I create 2 @remote interfaces and 2 @stateless classes (2 EJB), one for each entity class ?
Because lets imagine I create a bigger web app. If I have 100 entity classes, with the first method I'll have one huge EJB but with the second I'll have 100 EJB with their interfaces. I think the second is better but I'm not sure. What do you think ?
Java EE application architecture is obviously a massive topic, but a common approach would be to create a Session EJB to expose general API calls to your client and then use a coarse grain Entity EJB to handle your persistent data. These Entity EJBs can manage a number of finer grained Java objects and classes that map onto your database structure.
This might be a good place to start: https://docs.oracle.com/cd/A87860_01/doc/java.817/a83725/entity1.htm