The generic interface is fine, but I still need to implement basic operations for each of my Business Objects.
The second solution (bean implementation) is great, but... how should I use it?
1. Should I use composition and inject this CrudServiceBean into mine business object and perhaps delegate all CRUD operations to this EJB, somewhat like this:
In this way I still need to write every CRUD method in my business object class (just a delegation but still in 90% it's just the same plain delegation code).
2. I can extend the CrudServiceBean like the code below:
Can I extend another EJB? If I cannot, than this CrudServiceBean must be a POJO and therefore it will not have EntityManager injected. This sucks pretty badly...
3. I can extend the CrudServiceBean (plain POJO) and modify it to use a method like getEntityManager() within:
However, in this solution the getEntityManager() method must be at least package-visible (because of the overriding method from business object). I am not sure if this is the correct approach, as it exposes the EntityManager for other BusinessObjects...
Which approach would you choose and what is the rationale?
Thanks in advance!
Evildoers! Eat my justice! And this tiny ad's justice too!
a bit of art, as a gift, the permaculture playing cards