--- /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.internalMessaging.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.internalMessaging.NoSuchInternalAttachFileException;
+import com.pentila.entSavoie.internalMessaging.model.InternalAttachFile;
+import com.pentila.entSavoie.internalMessaging.model.impl.InternalAttachFileImpl;
+import com.pentila.entSavoie.internalMessaging.model.impl.InternalAttachFileModelImpl;
+
+import java.io.Serializable;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+/**
+ * The persistence implementation for the internal attach file service.
+ *
+ * <p>
+ * Caching information and settings can be found in <code>portal.properties</code>
+ * </p>
+ *
+ * @author Igor Barma - Mathieu Amblard
+ * @see InternalAttachFilePersistence
+ * @see InternalAttachFileUtil
+ * @generated
+ */
+public class InternalAttachFilePersistenceImpl extends BasePersistenceImpl<InternalAttachFile>
+ implements InternalAttachFilePersistence {
+ /*
+ * NOTE FOR DEVELOPERS:
+ *
+ * Never modify or reference this class directly. Always use {@link InternalAttachFileUtil} to access the internal attach file persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
+ */
+ public static final String FINDER_CLASS_NAME_ENTITY = InternalAttachFileImpl.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_WITH_PAGINATION_FIND_BY_MESSAGEID =
+ new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED,
+ InternalAttachFileImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBymessageId",
+ new String[] {
+ Long.class.getName(),
+
+ "java.lang.Integer", "java.lang.Integer",
+ "com.liferay.portal.kernel.util.OrderByComparator"
+ });
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MESSAGEID =
+ new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED,
+ InternalAttachFileImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBymessageId",
+ new String[] { Long.class.getName() },
+ InternalAttachFileModelImpl.MESSAGEID_COLUMN_BITMASK);
+ public static final FinderPath FINDER_PATH_COUNT_BY_MESSAGEID = new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBymessageId",
+ new String[] { Long.class.getName() });
+ public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED,
+ InternalAttachFileImpl.class,
+ FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED,
+ InternalAttachFileImpl.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
+ public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileModelImpl.FINDER_CACHE_ENABLED, Long.class,
+ FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
+
+ /**
+ * Caches the internal attach file in the entity cache if it is enabled.
+ *
+ * @param internalAttachFile the internal attach file
+ */
+ public void cacheResult(InternalAttachFile internalAttachFile) {
+ EntityCacheUtil.putResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFile.getPrimaryKey(),
+ internalAttachFile);
+
+ internalAttachFile.resetOriginalValues();
+ }
+
+ /**
+ * Caches the internal attach files in the entity cache if it is enabled.
+ *
+ * @param internalAttachFiles the internal attach files
+ */
+ public void cacheResult(List<InternalAttachFile> internalAttachFiles) {
+ for (InternalAttachFile internalAttachFile : internalAttachFiles) {
+ if (EntityCacheUtil.getResult(
+ InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class,
+ internalAttachFile.getPrimaryKey()) == null) {
+ cacheResult(internalAttachFile);
+ }
+ else {
+ internalAttachFile.resetOriginalValues();
+ }
+ }
+ }
+
+ /**
+ * Clears the cache for all internal attach files.
+ *
+ * <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(InternalAttachFileImpl.class.getName());
+ }
+
+ EntityCacheUtil.clearCache(InternalAttachFileImpl.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 internal attach file.
+ *
+ * <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(InternalAttachFile internalAttachFile) {
+ EntityCacheUtil.removeResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFile.getPrimaryKey());
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @Override
+ public void clearCache(List<InternalAttachFile> internalAttachFiles) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+
+ for (InternalAttachFile internalAttachFile : internalAttachFiles) {
+ EntityCacheUtil.removeResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFile.getPrimaryKey());
+ }
+ }
+
+ /**
+ * Creates a new internal attach file with the primary key. Does not add the internal attach file to the database.
+ *
+ * @param internalAttachFileId the primary key for the new internal attach file
+ * @return the new internal attach file
+ */
+ public InternalAttachFile create(long internalAttachFileId) {
+ InternalAttachFile internalAttachFile = new InternalAttachFileImpl();
+
+ internalAttachFile.setNew(true);
+ internalAttachFile.setPrimaryKey(internalAttachFileId);
+
+ return internalAttachFile;
+ }
+
+ /**
+ * Removes the internal attach file with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param internalAttachFileId the primary key of the internal attach file
+ * @return the internal attach file that was removed
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile remove(long internalAttachFileId)
+ throws NoSuchInternalAttachFileException, SystemException {
+ return remove(Long.valueOf(internalAttachFileId));
+ }
+
+ /**
+ * Removes the internal attach file with the primary key from the database. Also notifies the appropriate model listeners.
+ *
+ * @param primaryKey the primary key of the internal attach file
+ * @return the internal attach file that was removed
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalAttachFile remove(Serializable primaryKey)
+ throws NoSuchInternalAttachFileException, SystemException {
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ InternalAttachFile internalAttachFile = (InternalAttachFile)session.get(InternalAttachFileImpl.class,
+ primaryKey);
+
+ if (internalAttachFile == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
+ }
+
+ throw new NoSuchInternalAttachFileException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ primaryKey);
+ }
+
+ return remove(internalAttachFile);
+ }
+ catch (NoSuchInternalAttachFileException nsee) {
+ throw nsee;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ @Override
+ protected InternalAttachFile removeImpl(
+ InternalAttachFile internalAttachFile) throws SystemException {
+ internalAttachFile = toUnwrappedModel(internalAttachFile);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.delete(session, internalAttachFile);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ clearCache(internalAttachFile);
+
+ return internalAttachFile;
+ }
+
+ @Override
+ public InternalAttachFile updateImpl(
+ com.pentila.entSavoie.internalMessaging.model.InternalAttachFile internalAttachFile,
+ boolean merge) throws SystemException {
+ internalAttachFile = toUnwrappedModel(internalAttachFile);
+
+ boolean isNew = internalAttachFile.isNew();
+
+ InternalAttachFileModelImpl internalAttachFileModelImpl = (InternalAttachFileModelImpl)internalAttachFile;
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ BatchSessionUtil.update(session, internalAttachFile, merge);
+
+ internalAttachFile.setNew(false);
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
+
+ if (isNew || !InternalAttachFileModelImpl.COLUMN_BITMASK_ENABLED) {
+ FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ else {
+ if ((internalAttachFileModelImpl.getColumnBitmask() &
+ FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MESSAGEID.getColumnBitmask()) != 0) {
+ Object[] args = new Object[] {
+ Long.valueOf(internalAttachFileModelImpl.getOriginalMessageId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MESSAGEID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MESSAGEID,
+ args);
+
+ args = new Object[] {
+ Long.valueOf(internalAttachFileModelImpl.getMessageId())
+ };
+
+ FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_MESSAGEID,
+ args);
+ FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MESSAGEID,
+ args);
+ }
+ }
+
+ EntityCacheUtil.putResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFile.getPrimaryKey(),
+ internalAttachFile);
+
+ return internalAttachFile;
+ }
+
+ protected InternalAttachFile toUnwrappedModel(
+ InternalAttachFile internalAttachFile) {
+ if (internalAttachFile instanceof InternalAttachFileImpl) {
+ return internalAttachFile;
+ }
+
+ InternalAttachFileImpl internalAttachFileImpl = new InternalAttachFileImpl();
+
+ internalAttachFileImpl.setNew(internalAttachFile.isNew());
+ internalAttachFileImpl.setPrimaryKey(internalAttachFile.getPrimaryKey());
+
+ internalAttachFileImpl.setInternalAttachFileId(internalAttachFile.getInternalAttachFileId());
+ internalAttachFileImpl.setAttachFileId(internalAttachFile.getAttachFileId());
+ internalAttachFileImpl.setMessageId(internalAttachFile.getMessageId());
+ internalAttachFileImpl.setAttachFileType(internalAttachFile.getAttachFileType());
+
+ return internalAttachFileImpl;
+ }
+
+ /**
+ * Returns the internal attach file 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 internal attach file
+ * @return the internal attach file
+ * @throws com.liferay.portal.NoSuchModelException if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalAttachFile findByPrimaryKey(Serializable primaryKey)
+ throws NoSuchModelException, SystemException {
+ return findByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the internal attach file with the primary key or throws a {@link com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException} if it could not be found.
+ *
+ * @param internalAttachFileId the primary key of the internal attach file
+ * @return the internal attach file
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile findByPrimaryKey(long internalAttachFileId)
+ throws NoSuchInternalAttachFileException, SystemException {
+ InternalAttachFile internalAttachFile = fetchByPrimaryKey(internalAttachFileId);
+
+ if (internalAttachFile == null) {
+ if (_log.isWarnEnabled()) {
+ _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ internalAttachFileId);
+ }
+
+ throw new NoSuchInternalAttachFileException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
+ internalAttachFileId);
+ }
+
+ return internalAttachFile;
+ }
+
+ /**
+ * Returns the internal attach file with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param primaryKey the primary key of the internal attach file
+ * @return the internal attach file, or <code>null</code> if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ @Override
+ public InternalAttachFile fetchByPrimaryKey(Serializable primaryKey)
+ throws SystemException {
+ return fetchByPrimaryKey(((Long)primaryKey).longValue());
+ }
+
+ /**
+ * Returns the internal attach file with the primary key or returns <code>null</code> if it could not be found.
+ *
+ * @param internalAttachFileId the primary key of the internal attach file
+ * @return the internal attach file, or <code>null</code> if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile fetchByPrimaryKey(long internalAttachFileId)
+ throws SystemException {
+ InternalAttachFile internalAttachFile = (InternalAttachFile)EntityCacheUtil.getResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFileId);
+
+ if (internalAttachFile == _nullInternalAttachFile) {
+ return null;
+ }
+
+ if (internalAttachFile == null) {
+ Session session = null;
+
+ boolean hasException = false;
+
+ try {
+ session = openSession();
+
+ internalAttachFile = (InternalAttachFile)session.get(InternalAttachFileImpl.class,
+ Long.valueOf(internalAttachFileId));
+ }
+ catch (Exception e) {
+ hasException = true;
+
+ throw processException(e);
+ }
+ finally {
+ if (internalAttachFile != null) {
+ cacheResult(internalAttachFile);
+ }
+ else if (!hasException) {
+ EntityCacheUtil.putResult(InternalAttachFileModelImpl.ENTITY_CACHE_ENABLED,
+ InternalAttachFileImpl.class, internalAttachFileId,
+ _nullInternalAttachFile);
+ }
+
+ closeSession(session);
+ }
+ }
+
+ return internalAttachFile;
+ }
+
+ /**
+ * Returns all the internal attach files where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @return the matching internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> findBymessageId(long messageId)
+ throws SystemException {
+ return findBymessageId(messageId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
+ null);
+ }
+
+ /**
+ * Returns a range of all the internal attach files where messageId = ?.
+ *
+ * <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 messageId the message ID
+ * @param start the lower bound of the range of internal attach files
+ * @param end the upper bound of the range of internal attach files (not inclusive)
+ * @return the range of matching internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> findBymessageId(long messageId, int start,
+ int end) throws SystemException {
+ return findBymessageId(messageId, start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the internal attach files where messageId = ?.
+ *
+ * <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 messageId the message ID
+ * @param start the lower bound of the range of internal attach files
+ * @param end the upper bound of the range of internal attach files (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of matching internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> findBymessageId(long messageId, int start,
+ int end, OrderByComparator orderByComparator) throws SystemException {
+ FinderPath finderPath = null;
+ Object[] finderArgs = null;
+
+ if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
+ (orderByComparator == null)) {
+ finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_MESSAGEID;
+ finderArgs = new Object[] { messageId };
+ }
+ else {
+ finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_MESSAGEID;
+ finderArgs = new Object[] { messageId, start, end, orderByComparator };
+ }
+
+ List<InternalAttachFile> list = (List<InternalAttachFile>)FinderCacheUtil.getResult(finderPath,
+ finderArgs, this);
+
+ if ((list != null) && !list.isEmpty()) {
+ for (InternalAttachFile internalAttachFile : list) {
+ if ((messageId != internalAttachFile.getMessageId())) {
+ list = null;
+
+ break;
+ }
+ }
+ }
+
+ if (list == null) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(3 +
+ (orderByComparator.getOrderByFields().length * 3));
+ }
+ else {
+ query = new StringBundler(2);
+ }
+
+ query.append(_SQL_SELECT_INTERNALATTACHFILE_WHERE);
+
+ query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
+
+ if (orderByComparator != null) {
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+ }
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(messageId);
+
+ list = (List<InternalAttachFile>)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;
+ }
+
+ /**
+ * Returns the first internal attach file in the ordered set where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching internal attach file
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a matching internal attach file could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile findBymessageId_First(long messageId,
+ OrderByComparator orderByComparator)
+ throws NoSuchInternalAttachFileException, SystemException {
+ InternalAttachFile internalAttachFile = fetchBymessageId_First(messageId,
+ orderByComparator);
+
+ if (internalAttachFile != null) {
+ return internalAttachFile;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("messageId=");
+ msg.append(messageId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchInternalAttachFileException(msg.toString());
+ }
+
+ /**
+ * Returns the first internal attach file in the ordered set where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the first matching internal attach file, or <code>null</code> if a matching internal attach file could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile fetchBymessageId_First(long messageId,
+ OrderByComparator orderByComparator) throws SystemException {
+ List<InternalAttachFile> list = findBymessageId(messageId, 0, 1,
+ orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the last internal attach file in the ordered set where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching internal attach file
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a matching internal attach file could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile findBymessageId_Last(long messageId,
+ OrderByComparator orderByComparator)
+ throws NoSuchInternalAttachFileException, SystemException {
+ InternalAttachFile internalAttachFile = fetchBymessageId_Last(messageId,
+ orderByComparator);
+
+ if (internalAttachFile != null) {
+ return internalAttachFile;
+ }
+
+ StringBundler msg = new StringBundler(4);
+
+ msg.append(_NO_SUCH_ENTITY_WITH_KEY);
+
+ msg.append("messageId=");
+ msg.append(messageId);
+
+ msg.append(StringPool.CLOSE_CURLY_BRACE);
+
+ throw new NoSuchInternalAttachFileException(msg.toString());
+ }
+
+ /**
+ * Returns the last internal attach file in the ordered set where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the last matching internal attach file, or <code>null</code> if a matching internal attach file could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile fetchBymessageId_Last(long messageId,
+ OrderByComparator orderByComparator) throws SystemException {
+ int count = countBymessageId(messageId);
+
+ List<InternalAttachFile> list = findBymessageId(messageId, count - 1,
+ count, orderByComparator);
+
+ if (!list.isEmpty()) {
+ return list.get(0);
+ }
+
+ return null;
+ }
+
+ /**
+ * Returns the internal attach files before and after the current internal attach file in the ordered set where messageId = ?.
+ *
+ * @param internalAttachFileId the primary key of the current internal attach file
+ * @param messageId the message ID
+ * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
+ * @return the previous, current, and next internal attach file
+ * @throws com.pentila.entSavoie.internalMessaging.NoSuchInternalAttachFileException if a internal attach file with the primary key could not be found
+ * @throws SystemException if a system exception occurred
+ */
+ public InternalAttachFile[] findBymessageId_PrevAndNext(
+ long internalAttachFileId, long messageId,
+ OrderByComparator orderByComparator)
+ throws NoSuchInternalAttachFileException, SystemException {
+ InternalAttachFile internalAttachFile = findByPrimaryKey(internalAttachFileId);
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ InternalAttachFile[] array = new InternalAttachFileImpl[3];
+
+ array[0] = getBymessageId_PrevAndNext(session, internalAttachFile,
+ messageId, orderByComparator, true);
+
+ array[1] = internalAttachFile;
+
+ array[2] = getBymessageId_PrevAndNext(session, internalAttachFile,
+ messageId, orderByComparator, false);
+
+ return array;
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ closeSession(session);
+ }
+ }
+
+ protected InternalAttachFile getBymessageId_PrevAndNext(Session session,
+ InternalAttachFile internalAttachFile, long messageId,
+ OrderByComparator orderByComparator, boolean previous) {
+ StringBundler query = null;
+
+ if (orderByComparator != null) {
+ query = new StringBundler(6 +
+ (orderByComparator.getOrderByFields().length * 6));
+ }
+ else {
+ query = new StringBundler(3);
+ }
+
+ query.append(_SQL_SELECT_INTERNALATTACHFILE_WHERE);
+
+ query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
+
+ if (orderByComparator != null) {
+ String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
+
+ if (orderByConditionFields.length > 0) {
+ query.append(WHERE_AND);
+ }
+
+ for (int i = 0; i < orderByConditionFields.length; i++) {
+ query.append(_ORDER_BY_ENTITY_ALIAS);
+ query.append(orderByConditionFields[i]);
+
+ if ((i + 1) < orderByConditionFields.length) {
+ if (orderByComparator.isAscending() ^ previous) {
+ query.append(WHERE_GREATER_THAN_HAS_NEXT);
+ }
+ else {
+ query.append(WHERE_LESSER_THAN_HAS_NEXT);
+ }
+ }
+ else {
+ if (orderByComparator.isAscending() ^ previous) {
+ query.append(WHERE_GREATER_THAN);
+ }
+ else {
+ query.append(WHERE_LESSER_THAN);
+ }
+ }
+ }
+
+ query.append(ORDER_BY_CLAUSE);
+
+ String[] orderByFields = orderByComparator.getOrderByFields();
+
+ for (int i = 0; i < orderByFields.length; i++) {
+ query.append(_ORDER_BY_ENTITY_ALIAS);
+ query.append(orderByFields[i]);
+
+ if ((i + 1) < orderByFields.length) {
+ if (orderByComparator.isAscending() ^ previous) {
+ query.append(ORDER_BY_ASC_HAS_NEXT);
+ }
+ else {
+ query.append(ORDER_BY_DESC_HAS_NEXT);
+ }
+ }
+ else {
+ if (orderByComparator.isAscending() ^ previous) {
+ query.append(ORDER_BY_ASC);
+ }
+ else {
+ query.append(ORDER_BY_DESC);
+ }
+ }
+ }
+ }
+
+ String sql = query.toString();
+
+ Query q = session.createQuery(sql);
+
+ q.setFirstResult(0);
+ q.setMaxResults(2);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(messageId);
+
+ if (orderByComparator != null) {
+ Object[] values = orderByComparator.getOrderByConditionValues(internalAttachFile);
+
+ for (Object value : values) {
+ qPos.add(value);
+ }
+ }
+
+ List<InternalAttachFile> list = q.list();
+
+ if (list.size() == 2) {
+ return list.get(1);
+ }
+ else {
+ return null;
+ }
+ }
+
+ /**
+ * Returns all the internal attach files.
+ *
+ * @return the internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> findAll() throws SystemException {
+ return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
+ }
+
+ /**
+ * Returns a range of all the internal attach files.
+ *
+ * <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 internal attach files
+ * @param end the upper bound of the range of internal attach files (not inclusive)
+ * @return the range of internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> findAll(int start, int end)
+ throws SystemException {
+ return findAll(start, end, null);
+ }
+
+ /**
+ * Returns an ordered range of all the internal attach files.
+ *
+ * <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 internal attach files
+ * @param end the upper bound of the range of internal attach files (not inclusive)
+ * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
+ * @return the ordered range of internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public List<InternalAttachFile> 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<InternalAttachFile> list = (List<InternalAttachFile>)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_INTERNALATTACHFILE);
+
+ appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
+ orderByComparator);
+
+ sql = query.toString();
+ }
+ else {
+ sql = _SQL_SELECT_INTERNALATTACHFILE;
+ }
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ if (orderByComparator == null) {
+ list = (List<InternalAttachFile>)QueryUtil.list(q,
+ getDialect(), start, end, false);
+
+ Collections.sort(list);
+ }
+ else {
+ list = (List<InternalAttachFile>)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 all the internal attach files where messageId = ? from the database.
+ *
+ * @param messageId the message ID
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeBymessageId(long messageId) throws SystemException {
+ for (InternalAttachFile internalAttachFile : findBymessageId(messageId)) {
+ remove(internalAttachFile);
+ }
+ }
+
+ /**
+ * Removes all the internal attach files from the database.
+ *
+ * @throws SystemException if a system exception occurred
+ */
+ public void removeAll() throws SystemException {
+ for (InternalAttachFile internalAttachFile : findAll()) {
+ remove(internalAttachFile);
+ }
+ }
+
+ /**
+ * Returns the number of internal attach files where messageId = ?.
+ *
+ * @param messageId the message ID
+ * @return the number of matching internal attach files
+ * @throws SystemException if a system exception occurred
+ */
+ public int countBymessageId(long messageId) throws SystemException {
+ Object[] finderArgs = new Object[] { messageId };
+
+ Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_MESSAGEID,
+ finderArgs, this);
+
+ if (count == null) {
+ StringBundler query = new StringBundler(2);
+
+ query.append(_SQL_COUNT_INTERNALATTACHFILE_WHERE);
+
+ query.append(_FINDER_COLUMN_MESSAGEID_MESSAGEID_2);
+
+ String sql = query.toString();
+
+ Session session = null;
+
+ try {
+ session = openSession();
+
+ Query q = session.createQuery(sql);
+
+ QueryPos qPos = QueryPos.getInstance(q);
+
+ qPos.add(messageId);
+
+ count = (Long)q.uniqueResult();
+ }
+ catch (Exception e) {
+ throw processException(e);
+ }
+ finally {
+ if (count == null) {
+ count = Long.valueOf(0);
+ }
+
+ FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_MESSAGEID,
+ finderArgs, count);
+
+ closeSession(session);
+ }
+ }
+
+ return count.intValue();
+ }
+
+ /**
+ * Returns the number of internal attach files.
+ *
+ * @return the number of internal attach files
+ * @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_INTERNALATTACHFILE);
+
+ 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 internal attach file persistence.
+ */
+ public void afterPropertiesSet() {
+ String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
+ com.liferay.util.service.ServiceProps.get(
+ "value.object.listener.com.pentila.entSavoie.internalMessaging.model.InternalAttachFile")));
+
+ if (listenerClassNames.length > 0) {
+ try {
+ List<ModelListener<InternalAttachFile>> listenersList = new ArrayList<ModelListener<InternalAttachFile>>();
+
+ for (String listenerClassName : listenerClassNames) {
+ listenersList.add((ModelListener<InternalAttachFile>)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(InternalAttachFileImpl.class.getName());
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
+ FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
+ }
+
+ @BeanReference(type = AccountPersistence.class)
+ protected AccountPersistence accountPersistence;
+ @BeanReference(type = AttachmentPersistence.class)
+ protected AttachmentPersistence attachmentPersistence;
+ @BeanReference(type = ExternalCommunicationRightsPersistence.class)
+ protected ExternalCommunicationRightsPersistence externalCommunicationRightsPersistence;
+ @BeanReference(type = FolderPersistence.class)
+ protected FolderPersistence folderPersistence;
+ @BeanReference(type = InternalAttachFilePersistence.class)
+ protected InternalAttachFilePersistence internalAttachFilePersistence;
+ @BeanReference(type = InternalAutoResponsePersistence.class)
+ protected InternalAutoResponsePersistence internalAutoResponsePersistence;
+ @BeanReference(type = InternalContentPersistence.class)
+ protected InternalContentPersistence internalContentPersistence;
+ @BeanReference(type = InternalFolderMessagePersistence.class)
+ protected InternalFolderMessagePersistence internalFolderMessagePersistence;
+ @BeanReference(type = InternalMessagePersistence.class)
+ protected InternalMessagePersistence internalMessagePersistence;
+ @BeanReference(type = InternalReceiverPersistence.class)
+ protected InternalReceiverPersistence internalReceiverPersistence;
+ @BeanReference(type = InternalReceiversPersistence.class)
+ protected InternalReceiversPersistence internalReceiversPersistence;
+ @BeanReference(type = MessagePersistence.class)
+ protected MessagePersistence messagePersistence;
+ @BeanReference(type = RssChanelPersistence.class)
+ protected RssChanelPersistence rssChanelPersistence;
+ @BeanReference(type = RssItemPersistence.class)
+ protected RssItemPersistence rssItemPersistence;
+ @BeanReference(type = ResourcePersistence.class)
+ protected ResourcePersistence resourcePersistence;
+ @BeanReference(type = UserPersistence.class)
+ protected UserPersistence userPersistence;
+ private static final String _SQL_SELECT_INTERNALATTACHFILE = "SELECT internalAttachFile FROM InternalAttachFile internalAttachFile";
+ private static final String _SQL_SELECT_INTERNALATTACHFILE_WHERE = "SELECT internalAttachFile FROM InternalAttachFile internalAttachFile WHERE ";
+ private static final String _SQL_COUNT_INTERNALATTACHFILE = "SELECT COUNT(internalAttachFile) FROM InternalAttachFile internalAttachFile";
+ private static final String _SQL_COUNT_INTERNALATTACHFILE_WHERE = "SELECT COUNT(internalAttachFile) FROM InternalAttachFile internalAttachFile WHERE ";
+ private static final String _FINDER_COLUMN_MESSAGEID_MESSAGEID_2 = "internalAttachFile.messageId = ?";
+ private static final String _ORDER_BY_ENTITY_ALIAS = "internalAttachFile.";
+ private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No InternalAttachFile exists with the primary key ";
+ private static final String _NO_SUCH_ENTITY_WITH_KEY = "No InternalAttachFile 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(InternalAttachFilePersistenceImpl.class);
+ private static InternalAttachFile _nullInternalAttachFile = new InternalAttachFileImpl() {
+ @Override
+ public Object clone() {
+ return this;
+ }
+
+ @Override
+ public CacheModel<InternalAttachFile> toCacheModel() {
+ return _nullInternalAttachFileCacheModel;
+ }
+ };
+
+ private static CacheModel<InternalAttachFile> _nullInternalAttachFileCacheModel =
+ new CacheModel<InternalAttachFile>() {
+ public InternalAttachFile toEntityModel() {
+ return _nullInternalAttachFile;
+ }
+ };
+}
\ No newline at end of file