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

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

Introduction

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

Prototype

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

Source Link

Usage

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

License:Open Source License

/**
 * Removes the tool information with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the tool information
 * @return the tool information that was removed
 * @throws at.bibbox.reactjsservice.NoSuchToolInformationException if a tool information with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *///  ww  w  .j a  va  2 s .  c o m
@Override
public ToolInformation remove(Serializable primaryKey) throws NoSuchToolInformationException, SystemException {
    Session session = null;

    try {
        session = openSession();

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

        if (toolInformation == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchToolInformationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        return remove(toolInformation);
    } catch (NoSuchToolInformationException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

@Override
protected ToolInformation removeImpl(ToolInformation toolInformation) throws SystemException {
    toolInformation = toUnwrappedModel(toolInformation);

    Session session = null;

    try {//from w  ww .j a  v a  2s .  c om
        session = openSession();

        if (!session.contains(toolInformation)) {
            toolInformation = (ToolInformation) session.get(ToolInformationImpl.class,
                    toolInformation.getPrimaryKeyObj());
        }

        if (toolInformation != null) {
            session.delete(toolInformation);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    if (toolInformation != null) {
        clearCache(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
 *//*from   w  w w  . j  ava2s . com*/
@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

/**
 * Removes the configuration with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the configuration
 * @return the configuration that was removed
 * @throws at.graz.hmmc.liferay.portlet.puch.NoSuchConfigurationException if a configuration with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *///from  ww w  .jav a 2s . c  om
@Override
public Configuration remove(Serializable primaryKey) throws NoSuchConfigurationException, SystemException {
    Session session = null;

    try {
        session = openSession();

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

        if (configuration == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchConfigurationException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        return remove(configuration);
    } catch (NoSuchConfigurationException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

@Override
protected Configuration removeImpl(Configuration configuration) throws SystemException {
    configuration = toUnwrappedModel(configuration);

    Session session = null;

    try {/*from  ww  w.j a v  a  2  s  .c om*/
        session = openSession();

        if (!session.contains(configuration)) {
            configuration = (Configuration) session.get(ConfigurationImpl.class,
                    configuration.getPrimaryKeyObj());
        }

        if (configuration != null) {
            session.delete(configuration);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    if (configuration != null) {
        clearCache(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 .  ja  v a  2 s  . com*/
@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

/**
 * Removes the fahrzeug with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the fahrzeug
 * @return the fahrzeug that was removed
 * @throws at.graz.hmmc.liferay.portlet.puch.NoSuchFahrzeugException if a fahrzeug with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *//* w ww .jav  a 2s  .  com*/
@Override
public Fahrzeug remove(Serializable primaryKey) throws NoSuchFahrzeugException, SystemException {
    Session session = null;

    try {
        session = openSession();

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

        if (fahrzeug == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchFahrzeugException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        return remove(fahrzeug);
    } catch (NoSuchFahrzeugException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}

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

License:Open Source License

@Override
protected Fahrzeug removeImpl(Fahrzeug fahrzeug) throws SystemException {
    fahrzeug = toUnwrappedModel(fahrzeug);

    Session session = null;

    try {/*w  ww. ja  v a2  s  .com*/
        session = openSession();

        if (!session.contains(fahrzeug)) {
            fahrzeug = (Fahrzeug) session.get(FahrzeugImpl.class, fahrzeug.getPrimaryKeyObj());
        }

        if (fahrzeug != null) {
            session.delete(fahrzeug);
        }
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }

    if (fahrzeug != null) {
        clearCache(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
 */// w  w  w  .  j  a  v a  2 s.  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

/**
 * Removes the object data with the primary key from the database. Also notifies the appropriate model listeners.
 *
 * @param primaryKey the primary key of the object data
 * @return the object data that was removed
 * @throws at.graz.hmmc.liferay.portlet.puch.NoSuchObjectDataException if a object data with the primary key could not be found
 * @throws SystemException if a system exception occurred
 *///from   ww w . j  a v  a 2 s. co  m
@Override
public ObjectData remove(Serializable primaryKey) throws NoSuchObjectDataException, SystemException {
    Session session = null;

    try {
        session = openSession();

        ObjectData objectData = (ObjectData) session.get(ObjectDataImpl.class, primaryKey);

        if (objectData == null) {
            if (_log.isWarnEnabled()) {
                _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
            }

            throw new NoSuchObjectDataException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
        }

        return remove(objectData);
    } catch (NoSuchObjectDataException nsee) {
        throw nsee;
    } catch (Exception e) {
        throw processException(e);
    } finally {
        closeSession(session);
    }
}