--- /dev/null
+/**
+ * Copyright (c) 2000-2012 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.pentila.entSavoie.cartable.service.persistence;
+
+import com.liferay.portal.NoSuchModelException;
+import com.liferay.portal.kernel.bean.BeanReference;
+import com.liferay.portal.kernel.cache.CacheRegistryUtil;
+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.SystemException;
+import com.liferay.portal.kernel.log.Log;
+import com.liferay.portal.kernel.log.LogFactoryUtil;
+import com.liferay.portal.kernel.portlet.PortletClassLoaderUtil;
+import com.liferay.portal.kernel.util.GetterUtil;
+import com.liferay.portal.kernel.util.InstanceFactory;
+import com.liferay.portal.kernel.util.OrderByComparator;
+import com.liferay.portal.kernel.util.PropsKeys;
+import com.liferay.portal.kernel.util.PropsUtil;
+import com.liferay.portal.kernel.util.StringBundler;
+import com.liferay.portal.kernel.util.StringPool;
+import com.liferay.portal.kernel.util.StringUtil;
+import com.liferay.portal.model.CacheModel;
+import com.liferay.portal.model.ModelListener;
+import com.liferay.portal.service.persistence.BatchSessionUtil;
+import com.liferay.portal.service.persistence.ResourcePersistence;
+import com.liferay.portal.service.persistence.UserPersistence;
+import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
+
+import com.pentila.entSavoie.cartable.NoSuchFileTagException;
+import com.pentila.entSavoie.cartable.model.FileTag;
+import com.pentila.entSavoie.cartable.model.impl.FileTagImpl;
+import com.pentila.entSavoie.cartable.model.impl.FileTagModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The persistence implementation for the file tag service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author Barma Igor - Amblard Mathieu
+ * @see FileTagPersistence
+ * @see FileTagUtil
+ * @generated
+ */
+public class FileTagPersistenceImpl extends BasePersistenceImpl<FileTag>
+ implements FileTagPersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link FileTagUtil} to access the file tag persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = FileTagImpl.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";
+ public static final FinderPath FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG = new FinderPath(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagModelImpl.FINDER_CACHE_ENABLED, FileTagImpl.class,
+ FINDER_CLASS_NAME_ENTITY, "fetchBydlFileEntryId_tag",
+ new String[] { Long.class.getName() },
+ FileTagModelImpl.DLFILEENTRYID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_DLFILEENTRYID_TAG = new FinderPath(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION,
+ "countBydlFileEntryId_tag", new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagModelImpl.FINDER_CACHE_ENABLED, FileTagImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagModelImpl.FINDER_CACHE_ENABLED, FileTagImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the file tag in the entity cache if it is enabled.
+ *
+ * @param fileTag the file tag
+ */
+ public void cacheResult(FileTag fileTag) {
+ EntityCacheUtil.putResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTag.getPrimaryKey(), fileTag);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ new Object[] { Long.valueOf(fileTag.getDlFileEntryId()) }, fileTag);
+
+ fileTag.resetOriginalValues();
+ }
+
+ /**
+ * Caches the file tags in the entity cache if it is enabled.
+ *
+ * @param fileTags the file tags
+ */
+ public void cacheResult(List<FileTag> fileTags) {
+ for (FileTag fileTag : fileTags) {
+ if (EntityCacheUtil.getResult(
+ FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTag.getPrimaryKey()) == null) {
+ cacheResult(fileTag);
+ }
+ else {
+ fileTag.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all file tags.
+ *
+ * <p>
+ * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
+ * </p>
+ */
+ @Override
+ public void clearCache() {
+ if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
+ CacheRegistryUtil.clear(FileTagImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(FileTagImpl.class.getName());
+
+ 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 file tag.
+ *
+ * <p>
+ * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
+ * </p>
+ */
+ @Override
+ public void clearCache(FileTag fileTag) {
+ EntityCacheUtil.removeResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTag.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ clearUniqueFindersCache(fileTag);
+ }
+
+ @Override
+ public void clearCache(List<FileTag> fileTags) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (FileTag fileTag : fileTags) {
+ EntityCacheUtil.removeResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTag.getPrimaryKey());
+
+ clearUniqueFindersCache(fileTag);
+ }
+ }
+
+ protected void clearUniqueFindersCache(FileTag fileTag) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ new Object[] { Long.valueOf(fileTag.getDlFileEntryId()) });
+ }
+
+ /**
+ * Creates a new file tag with the primary key. Does not add the file tag to the database.
+ *
+ * @param fileTagId the primary key for the new file tag
+ * @return the new file tag
+ */
+ public FileTag create(long fileTagId) {
+ FileTag fileTag = new FileTagImpl();
+
+ fileTag.setNew(true);
+ fileTag.setPrimaryKey(fileTagId);
+
+ return fileTag;
+ }
+
+ /**
+ * Removes the file tag with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param fileTagId the primary key of the file tag
+ * @return the file tag that was removed
+ * @throws com.pentila.entSavoie.cartable.NoSuchFileTagException if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag remove(long fileTagId)
+ throws NoSuchFileTagException, SystemException {
+ return remove(Long.valueOf(fileTagId));
+ }
+
+ /**
+ * Removes the file tag with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the file tag
+ * @return the file tag that was removed
+ * @throws com.pentila.entSavoie.cartable.NoSuchFileTagException if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public FileTag remove(Serializable primaryKey)
+ throws NoSuchFileTagException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ FileTag fileTag = (FileTag)session.get(FileTagImpl.class, primaryKey);
+
+ if (fileTag == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchFileTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(fileTag);
+ }
+ catch (NoSuchFileTagException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected FileTag removeImpl(FileTag fileTag) throws SystemException {
+ fileTag = toUnwrappedModel(fileTag);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, fileTag);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(fileTag);
+
+ return fileTag;
+ }
+
+ @Override
+ public FileTag updateImpl(
+ com.pentila.entSavoie.cartable.model.FileTag fileTag, boolean merge)
+ throws SystemException {
+ fileTag = toUnwrappedModel(fileTag);
+
+ boolean isNew = fileTag.isNew();
+
+ FileTagModelImpl fileTagModelImpl = (FileTagModelImpl)fileTag;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, fileTag, merge);
+
+ fileTag.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !FileTagModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ EntityCacheUtil.putResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTag.getPrimaryKey(), fileTag);
+
+ if (isNew) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ new Object[] { Long.valueOf(fileTag.getDlFileEntryId()) },
+ fileTag);
+ }
+ else {
+ if ((fileTagModelImpl.getColumnBitmask() &
+ FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(fileTagModelImpl.getOriginalDlFileEntryId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DLFILEENTRYID_TAG,
+ args);
+
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ args);
+
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ new Object[] { Long.valueOf(fileTag.getDlFileEntryId()) },
+ fileTag);
+ }
+ }
+
+ return fileTag;
+ }
+
+ protected FileTag toUnwrappedModel(FileTag fileTag) {
+ if (fileTag instanceof FileTagImpl) {
+ return fileTag;
+ }
+
+ FileTagImpl fileTagImpl = new FileTagImpl();
+
+ fileTagImpl.setNew(fileTag.isNew());
+ fileTagImpl.setPrimaryKey(fileTag.getPrimaryKey());
+
+ fileTagImpl.setFileTagId(fileTag.getFileTagId());
+ fileTagImpl.setDlFileEntryId(fileTag.getDlFileEntryId());
+ fileTagImpl.setTagList(fileTag.getTagList());
+ fileTagImpl.setLinkList(fileTag.getLinkList());
+ fileTagImpl.setKeywordList(fileTag.getKeywordList());
+
+ return fileTagImpl;
+ }
+
+ /**
+ * Returns the file tag with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
+ *
+ * @param primaryKey the primary key of the file tag
+ * @return the file tag
+ * @throws com.liferay.portal.NoSuchModelException if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public FileTag findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the file tag with the primary key or throws a {@link com.pentila.entSavoie.cartable.NoSuchFileTagException} if it could not be found.
+ *
+ * @param fileTagId the primary key of the file tag
+ * @return the file tag
+ * @throws com.pentila.entSavoie.cartable.NoSuchFileTagException if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag findByPrimaryKey(long fileTagId)
+ throws NoSuchFileTagException, SystemException {
+ FileTag fileTag = fetchByPrimaryKey(fileTagId);
+
+ if (fileTag == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + fileTagId);
+ }
+
+ throw new NoSuchFileTagException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ fileTagId);
+ }
+
+ return fileTag;
+ }
+
+ /**
+ * Returns the file tag with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the file tag
+ * @return the file tag, or <code>null</code> if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public FileTag fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the file tag with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param fileTagId the primary key of the file tag
+ * @return the file tag, or <code>null</code> if a file tag with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag fetchByPrimaryKey(long fileTagId) throws SystemException {
+ FileTag fileTag = (FileTag)EntityCacheUtil.getResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTagId);
+
+ if (fileTag == _nullFileTag) {
+ return null;
+ }
+
+ if (fileTag == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ fileTag = (FileTag)session.get(FileTagImpl.class,
+ Long.valueOf(fileTagId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (fileTag != null) {
+ cacheResult(fileTag);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(FileTagModelImpl.ENTITY_CACHE_ENABLED,
+ FileTagImpl.class, fileTagId, _nullFileTag);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return fileTag;
+ }
+
+ /**
+ * Returns the file tag where dlFileEntryId = ? or throws a {@link com.pentila.entSavoie.cartable.NoSuchFileTagException} if it could not be found.
+ *
+ * @param dlFileEntryId the dl file entry ID
+ * @return the matching file tag
+ * @throws com.pentila.entSavoie.cartable.NoSuchFileTagException if a matching file tag could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag findBydlFileEntryId_tag(long dlFileEntryId)
+ throws NoSuchFileTagException, SystemException {
+ FileTag fileTag = fetchBydlFileEntryId_tag(dlFileEntryId);
+
+ if (fileTag == null) {
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("dlFileEntryId=");
+ msg.append(dlFileEntryId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ if (_log.isWarnEnabled()) {
+ _log.warn(msg.toString());
+ }
+
+ throw new NoSuchFileTagException(msg.toString());
+ }
+
+ return fileTag;
+ }
+
+ /**
+ * Returns the file tag where dlFileEntryId = ? or returns <code>null</code> if it could not be found. Uses the finder cache.
+ *
+ * @param dlFileEntryId the dl file entry ID
+ * @return the matching file tag, or <code>null</code> if a matching file tag could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag fetchBydlFileEntryId_tag(long dlFileEntryId)
+ throws SystemException {
+ return fetchBydlFileEntryId_tag(dlFileEntryId, true);
+ }
+
+ /**
+ * Returns the file tag where dlFileEntryId = ? or returns <code>null</code> if it could not be found, optionally using the finder cache.
+ *
+ * @param dlFileEntryId the dl file entry ID
+ * @param retrieveFromCache whether to use the finder cache
+ * @return the matching file tag, or <code>null</code> if a matching file tag could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag fetchBydlFileEntryId_tag(long dlFileEntryId,
+ boolean retrieveFromCache) throws SystemException {
+ Object[] finderArgs = new Object[] { dlFileEntryId };
+
+ Object result = null;
+
+ if (retrieveFromCache) {
+ result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ finderArgs, this);
+ }
+
+ if (result instanceof FileTag) {
+ FileTag fileTag = (FileTag)result;
+
+ if ((dlFileEntryId != fileTag.getDlFileEntryId())) {
+ result = null;
+ }
+ }
+
+ if (result == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_SELECT_FILETAG_WHERE);
+
+ query.append(_FINDER_COLUMN_DLFILEENTRYID_TAG_DLFILEENTRYID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(dlFileEntryId);
+
+ List<FileTag> list = q.list();
+
+ result = list;
+
+ FileTag fileTag = null;
+
+ if (list.isEmpty()) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ finderArgs, list);
+ }
+ else {
+ fileTag = list.get(0);
+
+ cacheResult(fileTag);
+
+ if ((fileTag.getDlFileEntryId() != dlFileEntryId)) {
+ FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ finderArgs, fileTag);
+ }
+ }
+
+ return fileTag;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (result == null) {
+ FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_DLFILEENTRYID_TAG,
+ finderArgs);
+ }
+
+ closeSession(session);
+ }
+ }
+ else {
+ if (result instanceof List<?>) {
+ return null;
+ }
+ else {
+ return (FileTag)result;
+ }
+ }
+ }
+
+ /**
+ * Returns all the file tags.
+ *
+ * @return the file tags
+ * @throws SystemException if a system exception occurred
+ */
+ public List<FileTag> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the file tags.
+ *
+ * <p>
+ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
+ * </p>
+ *
+ * @param start the lower bound of the range of file tags
+ * @param end the upper bound of the range of file tags (not inclusive)
+ * @return the range of file tags
+ * @throws SystemException if a system exception occurred
+ */
+ public List<FileTag> findAll(int start, int end) throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the file tags.
+ *
+ * <p>
+ * Useful when paginating results. Returns a maximum of <code>end - start</code> instances. <code>start</code> and <code>end</code> are not primary keys, they are indexes in the result set. Thus, <code>0</code> refers to the first result in the set. Setting both <code>start</code> and <code>end</code> to {@link com.liferay.portal.kernel.dao.orm.QueryUtil#ALL_POS} will return the full result set.
+ * </p>
+ *
+ * @param start the lower bound of the range of file tags
+ * @param end the upper bound of the range of file tags (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of file tags
+ * @throws SystemException if a system exception occurred
+ */
+ public List<FileTag> findAll(int start, int end,
+ OrderByComparator orderByComparator) throws SystemException {
+ FinderPath finderPath = null;
+ Object[] finderArgs = new Object[] { start, end, orderByComparator };
+
+ if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
+ (orderByComparator == null)) {
+ finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
+ finderArgs = FINDER_ARGS_EMPTY;
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
+ finderArgs = new Object[] { start, end, orderByComparator };
+ }
+
+ List<FileTag> list = (List<FileTag>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if (list == null) {
+ StringBundler query = null;
+ String sql = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(2 +
+ (orderByComparator.getOrderByFields().length * 3));
+
+ query.append(_SQL_SELECT_FILETAG);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_FILETAG;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<FileTag>)QueryUtil.list(q, getDialect(),
+ start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<FileTag>)QueryUtil.list(q, getDialect(),
+ start, end);
+ }
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (list == null) {
+ FinderCacheUtil.removeResult(finderPath, finderArgs);
+ }
+ else {
+ cacheResult(list);
+
+ FinderCacheUtil.putResult(finderPath, finderArgs, list);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return list;
+ }
+
+ /**
+ * Removes the file tag where dlFileEntryId = ? from the database.
+ *
+ * @param dlFileEntryId the dl file entry ID
+ * @return the file tag that was removed
+ * @throws SystemException if a system exception occurred
+ */
+ public FileTag removeBydlFileEntryId_tag(long dlFileEntryId)
+ throws NoSuchFileTagException, SystemException {
+ FileTag fileTag = findBydlFileEntryId_tag(dlFileEntryId);
+
+ return remove(fileTag);
+ }
+
+ /**
+ * Removes all the file tags from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (FileTag fileTag : findAll()) {
+ remove(fileTag);
+ }
+ }
+
+ /**
+ * Returns the number of file tags where dlFileEntryId = ?.
+ *
+ * @param dlFileEntryId the dl file entry ID
+ * @return the number of matching file tags
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBydlFileEntryId_tag(long dlFileEntryId)
+ throws SystemException {
+ Object[] finderArgs = new Object[] { dlFileEntryId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DLFILEENTRYID_TAG,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_FILETAG_WHERE);
+
+ query.append(_FINDER_COLUMN_DLFILEENTRYID_TAG_DLFILEENTRYID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(dlFileEntryId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DLFILEENTRYID_TAG,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of file tags.
+ *
+ * @return the number of file tags
+ * @throws SystemException if a system exception occurred
+ */
+ public int countAll() throws SystemException {
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
+ FINDER_ARGS_EMPTY, this);
+
+ if (count == null) {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(_SQL_COUNT_FILETAG);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
+ FINDER_ARGS_EMPTY, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Initializes the file tag persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.cartable.model.FileTag")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<FileTag>> listenersList = new ArrayList<ModelListener<FileTag>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<FileTag>)InstanceFactory.newInstance(
+ PortletClassLoaderUtil.getClassLoader(),
+ listenerClassName, (Class<?>[])null, (Object[])null));
+ }
+
+ listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
+ }
+ catch (Exception e) {
+ _log.error(e);
+ }
+ }
+ }
+
+ public void destroy() {
+ EntityCacheUtil.removeCache(FileTagImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = CasierEntryPersistence.class)
+ protected CasierEntryPersistence casierEntryPersistence;
+ @BeanReference(type = DlLinkPersistence.class)
+ protected DlLinkPersistence dlLinkPersistence;
+ @BeanReference(type = FileTagPersistence.class)
+ protected FileTagPersistence fileTagPersistence;
+ @BeanReference(type = FileVersionPersistence.class)
+ protected FileVersionPersistence fileVersionPersistence;
+ @BeanReference(type = LoolTokenPersistence.class)
+ protected LoolTokenPersistence loolTokenPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_FILETAG = "SELECT fileTag FROM FileTag fileTag";
+ private static final String _SQL_SELECT_FILETAG_WHERE = "SELECT fileTag FROM FileTag fileTag WHERE ";
+ private static final String _SQL_COUNT_FILETAG = "SELECT COUNT(fileTag) FROM FileTag fileTag";
+ private static final String _SQL_COUNT_FILETAG_WHERE = "SELECT COUNT(fileTag) FROM FileTag fileTag WHERE ";
+ private static final String _FINDER_COLUMN_DLFILEENTRYID_TAG_DLFILEENTRYID_2 =
+ "fileTag.dlFileEntryId = ?";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "fileTag.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No FileTag exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No FileTag exists with the key {";
+ private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = GetterUtil.getBoolean(PropsUtil.get(
+ PropsKeys.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE));
+ private static Log _log = LogFactoryUtil.getLog(FileTagPersistenceImpl.class);
+ private static FileTag _nullFileTag = new FileTagImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<FileTag> toCacheModel() {
+ return _nullFileTagCacheModel;
+ }
+ };
+
+ private static CacheModel<FileTag> _nullFileTagCacheModel = new CacheModel<FileTag>() {
+ public FileTag toEntityModel() {
+ return _nullFileTag;
+ }
+ };
+}
\ No newline at end of file