All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.liferay.portal.service.persistence.impl.WebDAVPropsPersistenceImpl Maven / Gradle / Ivy

There is a newer version: 7.4.3.112-ga112
Show newest version
/**
 * Copyright (c) 2000-present Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package com.liferay.portal.service.persistence.impl;

import aQute.bnd.annotation.ProviderType;

import com.liferay.portal.kernel.bean.BeanReference;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.NoSuchWebDAVPropsException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.WebDAVProps;
import com.liferay.portal.kernel.service.ServiceContext;
import com.liferay.portal.kernel.service.ServiceContextThreadLocal;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.WebDAVPropsPersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.WebDAVPropsImpl;
import com.liferay.portal.model.impl.WebDAVPropsModelImpl;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;

/**
 * The persistence implementation for the web dav props service.
 *
 * 

* Caching information and settings can be found in portal.properties *

* * @author Brian Wing Shun Chan * @generated */ @ProviderType public class WebDAVPropsPersistenceImpl extends BasePersistenceImpl implements WebDAVPropsPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use WebDAVPropsUtil to access the web dav props persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = WebDAVPropsImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathFetchByC_C; private FinderPath _finderPathCountByC_C; /** * Returns the web dav props where classNameId = ? and classPK = ? or throws a NoSuchWebDAVPropsException if it could not be found. * * @param classNameId the class name ID * @param classPK the class pk * @return the matching web dav props * @throws NoSuchWebDAVPropsException if a matching web dav props could not be found */ @Override public WebDAVProps findByC_C(long classNameId, long classPK) throws NoSuchWebDAVPropsException { WebDAVProps webDAVProps = fetchByC_C(classNameId, classPK); if (webDAVProps == null) { StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("classNameId="); msg.append(classNameId); msg.append(", classPK="); msg.append(classPK); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchWebDAVPropsException(msg.toString()); } return webDAVProps; } /** * Returns the web dav props where classNameId = ? and classPK = ? or returns null if it could not be found. Uses the finder cache. * * @param classNameId the class name ID * @param classPK the class pk * @return the matching web dav props, or null if a matching web dav props could not be found */ @Override public WebDAVProps fetchByC_C(long classNameId, long classPK) { return fetchByC_C(classNameId, classPK, true); } /** * Returns the web dav props where classNameId = ? and classPK = ? or returns null if it could not be found, optionally using the finder cache. * * @param classNameId the class name ID * @param classPK the class pk * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching web dav props, or null if a matching web dav props could not be found */ @Override public WebDAVProps fetchByC_C( long classNameId, long classPK, boolean retrieveFromCache) { Object[] finderArgs = new Object[] {classNameId, classPK}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult( _finderPathFetchByC_C, finderArgs, this); } if (result instanceof WebDAVProps) { WebDAVProps webDAVProps = (WebDAVProps)result; if ((classNameId != webDAVProps.getClassNameId()) || (classPK != webDAVProps.getClassPK())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(4); query.append(_SQL_SELECT_WEBDAVPROPS_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); List list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult( _finderPathFetchByC_C, finderArgs, list); } else { WebDAVProps webDAVProps = list.get(0); result = webDAVProps; cacheResult(webDAVProps); } } catch (Exception e) { FinderCacheUtil.removeResult(_finderPathFetchByC_C, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (WebDAVProps)result; } } /** * Removes the web dav props where classNameId = ? and classPK = ? from the database. * * @param classNameId the class name ID * @param classPK the class pk * @return the web dav props that was removed */ @Override public WebDAVProps removeByC_C(long classNameId, long classPK) throws NoSuchWebDAVPropsException { WebDAVProps webDAVProps = findByC_C(classNameId, classPK); return remove(webDAVProps); } /** * Returns the number of web dav propses where classNameId = ? and classPK = ?. * * @param classNameId the class name ID * @param classPK the class pk * @return the number of matching web dav propses */ @Override public int countByC_C(long classNameId, long classPK) { FinderPath finderPath = _finderPathCountByC_C; Object[] finderArgs = new Object[] {classNameId, classPK}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_WEBDAVPROPS_WHERE); query.append(_FINDER_COLUMN_C_C_CLASSNAMEID_2); query.append(_FINDER_COLUMN_C_C_CLASSPK_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(classNameId); qPos.add(classPK); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_C_C_CLASSNAMEID_2 = "webDAVProps.classNameId = ? AND "; private static final String _FINDER_COLUMN_C_C_CLASSPK_2 = "webDAVProps.classPK = ?"; public WebDAVPropsPersistenceImpl() { setModelClass(WebDAVProps.class); } /** * Caches the web dav props in the entity cache if it is enabled. * * @param webDAVProps the web dav props */ @Override public void cacheResult(WebDAVProps webDAVProps) { EntityCacheUtil.putResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps); FinderCacheUtil.putResult( _finderPathFetchByC_C, new Object[] { webDAVProps.getClassNameId(), webDAVProps.getClassPK() }, webDAVProps); webDAVProps.resetOriginalValues(); } /** * Caches the web dav propses in the entity cache if it is enabled. * * @param webDAVPropses the web dav propses */ @Override public void cacheResult(List webDAVPropses) { for (WebDAVProps webDAVProps : webDAVPropses) { if (EntityCacheUtil.getResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()) == null) { cacheResult(webDAVProps); } else { webDAVProps.resetOriginalValues(); } } } /** * Clears the cache for all web dav propses. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache() { EntityCacheUtil.clearCache(WebDAVPropsImpl.class); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the web dav props. * *

* The com.liferay.portal.kernel.dao.orm.EntityCache and com.liferay.portal.kernel.dao.orm.FinderCache are both cleared by this method. *

*/ @Override public void clearCache(WebDAVProps webDAVProps) { EntityCacheUtil.removeResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((WebDAVPropsModelImpl)webDAVProps, true); } @Override public void clearCache(List webDAVPropses) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (WebDAVProps webDAVProps : webDAVPropses) { EntityCacheUtil.removeResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey()); clearUniqueFindersCache((WebDAVPropsModelImpl)webDAVProps, true); } } protected void cacheUniqueFindersCache( WebDAVPropsModelImpl webDAVPropsModelImpl) { Object[] args = new Object[] { webDAVPropsModelImpl.getClassNameId(), webDAVPropsModelImpl.getClassPK() }; FinderCacheUtil.putResult( _finderPathCountByC_C, args, Long.valueOf(1), false); FinderCacheUtil.putResult( _finderPathFetchByC_C, args, webDAVPropsModelImpl, false); } protected void clearUniqueFindersCache( WebDAVPropsModelImpl webDAVPropsModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { webDAVPropsModelImpl.getClassNameId(), webDAVPropsModelImpl.getClassPK() }; FinderCacheUtil.removeResult(_finderPathCountByC_C, args); FinderCacheUtil.removeResult(_finderPathFetchByC_C, args); } if ((webDAVPropsModelImpl.getColumnBitmask() & _finderPathFetchByC_C.getColumnBitmask()) != 0) { Object[] args = new Object[] { webDAVPropsModelImpl.getOriginalClassNameId(), webDAVPropsModelImpl.getOriginalClassPK() }; FinderCacheUtil.removeResult(_finderPathCountByC_C, args); FinderCacheUtil.removeResult(_finderPathFetchByC_C, args); } } /** * Creates a new web dav props with the primary key. Does not add the web dav props to the database. * * @param webDavPropsId the primary key for the new web dav props * @return the new web dav props */ @Override public WebDAVProps create(long webDavPropsId) { WebDAVProps webDAVProps = new WebDAVPropsImpl(); webDAVProps.setNew(true); webDAVProps.setPrimaryKey(webDavPropsId); webDAVProps.setCompanyId(companyProvider.getCompanyId()); return webDAVProps; } /** * Removes the web dav props with the primary key from the database. Also notifies the appropriate model listeners. * * @param webDavPropsId the primary key of the web dav props * @return the web dav props that was removed * @throws NoSuchWebDAVPropsException if a web dav props with the primary key could not be found */ @Override public WebDAVProps remove(long webDavPropsId) throws NoSuchWebDAVPropsException { return remove((Serializable)webDavPropsId); } /** * Removes the web dav props with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the web dav props * @return the web dav props that was removed * @throws NoSuchWebDAVPropsException if a web dav props with the primary key could not be found */ @Override public WebDAVProps remove(Serializable primaryKey) throws NoSuchWebDAVPropsException { Session session = null; try { session = openSession(); WebDAVProps webDAVProps = (WebDAVProps)session.get( WebDAVPropsImpl.class, primaryKey); if (webDAVProps == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchWebDAVPropsException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(webDAVProps); } catch (NoSuchWebDAVPropsException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected WebDAVProps removeImpl(WebDAVProps webDAVProps) { Session session = null; try { session = openSession(); if (!session.contains(webDAVProps)) { webDAVProps = (WebDAVProps)session.get( WebDAVPropsImpl.class, webDAVProps.getPrimaryKeyObj()); } if (webDAVProps != null) { session.delete(webDAVProps); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (webDAVProps != null) { clearCache(webDAVProps); } return webDAVProps; } @Override public WebDAVProps updateImpl(WebDAVProps webDAVProps) { boolean isNew = webDAVProps.isNew(); if (!(webDAVProps instanceof WebDAVPropsModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(webDAVProps.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler(webDAVProps); throw new IllegalArgumentException( "Implement ModelWrapper in webDAVProps proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom WebDAVProps implementation " + webDAVProps.getClass()); } WebDAVPropsModelImpl webDAVPropsModelImpl = (WebDAVPropsModelImpl)webDAVProps; ServiceContext serviceContext = ServiceContextThreadLocal.getServiceContext(); Date now = new Date(); if (isNew && (webDAVProps.getCreateDate() == null)) { if (serviceContext == null) { webDAVProps.setCreateDate(now); } else { webDAVProps.setCreateDate(serviceContext.getCreateDate(now)); } } if (!webDAVPropsModelImpl.hasSetModifiedDate()) { if (serviceContext == null) { webDAVProps.setModifiedDate(now); } else { webDAVProps.setModifiedDate( serviceContext.getModifiedDate(now)); } } Session session = null; try { session = openSession(); if (webDAVProps.isNew()) { session.save(webDAVProps); webDAVProps.setNew(false); } else { webDAVProps = (WebDAVProps)session.merge(webDAVProps); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!WebDAVPropsModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } EntityCacheUtil.putResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, webDAVProps.getPrimaryKey(), webDAVProps, false); clearUniqueFindersCache(webDAVPropsModelImpl, false); cacheUniqueFindersCache(webDAVPropsModelImpl); webDAVProps.resetOriginalValues(); return webDAVProps; } /** * Returns the web dav props with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found. * * @param primaryKey the primary key of the web dav props * @return the web dav props * @throws NoSuchWebDAVPropsException if a web dav props with the primary key could not be found */ @Override public WebDAVProps findByPrimaryKey(Serializable primaryKey) throws NoSuchWebDAVPropsException { WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey); if (webDAVProps == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchWebDAVPropsException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return webDAVProps; } /** * Returns the web dav props with the primary key or throws a NoSuchWebDAVPropsException if it could not be found. * * @param webDavPropsId the primary key of the web dav props * @return the web dav props * @throws NoSuchWebDAVPropsException if a web dav props with the primary key could not be found */ @Override public WebDAVProps findByPrimaryKey(long webDavPropsId) throws NoSuchWebDAVPropsException { return findByPrimaryKey((Serializable)webDavPropsId); } /** * Returns the web dav props with the primary key or returns null if it could not be found. * * @param primaryKey the primary key of the web dav props * @return the web dav props, or null if a web dav props with the primary key could not be found */ @Override public WebDAVProps fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = EntityCacheUtil.getResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, primaryKey); if (serializable == nullModel) { return null; } WebDAVProps webDAVProps = (WebDAVProps)serializable; if (webDAVProps == null) { Session session = null; try { session = openSession(); webDAVProps = (WebDAVProps)session.get( WebDAVPropsImpl.class, primaryKey); if (webDAVProps != null) { cacheResult(webDAVProps); } else { EntityCacheUtil.putResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, primaryKey, nullModel); } } catch (Exception e) { EntityCacheUtil.removeResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return webDAVProps; } /** * Returns the web dav props with the primary key or returns null if it could not be found. * * @param webDavPropsId the primary key of the web dav props * @return the web dav props, or null if a web dav props with the primary key could not be found */ @Override public WebDAVProps fetchByPrimaryKey(long webDavPropsId) { return fetchByPrimaryKey((Serializable)webDavPropsId); } @Override public Map fetchByPrimaryKeys( Set primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); WebDAVProps webDAVProps = fetchByPrimaryKey(primaryKey); if (webDAVProps != null) { map.put(primaryKey, webDAVProps); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = EntityCacheUtil.getResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (WebDAVProps)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler( uncachedPrimaryKeys.size() * 2 + 1); query.append(_SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(","); } query.setIndex(query.index() - 1); query.append(")"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (WebDAVProps webDAVProps : (List)q.list()) { map.put(webDAVProps.getPrimaryKeyObj(), webDAVProps); cacheResult(webDAVProps); uncachedPrimaryKeys.remove(webDAVProps.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the web dav propses. * * @return the web dav propses */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the web dav propses. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from WebDAVPropsModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of web dav propses * @param end the upper bound of the range of web dav propses (not inclusive) * @return the range of web dav propses */ @Override public List findAll(int start, int end) { return findAll(start, end, null); } /** * Returns an ordered range of all the web dav propses. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from WebDAVPropsModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of web dav propses * @param end the upper bound of the range of web dav propses (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of web dav propses */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator) { return findAll(start, end, orderByComparator, true); } /** * Returns an ordered range of all the web dav propses. * *

* Useful when paginating results. Returns a maximum of end - start instances. start and end are not primary keys, they are indexes in the result set. Thus, 0 refers to the first result in the set. Setting both start and end to QueryUtil#ALL_POS will return the full result set. If orderByComparator is specified, then the query will include the given ORDER BY logic. If orderByComparator is absent and pagination is required (start and end are not QueryUtil#ALL_POS), then the query will include the default ORDER BY logic from WebDAVPropsModelImpl. If both orderByComparator and pagination are absent, for performance reasons, the query will not have an ORDER BY clause and the returned result set will be sorted on by the primary key in an ascending order. *

* * @param start the lower bound of the range of web dav propses * @param end the upper bound of the range of web dav propses (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of web dav propses */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_WEBDAVPROPS); appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_WEBDAVPROPS; if (pagination) { sql = sql.concat(WebDAVPropsModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the web dav propses from the database. * */ @Override public void removeAll() { for (WebDAVProps webDAVProps : findAll()) { remove(webDAVProps); } } /** * Returns the number of web dav propses. * * @return the number of web dav propses */ @Override public int countAll() { Long count = (Long)FinderCacheUtil.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_WEBDAVPROPS); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override protected Map getTableColumnsMap() { return WebDAVPropsModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the web dav props persistence. */ public void afterPropertiesSet() { _finderPathWithPaginationFindAll = new FinderPath( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathFetchByC_C = new FinderPath( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, WebDAVPropsImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByC_C", new String[] {Long.class.getName(), Long.class.getName()}, WebDAVPropsModelImpl.CLASSNAMEID_COLUMN_BITMASK | WebDAVPropsModelImpl.CLASSPK_COLUMN_BITMASK); _finderPathCountByC_C = new FinderPath( WebDAVPropsModelImpl.ENTITY_CACHE_ENABLED, WebDAVPropsModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_C", new String[] {Long.class.getName(), Long.class.getName()}); } public void destroy() { EntityCacheUtil.removeCache(WebDAVPropsImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; private static final String _SQL_SELECT_WEBDAVPROPS = "SELECT webDAVProps FROM WebDAVProps webDAVProps"; private static final String _SQL_SELECT_WEBDAVPROPS_WHERE_PKS_IN = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE webDavPropsId IN ("; private static final String _SQL_SELECT_WEBDAVPROPS_WHERE = "SELECT webDAVProps FROM WebDAVProps webDAVProps WHERE "; private static final String _SQL_COUNT_WEBDAVPROPS = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps"; private static final String _SQL_COUNT_WEBDAVPROPS_WHERE = "SELECT COUNT(webDAVProps) FROM WebDAVProps webDAVProps WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "webDAVProps."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WebDAVProps exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WebDAVProps exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( WebDAVPropsPersistenceImpl.class); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy