diff options
Diffstat (limited to 'orktrack/src/net/sf/oreka/orktrack/PortManager.java')
-rw-r--r-- | orktrack/src/net/sf/oreka/orktrack/PortManager.java | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/orktrack/src/net/sf/oreka/orktrack/PortManager.java b/orktrack/src/net/sf/oreka/orktrack/PortManager.java index 09c18e9..839b9ab 100644 --- a/orktrack/src/net/sf/oreka/orktrack/PortManager.java +++ b/orktrack/src/net/sf/oreka/orktrack/PortManager.java @@ -115,13 +115,15 @@ public class PortManager { portById.put(1, port); } - public void initialize() { + public boolean initialize() { + Session hbnSession = null; + boolean success = false; try { - Session session = HibernateManager.getSession(); - Transaction tx = session.beginTransaction(); + hbnSession = HibernateManager.getSession(); + Transaction tx = hbnSession.beginTransaction(); - Iterator portFaces = session.createQuery( + Iterator portFaces = hbnSession.createQuery( "from RecPortFace") .list() .iterator(); @@ -132,7 +134,7 @@ public class PortManager { int portId = portFace.getRecPort().getId(); Port port = portById.get(portId); if(port == null) { - RecPort recPort = (RecPort)session.get(RecPort.class, portId); + RecPort recPort = (RecPort)hbnSession.get(RecPort.class, portId); if (recPort != null) { port = new Port(recPort); portById.put(portId, port); @@ -142,11 +144,15 @@ public class PortManager { portByName.put(portFace.getName(), port); } tx.commit(); - session.close(); + success = true; } catch (Exception e) { - log.warn("HibernateManager.initialize: could not initialize", e); + log.error("initialize: exception:" + e.getClass().getName()); } + finally { + if(hbnSession != null) {hbnSession.close();} + } + return success; } public RecPort getRecPortByFace(String face, Session hbnSession) { |