@Test @Transactional public void testDeleteElementsByMapType() { m_onmsMapElementDao.deleteElementsByMapType(OnmsMap.USER_GENERATED_MAP); m_onmsMapElementDao.deleteElementsByMapType(OnmsMap.AUTOMATICALLY_GENERATED_MAP); assertEquals(0,m_onmsMapElementDao.findAll().size()); }
public void deleteElementsByMapType(final String mapType) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { String hql = "delete from OnmsMapElement as element where element.id in ( select el.id from OnmsMapElement as el where el.map.type = ?)"; Query query = session.createQuery(hql); query.setParameter(0, mapType); query.executeUpdate(); return null; } }); }
OnmsMapElementDaoHibernate extends AbstractDaoHibernate<OnmsMapElement, Integer> implements OnmsMapElementDao { public void deleteElementsByMapType(final String mapType) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { String hql = "delete from OnmsMapElement as element where element.id in ( select el.id from OnmsMapElement as el where el.map.type = ?)"; Query query = session.createQuery(hql); query.setParameter(0, mapType); query.executeUpdate(); return null; } }); } }
OnmsMapElementDaoHibernate extends AbstractDaoHibernate<OnmsMapElement, Integer> implements OnmsMapElementDao { public void deleteElementsByMapType(final String mapType) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { String hql = "delete from OnmsMapElement as element where element.id in ( select el.id from OnmsMapElement as el where el.map.type = ?)"; Query query = session.createQuery(hql); query.setParameter(0, mapType); query.executeUpdate(); return null; } }); } OnmsMapElementDaoHibernate(); }
OnmsMapElementDaoHibernate extends AbstractDaoHibernate<OnmsMapElement, Integer> implements OnmsMapElementDao { public void deleteElementsByMapType(final String mapType) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { String hql = "delete from OnmsMapElement as element where element.id in ( select el.id from OnmsMapElement as el where el.map.type = ?)"; Query query = session.createQuery(hql); query.setParameter(0, mapType); query.executeUpdate(); return null; } }); } OnmsMapElementDaoHibernate(); @SuppressWarnings("unchecked") Collection<OnmsMapElement> findAll(final Integer offset, final Integer limit); OnmsMapElement findElementById(int id); Collection<OnmsMapElement> findElementsByMapId(OnmsMap map); Collection<OnmsMapElement> findElementsByNodeId(int nodeid); void deleteElementsByMapId(final OnmsMap map); void deleteElementsByNodeid(final int nodeid); void deleteElementsByType(final String type); void deleteElementsByElementIdAndType(final int id,final String type); Collection<OnmsMapElement> findElementsByElementIdAndType(
            int elementId, String type); Collection<OnmsMapElement> findElementsByType(String type); OnmsMapElement findElement(int elementId, String type, OnmsMap map); void deleteElementsByMapType(final String mapType); Collection<OnmsMapElement> findElementsByMapIdAndType(int mapId,
            String type); Collection<OnmsMapElement> findMapElementsOnMap(int mapId); Collection<OnmsMapElement> findNodeElementsOnMap(int mapId); int countElementsOnMap(final int mapid); }
OnmsMapElementDaoHibernate extends AbstractDaoHibernate<OnmsMapElement, Integer> implements OnmsMapElementDao { public void deleteElementsByMapType(final String mapType) { getHibernateTemplate().execute(new HibernateCallback<Void>() { public Void doInHibernate(Session session) throws HibernateException, SQLException { String hql = "delete from OnmsMapElement as element where element.id in ( select el.id from OnmsMapElement as el where el.map.type = ?)"; Query query = session.createQuery(hql); query.setParameter(0, mapType); query.executeUpdate(); return null; } }); } OnmsMapElementDaoHibernate(); @SuppressWarnings("unchecked") Collection<OnmsMapElement> findAll(final Integer offset, final Integer limit); OnmsMapElement findElementById(int id); Collection<OnmsMapElement> findElementsByMapId(OnmsMap map); Collection<OnmsMapElement> findElementsByNodeId(int nodeid); void deleteElementsByMapId(final OnmsMap map); void deleteElementsByNodeid(final int nodeid); void deleteElementsByType(final String type); void deleteElementsByElementIdAndType(final int id,final String type); Collection<OnmsMapElement> findElementsByElementIdAndType(
            int elementId, String type); Collection<OnmsMapElement> findElementsByType(String type); OnmsMapElement findElement(int elementId, String type, OnmsMap map); void deleteElementsByMapType(final String mapType); Collection<OnmsMapElement> findElementsByMapIdAndType(int mapId,
            String type); Collection<OnmsMapElement> findMapElementsOnMap(int mapId); Collection<OnmsMapElement> findNodeElementsOnMap(int mapId); int countElementsOnMap(final int mapid);  }