HandleDAOImpl extends AbstractHibernateDAO<Handle> implements HandleDAO { @Override public int updateHandlesWithNewPrefix(Context context, String newPrefix, String oldPrefix) throws SQLException { String hql = "UPDATE Handle set handle = concat(:newPrefix, '/', substring(handle, :oldPrefixLength + 2)) WHERE handle like concat(:oldPrefix,'%')"; Query query = createQuery(context, hql); query.setString("newPrefix", newPrefix); query.setInteger("oldPrefixLength", oldPrefix.length()); query.setString("oldPrefix", oldPrefix); return query.executeUpdate(); } protected  HandleDAOImpl(); @Override List<Handle> getHandlesByDSpaceObject(Context context, DSpaceObject dso); @Override Handle findByHandle(Context context, String handle); @Override List<Handle> findByPrefix(Context context, String prefix); @Override long countHandlesByPrefix(Context context, String prefix); @Override int updateHandlesWithNewPrefix(Context context, String newPrefix, String oldPrefix); @Override int countRows(Context context); @Override Long getNextHandleSuffix(Context context);  }
@Test public void updateHandlesWithNewPrefix() throws Exception { context.turnOffAuthorisationSystem(); String newPrefix = "987654321"; handleDAO.updateHandlesWithNewPrefix(context, newPrefix, HANDLE_PREFIX); context.commit(); assertEquals(newPrefix + "/" + SUFFIX_1, itemService.find(context, item1.getID()).getHandle()); assertEquals(newPrefix + "/" + SUFFIX_2, itemService.find(context, item2.getID()).getHandle()); assertEquals(newPrefix + "/" + SUFFIX_3, itemService.find(context, item3.getID()).getHandle()); assertEquals("hdl:custom-prefix/" + SUFFIX_4, itemService.find(context, item4.getID()).getHandle()); context.restoreAuthSystemState(); }