[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model AttributeFacade.java,1.1,1.2 Construc
Status: Pre-Alpha
Brought to you by:
henryml
From: Jesper P. <je...@us...> - 2005-09-20 12:56:59
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12323/src/net/sourceforge/bprocessor/model Modified Files: AttributeFacade.java ConstructionSpaceFacade.java DomainFacade.java EdgeFacade.java ElementFacade.java FunctionalSpaceFacade.java PartFacade.java SurfaceFacade.java VertexFacade.java Log Message: tx.rollback() when an exception is thrown Index: ConstructionSpaceFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ConstructionSpaceFacade.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ConstructionSpaceFacade.java 20 Sep 2005 12:26:39 -0000 1.7 --- ConstructionSpaceFacade.java 20 Sep 2005 12:56:45 -0000 1.8 *************** *** 54,60 **** public synchronized ConstructionSpace create(ConstructionSpace c) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(c); --- 54,61 ---- public synchronized ConstructionSpace create(ConstructionSpace c) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(c); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(ConstructionSpace c) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(c); --- 83,90 ---- public synchronized void update(ConstructionSpace c) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(c); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,105 **** --- 110,115 ---- public synchronized void remove(ConstructionSpace c) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; + //setting references to this space to null Set surfaces = c.getSurfaces(); *************** *** 121,127 **** } } try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(c); --- 131,138 ---- } } + try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(c); *************** *** 132,135 **** --- 143,149 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 146,152 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT c FROM ConstructionSpace AS c"); --- 160,167 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT c FROM ConstructionSpace AS c"); *************** *** 159,162 **** --- 174,180 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 176,182 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (ConstructionSpace)session.load(ConstructionSpace.class, id); --- 194,201 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (ConstructionSpace)session.load(ConstructionSpace.class, id); *************** *** 184,187 **** --- 203,209 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 201,207 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT c FROM ConstructionSpace AS c WHERE c.name = :name"); --- 223,230 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT c FROM ConstructionSpace AS c WHERE c.name = :name"); *************** *** 215,218 **** --- 238,244 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 232,243 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); ! Query q = session.createQuery("SELECT f FROM ConstructionSpace AS f," + "Domain AS d " + "JOIN d.surfaces AS surfaces " + ! "WHERE surfaces.id = :id AND d.id = f.id"); q.setLong("id", surface.getId().longValue()); --- 258,270 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); ! Query q = session.createQuery("SELECT cs FROM ConstructionSpace AS cs," + "Domain AS d " + "JOIN d.surfaces AS surfaces " + ! "WHERE surfaces.id = :id AND d.id = cs.id"); q.setLong("id", surface.getId().longValue()); *************** *** 248,251 **** --- 275,281 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: ElementFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/ElementFacade.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ElementFacade.java 17 Aug 2005 11:22:54 -0000 1.4 --- ElementFacade.java 20 Sep 2005 12:56:45 -0000 1.5 *************** *** 54,60 **** public synchronized Element create(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(e); --- 54,61 ---- public synchronized Element create(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(e); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(e); --- 83,90 ---- public synchronized void update(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(e); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,108 **** public synchronized void remove(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(e); --- 110,117 ---- public synchronized void remove(Element e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(e); *************** *** 113,116 **** --- 122,128 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 127,133 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Element AS e"); --- 139,146 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Element AS e"); *************** *** 140,143 **** --- 153,159 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 157,163 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Element)session.load(Element.class, id); --- 173,180 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Element)session.load(Element.class, id); *************** *** 165,168 **** --- 182,188 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 182,188 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Element AS e WHERE e.name = :name"); --- 202,209 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Element AS e WHERE e.name = :name"); *************** *** 196,199 **** --- 217,223 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: AttributeFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/AttributeFacade.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** AttributeFacade.java 24 Aug 2005 06:58:06 -0000 1.1 --- AttributeFacade.java 20 Sep 2005 12:56:45 -0000 1.2 *************** *** 47,53 **** public synchronized Attribute create(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(a); --- 47,54 ---- public synchronized Attribute create(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(a); *************** *** 55,58 **** --- 56,62 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 69,75 **** public synchronized void update(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(a); --- 73,80 ---- public synchronized void update(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(a); *************** *** 77,80 **** --- 82,88 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 89,95 **** public synchronized void remove(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(a); --- 97,104 ---- public synchronized void remove(Attribute a) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(a); *************** *** 97,100 **** --- 106,112 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 112,118 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Attribute)session.load(Attribute.class, id); --- 124,131 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Attribute)session.load(Attribute.class, id); *************** *** 120,123 **** --- 133,139 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: DomainFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/DomainFacade.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DomainFacade.java 20 Sep 2005 12:39:40 -0000 1.1 --- DomainFacade.java 20 Sep 2005 12:56:45 -0000 1.2 *************** *** 52,58 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT d FROM Domain AS d"); --- 52,59 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT d FROM Domain AS d"); *************** *** 65,68 **** --- 66,72 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 82,88 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Domain)session.load(Domain.class, id); --- 86,93 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Domain)session.load(Domain.class, id); *************** *** 90,93 **** --- 95,101 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 97,100 **** --- 105,109 ---- return result; } + /** * Find all the domains associated with a surface *************** *** 106,112 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); //this query is wrong --- 115,122 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); //this query is wrong *************** *** 122,125 **** --- 132,138 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: SurfaceFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/SurfaceFacade.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** SurfaceFacade.java 20 Sep 2005 12:38:11 -0000 1.8 --- SurfaceFacade.java 20 Sep 2005 12:56:45 -0000 1.9 *************** *** 53,67 **** public synchronized Surface create(Surface s) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(s); tx.commit(); ! Notification n = new Notification(Notification.SURFACE_CREATED, s.getId()); Notifier.getInstance().sendNotification(n); } catch (Exception ex) { log.error(ex.getMessage(), ex); } finally { --- 53,71 ---- public synchronized Surface create(Surface s) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(s); tx.commit(); ! Notification n = new Notification(Notification.SURFACE_CREATED, s.getId()); Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 78,84 **** public synchronized void update(Surface s) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(s); --- 82,89 ---- public synchronized void update(Surface s) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(s); *************** *** 89,92 **** --- 94,100 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 113,119 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(s); --- 121,128 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(s); *************** *** 124,127 **** --- 133,139 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 138,144 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s"); --- 150,157 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s"); *************** *** 151,154 **** --- 164,170 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 168,174 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Surface)session.load(Surface.class, id); --- 184,191 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Surface)session.load(Surface.class, id); *************** *** 176,179 **** --- 193,199 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 193,199 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s WHERE s.name = :name"); --- 213,220 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s WHERE s.name = :name"); *************** *** 207,210 **** --- 228,234 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 224,230 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s " + --- 248,255 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT s FROM Surface AS s " + *************** *** 240,243 **** --- 265,271 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: VertexFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/VertexFacade.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** VertexFacade.java 17 Aug 2005 11:22:54 -0000 1.5 --- VertexFacade.java 20 Sep 2005 12:56:45 -0000 1.6 *************** *** 54,60 **** public synchronized Vertex create(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(v); --- 54,61 ---- public synchronized Vertex create(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(v); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(v); --- 83,90 ---- public synchronized void update(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(v); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,108 **** public synchronized void remove(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(v); --- 110,117 ---- public synchronized void remove(Vertex v) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(v); *************** *** 113,116 **** --- 122,128 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 127,133 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT v FROM Vertex AS v"); --- 139,146 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT v FROM Vertex AS v"); *************** *** 140,143 **** --- 153,159 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 157,163 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Vertex)session.load(Vertex.class, id); --- 173,180 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Vertex)session.load(Vertex.class, id); *************** *** 165,168 **** --- 182,188 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 182,188 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT v FROM Vertex AS v WHERE v.name = :name"); --- 202,209 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT v FROM Vertex AS v WHERE v.name = :name"); *************** *** 196,199 **** --- 217,223 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 216,222 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); double minX = x - delta; --- 240,247 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); double minX = x - delta; *************** *** 245,248 **** --- 270,276 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: EdgeFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/EdgeFacade.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** EdgeFacade.java 17 Aug 2005 11:22:54 -0000 1.5 --- EdgeFacade.java 20 Sep 2005 12:56:45 -0000 1.6 *************** *** 54,60 **** public synchronized Edge create(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(e); --- 54,61 ---- public synchronized Edge create(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(e); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(e); --- 83,90 ---- public synchronized void update(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(e); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,108 **** public synchronized void remove(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(e); --- 110,117 ---- public synchronized void remove(Edge e) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(e); *************** *** 113,116 **** --- 122,128 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 127,133 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e"); --- 139,146 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e"); *************** *** 140,143 **** --- 153,159 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 157,163 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Edge)session.load(Edge.class, id); --- 173,180 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Edge)session.load(Edge.class, id); *************** *** 165,168 **** --- 182,188 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 182,188 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e WHERE e.name = :name"); --- 202,209 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e WHERE e.name = :name"); *************** *** 196,199 **** --- 217,223 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 213,219 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e " + --- 237,244 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT e FROM Edge AS e " + *************** *** 228,231 **** --- 253,259 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: PartFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/PartFacade.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PartFacade.java 17 Aug 2005 11:22:54 -0000 1.4 --- PartFacade.java 20 Sep 2005 12:56:45 -0000 1.5 *************** *** 54,60 **** public synchronized Part create(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(p); --- 54,61 ---- public synchronized Part create(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(p); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(p); --- 83,90 ---- public synchronized void update(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(p); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,108 **** public synchronized void remove(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(p); --- 110,117 ---- public synchronized void remove(Part p) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(p); *************** *** 113,116 **** --- 122,128 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 127,133 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT p FROM Part AS p"); --- 139,146 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT p FROM Part AS p"); *************** *** 140,143 **** --- 153,159 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 157,163 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (Part)session.load(Part.class, id); --- 173,180 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (Part)session.load(Part.class, id); *************** *** 165,168 **** --- 182,188 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 182,188 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT p FROM Part AS p WHERE p.name = :name"); --- 202,209 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT p FROM Part AS p WHERE p.name = :name"); *************** *** 196,199 **** --- 217,223 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { Index: FunctionalSpaceFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/FunctionalSpaceFacade.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** FunctionalSpaceFacade.java 20 Sep 2005 12:30:26 -0000 1.7 --- FunctionalSpaceFacade.java 20 Sep 2005 12:56:45 -0000 1.8 *************** *** 54,60 **** public synchronized FunctionalSpace create(FunctionalSpace f) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.save(f); --- 54,61 ---- public synchronized FunctionalSpace create(FunctionalSpace f) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.save(f); *************** *** 65,68 **** --- 66,72 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 79,85 **** public synchronized void update(FunctionalSpace f) { HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.update(f); --- 83,90 ---- public synchronized void update(FunctionalSpace f) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.update(f); *************** *** 90,93 **** --- 95,101 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 102,105 **** --- 110,115 ---- public synchronized void remove(FunctionalSpace f) { HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; + //setting references to this space to null Set surfaces = f.getSurfaces(); *************** *** 121,127 **** } } try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); session.delete(f); --- 131,138 ---- } } + try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); session.delete(f); *************** *** 132,135 **** --- 143,149 ---- Notifier.getInstance().sendNotification(n); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 146,152 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f"); --- 160,167 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f"); *************** *** 159,162 **** --- 174,180 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 176,182 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); result = (FunctionalSpace)session.load(FunctionalSpace.class, id); --- 194,201 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); result = (FunctionalSpace)session.load(FunctionalSpace.class, id); *************** *** 184,187 **** --- 203,209 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 201,207 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f WHERE f.name = :name"); --- 223,230 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f WHERE f.name = :name"); *************** *** 215,218 **** --- 238,244 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { *************** *** 232,238 **** HibernateUtil hu = HibernateUtil.getInstance(); try { Session session = hu.currentSession(); ! Transaction tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f," + --- 258,265 ---- HibernateUtil hu = HibernateUtil.getInstance(); + Transaction tx = null; try { Session session = hu.currentSession(); ! tx = session.beginTransaction(); Query q = session.createQuery("SELECT f FROM FunctionalSpace AS f," + *************** *** 248,251 **** --- 275,281 ---- tx.commit(); } catch (Exception ex) { + if (tx != null) { + tx.rollback(); + } log.error(ex.getMessage(), ex); } finally { |