Obviously using stateless EJB beans in an entity bean smells, but please consider a scenario as follows and tell me if you know of a better solution:
- I have an
InvoiceTemplate
Entity Bean with fieldNextInvoiceDate
- Generating
NextInvoiceDate
is a complex procedure and should be performed outside of theInvoiceTemplate
class NextInvoiceDate
should be updated each timeInvoiceTemplate
is stored to the db
For now I have logic regarding the generation of NextInvoiceDate
in @PrePersist
@PreUpdate
methon in InvoiceTemplate
entity bean. The logic is getting more and more complicated and I want to move it outside of the InvoiceTemplate
entity bean. It looks to me that there should be a service to calculate NextInvoiceDate
. But then is it right to invoke this service from the inside of InvoiceTemplate
?