0
Person, I have the following structure in my project (CDI):
BEAN:
@Named
@SessionScoped
public class ClienteMB extends BaseAbstractMB<Cliente, ClienteDTO> implements Serializable {
@Inject
private ClienteService clienteService;
// METODOS
}
Service (interface):
public interface ClienteService extends BaseService<Cliente, ClienteDTO>{
// METODOS
}
Serviceimpl:
@Transactional(rollbackOn = Exception.class)
public class ClienteServiceImpl extends BaseAbstractServiceImpl<Cliente, ClienteDTO> implements ClienteService {
// METODOS
}
Until then, this structure is correct, right? But in another project to which I work in the Clienteserviceimpl class we have an annotation called @Stateless
(Concept: No record of all previous interactions are saved)
My question is, do I really need to take the note @Stateless
? If yes, what is its real utility? Because once the project is CDI, the annotation @Stateless
It’s EJB, isn’t it?
And why in one project I don’t use the annotation and other use, and both normally functional.
According to a colleague of mine, if I don’t have the note @Stateless
would not make a @Inject
, but in the design I do not use the @Stateless
I can make a @Inject
normally.
Does anyone know how to explain this?
Possible duplicate of When to use Stateful or Stateless
– renanvm
And if I don’t use either, how does it impact? In this case, I can do it without any problem by not using stateless?
– Alisson Hoepers