[Bprocessor-commit] model/src/net/sourceforge/bprocessor/model EdgeFacade.java,1.2,1.3
Status: Pre-Alpha
Brought to you by:
henryml
From: Jesper P. <je...@us...> - 2005-07-28 08:01:34
|
Update of /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20257/src/net/sourceforge/bprocessor/model Modified Files: EdgeFacade.java Log Message: Added findByVertex() Index: EdgeFacade.java =================================================================== RCS file: /cvsroot/bprocessor/model/src/net/sourceforge/bprocessor/model/EdgeFacade.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** EdgeFacade.java 28 Jul 2005 06:48:54 -0000 1.2 --- EdgeFacade.java 28 Jul 2005 08:01:24 -0000 1.3 *************** *** 192,194 **** --- 192,226 ---- return result; } + + /** + * Find edges that has a vertex + * @param v The vertex + * @return The edges + */ + public Set findByVertex(Vertex v) { + Set result = new HashSet(); + + 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.from.id = :id OR e.to.id = :id"); + q.setLong("id", v.getId().longValue()); + + Iterator it = q.iterate(); + while (it.hasNext()) { + result.add((Edge)it.next()); + } + + tx.commit(); + } catch (Exception ex) { + log.error(ex.getMessage(), ex); + } finally { + hu.closeSession(); + } + + return result; + } } |