Example usage for com.liferay.portal.kernel.dao.orm Query iterate

List of usage examples for com.liferay.portal.kernel.dao.orm Query iterate

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.dao.orm Query iterate.

Prototype

@SuppressWarnings("rawtypes")
    public Iterator iterate() throws ORMException;

Source Link

Usage

From source file:com.liferay.mail.service.persistence.CyrusVirtualPersistenceImpl.java

License:Open Source License

public void removeByUserId(long userId) throws SystemException {
    Session session = null;/*w  ww  .  j  ava  2  s.  c o m*/

    try {
        session = openSession();

        Query q = session.createQuery(FIND_BY_USER_ID);

        q.setString(0, String.valueOf(userId));

        Iterator<CyrusVirtual> itr = q.iterate();

        while (itr.hasNext()) {
            CyrusVirtual virtual = itr.next();

            session.delete(virtual);
        }

        closeSession(session);
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}