Bonjour pouvez vous m'aider ?
je n'ai pas de session.il y a a la place null pointer exception

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Candidat candidat = new Candidat();
 
		candidat.setAge(age);
		candidat.setConfirme("non");
		candidat.setDepartement(departement);
		candidat.setEmail(email);
		candidat.setLogin(login);
		candidat.setNom(nom);
		candidat.setPrenom(prenom);
		candidat.setPassword(password);
		candidat.setPasswordconfirme(passwordconfirme);
		candidat.setSex(sex);
		candidat.setProfession(profession);
 
		try {if (HibernateSessionFactory.getSession().createSQLQuery("select max(idcandidat)  from Candidat")==null) {candidat.setIdcandidat(Integer.valueOf(1));HibernateSessionFactory.getSession().close();} 
		else {candidat.setIdcandidat(getIdcandidat()+Integer.valueOf(1));HibernateSessionFactory.getSession().close();}
		} catch (Exception e) {candidat.setIdcandidat(Integer.valueOf(1));}
 
		HibernateSessionFactory.closeSession();
 
		CandidatDAO dao = new CandidatDAO();
 
		Transaction  tx =  dao.getSession().getTransaction();  <=> icii null pointer exception
 
		tx =  dao.getSession().beginTransaction();
 
		dao.save(candidat);
 
		tx.commit();
 
		dao.getSession().close();