Bonjour a tous,
j'ai l'exception suivante quand j'effectue certaine operation, et je ne trouve pas pourquoi.
Ca se produit entre autre quand je fait un delete et un update. (mais par sur tous mes objets).
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53 public class Hibernate { protected static final SessionFactory sessionFactory; static { try { // Create the SessionFactory from hibernate.cfg.xml sessionFactory = new Configuration().configure().buildSessionFactory(); } catch (Throwable ex) { // Make sure you log the exception, as it might be swallowed System.err.println("Initial SessionFactory creation failed." + ex); throw new ExceptionInInitializerError(ex); } } public void create(Object obj) { Session session = sessionFactory.openSession(); session.getTransaction().begin(); session.save(obj); session.getTransaction().commit(); } public void refresh(Object obj) { Session session = sessionFactory.openSession(); session.getTransaction().begin(); session.refresh(obj); session.getTransaction().commit(); } public void update(Object obj) { Session session = sessionFactory.openSession(); session.getTransaction().begin(); session.saveOrUpdate(obj); session.getTransaction().commit(); } public void delete(Object obj) { Session session = sessionFactory.openSession(); session.getTransaction().begin(); session.delete(obj); session.getTransaction().commit(); } protected String protectString(String toProtect) { return (toProtect.replace("'", "''")); } }Si vous pouviez me guider ca serait sympa car je ne trouve vraiment pas, je ne comprend meme pas l'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 public class DAOPerson extends Hibernate { @SuppressWarnings("unchecked") public List<Person> findByName(String name) { Session session = sessionFactory.openSession(); List<Person> List = session.createQuery("FROM Person WHERE FirstName LIKE '%" + this.protectString(name) + "%' OR LastName LIKE '%" + this.protectString(name) + "%' ORDER BY LastName ASC, FirstName ASC").list(); return (List); } @SuppressWarnings("unchecked") public List<Person> findByFullName(String lastName, String firstName) { Session session = sessionFactory.openSession(); List<Person> List = session.createQuery("FROM Person WHERE FirstName='" + this.protectString(firstName) + "' AND LastName='" + this.protectString(lastName) + "'").list(); return (List); } @SuppressWarnings("unchecked") public List<Person> findAll() { Session session = sessionFactory.openSession(); List<Person> List = (List<Person>)session.createQuery("From Person ORDER BY LastName ASC, FirstName ASC").list(); return (List); } }
J'ai trouver deux autre topics la dessus mais rien de concluant.
Merci d'avance.
Cordialement,
NeoKript
Partager