Salut,
dans mon archi 3 tiers, j'ai décidé d'utiliser saveOrUpdate mais il me répète sans cesse :
javax.servlet.ServletException: this instance does not yet exist as a row in the database
comment est-ce possible ?
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 public static Entry addEntry(Entry entry, User user) throws Exception{ Session session = HibernateUtil.currentSession(); entry.setOrgId( user.getOrgid()); Transaction tx = null; try { tx = session.beginTransaction(); session.saveOrUpdate(entry); tx.commit(); session.flush(); HibernateUtil.closeSession(); } catch (Exception e) { if (tx != null){ tx.rollback(); session.refresh(entry); HibernateUtil.closeSession(); } throw e; } return(entry); }
Partager