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

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

Introduction

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

Prototype

public void evict(Object object) throws ORMException;

Source Link

Usage

From source file:cn.zoneco.openplatform.service.persistence.AttachmentInfoPersistenceImpl.java

License:Open Source License

@Override
public AttachmentInfo updateImpl(cn.zoneco.openplatform.model.AttachmentInfo attachmentInfo)
        throws SystemException {
    attachmentInfo = toUnwrappedModel(attachmentInfo);

    boolean isNew = attachmentInfo.isNew();

    Session session = null;

    try {// ww w . j a va  2 s  . c o m
        session = openSession();

        if (attachmentInfo.isNew()) {
            session.save(attachmentInfo);

            attachmentInfo.setNew(false);
        } else {
            session.evict(attachmentInfo);
            session.saveOrUpdate(attachmentInfo);
        }

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    EntityCacheUtil.putResult(AttachmentInfoModelImpl.ENTITY_CACHE_ENABLED, AttachmentInfoImpl.class,
            attachmentInfo.getPrimaryKey(), attachmentInfo);

    attachmentInfo.resetOriginalValues();

    return attachmentInfo;
}

From source file:com.coleg.service.persistence.CustomerPersistenceImpl.java

License:Open Source License

protected Customer removeImpl(Customer customer) throws SystemException {
    customer = toUnwrappedModel(customer);

    Session session = null;

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

        if (customer.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(CustomerImpl.class, customer.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(customer);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(CustomerModelImpl.ENTITY_CACHE_ENABLED, CustomerImpl.class,
            customer.getPrimaryKey());

    return customer;
}

From source file:com.coleg.service.persistence.EmployeePersistenceImpl.java

License:Open Source License

protected Employee removeImpl(Employee employee) throws SystemException {
    employee = toUnwrappedModel(employee);

    Session session = null;

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

        if (employee.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(EmployeeImpl.class, employee.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(employee);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(EmployeeModelImpl.ENTITY_CACHE_ENABLED, EmployeeImpl.class,
            employee.getPrimaryKey());

    return employee;
}

From source file:com.coleg.service.persistence.EmpPersistenceImpl.java

License:Open Source License

protected Emp removeImpl(Emp emp) throws SystemException {
    emp = toUnwrappedModel(emp);//w w  w.j a va 2s.  c om

    Session session = null;

    try {
        session = openSession();

        if (emp.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(EmpImpl.class, emp.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(emp);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(EmpModelImpl.ENTITY_CACHE_ENABLED, EmpImpl.class, emp.getPrimaryKey());

    return emp;
}

From source file:com.coleg.service.persistence.FooPersistenceImpl.java

License:Open Source License

@Override
protected Foo removeImpl(Foo foo) throws SystemException {
    foo = toUnwrappedModel(foo);/*from   w w  w.j  av  a 2s. c  om*/

    Session session = null;

    try {
        session = openSession();

        if (foo.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(FooImpl.class, foo.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(foo);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(FooModelImpl.ENTITY_CACHE_ENABLED, FooImpl.class, foo.getPrimaryKey());

    return foo;
}

From source file:com.commsen.liferay.multidevice.rules.service.persistence.RulePersistenceImpl.java

License:Open Source License

protected Rule removeImpl(Rule rule) throws SystemException {
    rule = toUnwrappedModel(rule);//from w  w w .  j a  va  2  s.com

    Session session = null;

    try {
        session = openSession();

        if (rule.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(RuleImpl.class, rule.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(rule);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(RuleModelImpl.ENTITY_CACHE_ENABLED, RuleImpl.class, rule.getPrimaryKey());

    return rule;
}

From source file:com.commsen.sample.portlet.chatrooms.service.persistence.MessagePersistenceImpl.java

License:Open Source License

protected Message removeImpl(Message message) throws SystemException {
    message = toUnwrappedModel(message);

    Session session = null;

    try {/*  ww w .j  a va2  s.c  o  m*/
        session = openSession();

        if (message.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(MessageImpl.class, message.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(message);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(MessageModelImpl.ENTITY_CACHE_ENABLED, MessageImpl.class,
            message.getPrimaryKey());

    return message;
}

From source file:com.edujini.incoleg.video.service.persistence.StoreSettingsPersistenceImpl.java

License:Open Source License

protected StoreSettings removeImpl(StoreSettings storeSettings) throws SystemException {
    storeSettings = toUnwrappedModel(storeSettings);

    Session session = null;

    try {//  w ww . j a va  2  s  .  co  m
        session = openSession();

        if (storeSettings.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(StoreSettingsImpl.class, storeSettings.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(storeSettings);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(StoreSettingsModelImpl.ENTITY_CACHE_ENABLED, StoreSettingsImpl.class,
            storeSettings.getPrimaryKey());

    return storeSettings;
}

From source file:com.edujini.incoleg.video.service.persistence.VideoInfoPersistenceImpl.java

License:Open Source License

protected VideoInfo removeImpl(VideoInfo videoInfo) throws SystemException {
    videoInfo = toUnwrappedModel(videoInfo);

    Session session = null;

    try {//from   w  w w .  j av  a  2 s. c o m
        session = openSession();

        if (videoInfo.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(VideoInfoImpl.class, videoInfo.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(videoInfo);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    VideoInfoModelImpl videoInfoModelImpl = (VideoInfoModelImpl) videoInfo;

    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_FILENAME,
            new Object[] { videoInfoModelImpl.getOriginalMappedFileName() });

    EntityCacheUtil.removeResult(VideoInfoModelImpl.ENTITY_CACHE_ENABLED, VideoInfoImpl.class,
            videoInfo.getPrimaryKey());

    return videoInfo;
}

From source file:com.edujini.incoleg.video.service.persistence.VOMapPersistenceImpl.java

License:Open Source License

protected VOMap removeImpl(VOMap voMap) throws SystemException {
    voMap = toUnwrappedModel(voMap);//from ww w.  ja  v  a  2s .c o  m

    Session session = null;

    try {
        session = openSession();

        if (voMap.isCachedModel() || BatchSessionUtil.isEnabled()) {
            Object staleObject = session.get(VOMapImpl.class, voMap.getPrimaryKeyObj());

            if (staleObject != null) {
                session.evict(staleObject);
            }
        }

        session.delete(voMap);

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

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);

    EntityCacheUtil.removeResult(VOMapModelImpl.ENTITY_CACHE_ENABLED, VOMapImpl.class, voMap.getPrimaryKey());

    return voMap;
}