Example usage for com.liferay.portal.kernel.dao.orm Session load

List of usage examples for com.liferay.portal.kernel.dao.orm Session load

Introduction

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

Prototype

public Object load(Class<?> clazz, Serializable id) throws ORMException;

Source Link

Usage

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

License:Open Source License

public CyrusUser findByPrimaryKey(long userId) throws NoSuchCyrusUserException, SystemException {

    Session session = null;

    try {/*from  w w w. ja va 2s  . co  m*/
        session = openSession();

        return (CyrusUser) session.load(CyrusUser.class, String.valueOf(userId));
    } catch (ObjectNotFoundException onfe) {
        throw new NoSuchCyrusUserException();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

public void remove(long userId) throws NoSuchCyrusUserException, SystemException {

    Session session = null;

    try {/* www  . j a  v a 2 s.co  m*/
        session = openSession();

        CyrusUser user = (CyrusUser) session.load(CyrusUser.class, String.valueOf(userId));

        session.delete(user);

        session.flush();
    } catch (ObjectNotFoundException onfe) {
        throw new NoSuchCyrusUserException();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

public void update(CyrusUser user) throws SystemException {
    Session session = null;

    try {/*from  w  ww.  j  a v a2s.com*/
        session = openSession();

        try {
            CyrusUser userModel = (CyrusUser) session.load(CyrusUser.class, String.valueOf(user.getUserId()));

            userModel.setPassword(user.getPassword());

            session.flush();
        } catch (ObjectNotFoundException onfe) {
            CyrusUser userModel = new CyrusUser(user.getUserId(), user.getPassword());

            session.save(userModel);

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

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

License:Open Source License

public CyrusVirtual findByPrimaryKey(String emailAddress) throws NoSuchCyrusVirtualException, SystemException {

    Session session = null;

    try {//from   w w w.j  ava2  s .  c om
        session = openSession();

        return (CyrusVirtual) session.load(CyrusVirtual.class, emailAddress);
    } catch (ObjectNotFoundException onfe) {
        throw new NoSuchCyrusVirtualException();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

public void remove(String emailAddress) throws NoSuchCyrusVirtualException, SystemException {

    Session session = null;

    try {/*w w  w .  ja v  a  2  s. c o  m*/
        session = openSession();

        CyrusVirtual virtual = (CyrusVirtual) session.load(CyrusVirtual.class, emailAddress);

        session.delete(virtual);

        session.flush();
    } catch (ObjectNotFoundException onfe) {
        throw new NoSuchCyrusVirtualException();
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

public void update(CyrusVirtual virtual) throws SystemException {
    Session session = null;

    try {//from w w  w .j  av a2  s . c om
        session = openSession();

        try {
            CyrusVirtual virtualModel = (CyrusVirtual) session.load(CyrusVirtual.class,
                    virtual.getEmailAddress());

            virtualModel.setUserId(virtual.getUserId());

            session.flush();
        } catch (ObjectNotFoundException onfe) {
            CyrusVirtual virtualModel = new CyrusVirtual(virtual.getEmailAddress(), virtual.getUserId());

            session.save(virtualModel);

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