Example usage for com.liferay.portal.kernel.dao.orm EntityCacheUtil putResult

List of usage examples for com.liferay.portal.kernel.dao.orm EntityCacheUtil putResult

Introduction

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

Prototype

public static void putResult(boolean entityCacheEnabled, Class<?> clazz, Serializable primaryKey,
            Serializable result) 

Source Link

Usage

From source file:at.bibbox.reactjsservice.service.persistence.ToolInformationPersistenceImpl.java

License:Open Source License

/**
 * Caches the tool information in the entity cache if it is enabled.
 *
 * @param toolInformation the tool information
 *///w  w  w. j  ava 2  s.c o  m
@Override
public void cacheResult(ToolInformation toolInformation) {
    EntityCacheUtil.putResult(ToolInformationModelImpl.ENTITY_CACHE_ENABLED, ToolInformationImpl.class,
            toolInformation.getPrimaryKey(), toolInformation);

    toolInformation.resetOriginalValues();
}

From source file:at.bibbox.reactjsservice.service.persistence.ToolInformationPersistenceImpl.java

License:Open Source License

@Override
public ToolInformation updateImpl(at.bibbox.reactjsservice.model.ToolInformation toolInformation)
        throws SystemException {
    toolInformation = toUnwrappedModel(toolInformation);

    boolean isNew = toolInformation.isNew();

    ToolInformationModelImpl toolInformationModelImpl = (ToolInformationModelImpl) toolInformation;

    Session session = null;/*from w w w  . j  a v a  2s . com*/

    try {
        session = openSession();

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

            toolInformation.setNew(false);
        } else {
            session.merge(toolInformation);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ToolInformationModelImpl.COLUMN_BITMASK_ENABLED) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    else {
        if ((toolInformationModelImpl.getColumnBitmask()
                & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORY.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { toolInformationModelImpl.getOriginalCategory() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORY, args);

            args = new Object[] { toolInformationModelImpl.getCategory() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_CATEGORY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_CATEGORY, args);
        }
    }

    EntityCacheUtil.putResult(ToolInformationModelImpl.ENTITY_CACHE_ENABLED, ToolInformationImpl.class,
            toolInformation.getPrimaryKey(), toolInformation);

    return toolInformation;
}

From source file:at.bibbox.reactjsservice.service.persistence.ToolInformationPersistenceImpl.java

License:Open Source License

/**
 * Returns the tool information with the primary key or returns <code>null</code> if it could not be found.
 *
 * @param primaryKey the primary key of the tool information
 * @return the tool information, or <code>null</code> if a tool information with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *///ww  w.  ja  v  a 2 s  . c o m
@Override
public ToolInformation fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    ToolInformation toolInformation = (ToolInformation) EntityCacheUtil
            .getResult(ToolInformationModelImpl.ENTITY_CACHE_ENABLED, ToolInformationImpl.class, primaryKey);

    if (toolInformation == _nullToolInformation) {
        return null;
    }

    if (toolInformation == null) {
        Session session = null;

        try {
            session = openSession();

            toolInformation = (ToolInformation) session.get(ToolInformationImpl.class, primaryKey);

            if (toolInformation != null) {
                cacheResult(toolInformation);
            } else {
                EntityCacheUtil.putResult(ToolInformationModelImpl.ENTITY_CACHE_ENABLED,
                        ToolInformationImpl.class, primaryKey, _nullToolInformation);
            }
        } catch (Exception e) {
            EntityCacheUtil.removeResult(ToolInformationModelImpl.ENTITY_CACHE_ENABLED,
                    ToolInformationImpl.class, primaryKey);

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

    return toolInformation;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Caches the configuration in the entity cache if it is enabled.
 *
 * @param configuration the configuration
 *//*from   w w w . j a  v a2 s .c o  m*/
@Override
public void cacheResult(Configuration configuration) {
    EntityCacheUtil.putResult(ConfigurationModelImpl.ENTITY_CACHE_ENABLED, ConfigurationImpl.class,
            configuration.getPrimaryKey(), configuration);

    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONFINDER,
            new Object[] { configuration.getScope(), configuration.getOptionkey() }, configuration);

    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_OPTIONSFINDERVALUE,
            new Object[] { configuration.getScope(), configuration.getOptionvalue() }, configuration);

    configuration.resetOriginalValues();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

@Override
public Configuration updateImpl(at.graz.hmmc.liferay.portlet.puch.model.Configuration configuration)
        throws SystemException {
    configuration = toUnwrappedModel(configuration);

    boolean isNew = configuration.isNew();

    ConfigurationModelImpl configurationModelImpl = (ConfigurationModelImpl) configuration;

    Session session = null;/*from  ww  w. ja va 2 s . c o  m*/

    try {
        session = openSession();

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

            configuration.setNew(false);
        } else {
            session.merge(configuration);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !ConfigurationModelImpl.COLUMN_BITMASK_ENABLED) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    else {
        if ((configurationModelImpl.getColumnBitmask()
                & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERKEY.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { configurationModelImpl.getOriginalScope(),
                    configurationModelImpl.getOriginalOptionkey() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDERKEY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERKEY, args);

            args = new Object[] { configurationModelImpl.getScope(), configurationModelImpl.getOptionkey() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDERKEY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERKEY, args);
        }

        if ((configurationModelImpl.getColumnBitmask()
                & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDER.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { configurationModelImpl.getOriginalScope() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDER, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDER, args);

            args = new Object[] { configurationModelImpl.getScope() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDER, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDER, args);
        }

        if ((configurationModelImpl.getColumnBitmask()
                & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERFORKEY.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { configurationModelImpl.getOriginalOptionkey() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDERFORKEY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERFORKEY, args);

            args = new Object[] { configurationModelImpl.getOptionkey() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_OPTIONSFINDERFORKEY, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_OPTIONSFINDERFORKEY, args);
        }
    }

    EntityCacheUtil.putResult(ConfigurationModelImpl.ENTITY_CACHE_ENABLED, ConfigurationImpl.class,
            configuration.getPrimaryKey(), configuration);

    clearUniqueFindersCache(configuration);
    cacheUniqueFindersCache(configuration);

    return configuration;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ConfigurationPersistenceImpl.java

License:Open Source License

/**
 * Returns the configuration with the primary key or returns <code>null</code> if it could not be found.
 *
 * @param primaryKey the primary key of the configuration
 * @return the configuration, or <code>null</code> if a configuration with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *//* ww w  .  j  ava 2  s  .  co m*/
@Override
public Configuration fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    Configuration configuration = (Configuration) EntityCacheUtil
            .getResult(ConfigurationModelImpl.ENTITY_CACHE_ENABLED, ConfigurationImpl.class, primaryKey);

    if (configuration == _nullConfiguration) {
        return null;
    }

    if (configuration == null) {
        Session session = null;

        try {
            session = openSession();

            configuration = (Configuration) session.get(ConfigurationImpl.class, primaryKey);

            if (configuration != null) {
                cacheResult(configuration);
            } else {
                EntityCacheUtil.putResult(ConfigurationModelImpl.ENTITY_CACHE_ENABLED, ConfigurationImpl.class,
                        primaryKey, _nullConfiguration);
            }
        } catch (Exception e) {
            EntityCacheUtil.removeResult(ConfigurationModelImpl.ENTITY_CACHE_ENABLED, ConfigurationImpl.class,
                    primaryKey);

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

    return configuration;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.FahrzeugPersistenceImpl.java

License:Open Source License

/**
 * Caches the fahrzeug in the entity cache if it is enabled.
 *
 * @param fahrzeug the fahrzeug/*  ww w  .j  a  v  a 2s.c  o m*/
 */
@Override
public void cacheResult(Fahrzeug fahrzeug) {
    EntityCacheUtil.putResult(FahrzeugModelImpl.ENTITY_CACHE_ENABLED, FahrzeugImpl.class,
            fahrzeug.getPrimaryKey(), fahrzeug);

    fahrzeug.resetOriginalValues();
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.FahrzeugPersistenceImpl.java

License:Open Source License

@Override
public Fahrzeug updateImpl(at.graz.hmmc.liferay.portlet.puch.model.Fahrzeug fahrzeug) throws SystemException {
    fahrzeug = toUnwrappedModel(fahrzeug);

    boolean isNew = fahrzeug.isNew();

    FahrzeugModelImpl fahrzeugModelImpl = (FahrzeugModelImpl) fahrzeug;

    Session session = null;/* www .ja v a  2 s.  c o  m*/

    try {
        session = openSession();

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

            fahrzeug.setNew(false);
        } else {
            session.merge(fahrzeug);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);

    if (isNew || !FahrzeugModelImpl.COLUMN_BITMASK_ENABLED) {
        FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
    }

    else {
        if ((fahrzeugModelImpl.getColumnBitmask()
                & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYP.getColumnBitmask()) != 0) {
            Object[] args = new Object[] { fahrzeugModelImpl.getOriginalTyp() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYP, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYP, args);

            args = new Object[] { fahrzeugModelImpl.getTyp() };

            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_TYP, args);
            FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_TYP, args);
        }
    }

    EntityCacheUtil.putResult(FahrzeugModelImpl.ENTITY_CACHE_ENABLED, FahrzeugImpl.class,
            fahrzeug.getPrimaryKey(), fahrzeug);

    return fahrzeug;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.FahrzeugPersistenceImpl.java

License:Open Source License

/**
 * Returns the fahrzeug with the primary key or returns <code>null</code> if it could not be found.
 *
 * @param primaryKey the primary key of the fahrzeug
 * @return the fahrzeug, or <code>null</code> if a fahrzeug with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *//*from  w ww .  j a  v a2s . c  o m*/
@Override
public Fahrzeug fetchByPrimaryKey(Serializable primaryKey) throws SystemException {
    Fahrzeug fahrzeug = (Fahrzeug) EntityCacheUtil.getResult(FahrzeugModelImpl.ENTITY_CACHE_ENABLED,
            FahrzeugImpl.class, primaryKey);

    if (fahrzeug == _nullFahrzeug) {
        return null;
    }

    if (fahrzeug == null) {
        Session session = null;

        try {
            session = openSession();

            fahrzeug = (Fahrzeug) session.get(FahrzeugImpl.class, primaryKey);

            if (fahrzeug != null) {
                cacheResult(fahrzeug);
            } else {
                EntityCacheUtil.putResult(FahrzeugModelImpl.ENTITY_CACHE_ENABLED, FahrzeugImpl.class,
                        primaryKey, _nullFahrzeug);
            }
        } catch (Exception e) {
            EntityCacheUtil.removeResult(FahrzeugModelImpl.ENTITY_CACHE_ENABLED, FahrzeugImpl.class,
                    primaryKey);

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

    return fahrzeug;
}

From source file:at.graz.hmmc.liferay.portlet.puch.service.persistence.ObjectDataPersistenceImpl.java

License:Open Source License

/**
 * Caches the object data in the entity cache if it is enabled.
 *
 * @param objectData the object data/*from w ww  .  ja  va 2s.c  o m*/
 */
@Override
public void cacheResult(ObjectData objectData) {
    EntityCacheUtil.putResult(ObjectDataModelImpl.ENTITY_CACHE_ENABLED, ObjectDataImpl.class,
            objectData.getPrimaryKey(), objectData);

    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DATABYONTOLOGY,
            new Object[] { objectData.getPuchmuseumsobjectId(), objectData.getObjectkey() }, objectData);

    objectData.resetOriginalValues();
}