@Stateless on CDI project

Asked

Viewed 152 times

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?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.