Class AbstractCrudService

  • All Implemented Interfaces:
    CrudReadService, CrudWriteService
    Direct Known Subclasses:
    AbstractCrudServiceEnvers

    @DeclareRoles("editor")
    public abstract class AbstractCrudService
    extends Object
    implements CrudWriteService, CrudReadService

    This base class enables you to create crud service beans with minimal effort. All you have to do is override, implement getEntityManager and annotate with for example @Stateless, @Local(Auditing.class, CrudWriteService.class). You can also just define CDI beans instead of EJB, but be aware you won't get declarative security then.

    Inject the crud interfaces using @Inject where you need them.

    This base class declares Transactional and EDITORROLE to protect write operations, read operations by default support no transactions. When overriding don't forget transaction and role annotations are not inherited. If you don't need security, override and use PermitAll.

    A JpqlBuilder is injected and used for building dynamic queries and for setting values when using named queries.

    Author:
    eduard