when doing userFacade.create(user)
, i can see the user is created in the database , but i can't login with that user until i restart the application
or if i unvalidate that session (it is in sessionScoped)
other exemple :if i create a Cv and add it to user CVs , i can't get the last cv created with user.getListCvs()
even if it is in the database ,but if i restart the server i can see it
this is the bean of creating a CV of the current user
public class CreerCV implements Serializable{
@EJB
private CvFacade cvFacade;
@EJB
CandidatFacade candidatFacade;
private Cv cv;
private Candidat candidat;
@PostConstruct
public void init(){
cv=new Cv();
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
candidat=(Candidat)session.getAttribute("membre");
candidat=candidatFacade.find(candidat.getId()); //so i can not get the listCVs of the my saved attribute in my session , but the listCVs of a user in the database ! This is the problem
}
//+getters and setters
public String creerCV(){
if(candidat!=null){
cv.setCandidat(candidat);
candidat.getListeCv().add(cv);
try{
cvFacade.create(cv);
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage("Création du cv avec succés"));
}catch(Exception e) {
System.out.println(e);
}
}
else
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Une erreur s'est produite",""));
return "/index.xhtml";
}
and this is the bean of displaying the CVs of the current user
@Named
@RequestScoped
public class ListeCvs implements Serializable{
@EJB
private CvFacade cvFacade;
private List<Cv> listeCvs=new ArrayList<>();
private Cv selectedCv;
private Candidat candidat;
@PostConstruct
public void init(){
HttpSession session = (HttpSession) FacesContext.getCurrentInstance().getExternalContext().getSession(false);
candidat=(Candidat)session.getAttribute("membre");
System.out.println(candidat.getListeCv());
if(candidat!=null)
listeCvs=candidat.getListeCv();
candidat=candidatFacade.find(candidat.getId());
}
//getters+setters ect..
Exemple :
i create a cv , i refresh i can not see the cv created in the table! i go to the database , i can see it is created i restart my application , i go to my table i can see my cv in the table
i create a second cv , i can not see it in the table , but i can see the previous one that i created,i see that it is created on the database,i restart my application go to my table i can see my 2 CVs there !
PS:for tests, i use System.out.print
and some dataTables
to see the list