I am new to JPA and CDI, and I am trying to create an enterprise application using these frameworks.
I get how I can stick in beans and keep everything in order and stateless. I also understand that JPA loads relationships, etc. For me, so I no longer need to worry about it. I still use my DAO for specific search methods and, of course, to create new objects.
I understand that I do not want to inject material into my objects, since they are controlled by JPA, and I need to use the new keyword to create a new object (instead of loading).
I use to manage my objects with other classes, for example, if we have a User and a group, I use the idle bean status to manage the group (create new, search, etc.), and this idle beans uses my DAO to retrieve and sending data.
I am using a Group object to manage users (maybe this is wrong?), But I do not want to introduce a DAO into the group, as this is an entity. I know that something is wrong with this design, but I cannot find the best practice for this.
Should all management classes be EJB? I'm used to creating domain classes for my logic, should I drop this concept, put all my logic in EJB and use objects to store data only?
source share