Java tutorial
/** * Copyright (c) 2000-2013 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.appuntivari.esempio.service.persistence; import com.appuntivari.esempio.NoSuchSistemiException; import com.appuntivari.esempio.model.Sistemi; import com.appuntivari.esempio.model.impl.SistemiImpl; import com.appuntivari.esempio.model.impl.SistemiModelImpl; 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.SQLQuery; 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.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.kernel.util.Validator; import com.liferay.portal.model.CacheModel; import com.liferay.portal.model.ModelListener; import com.liferay.portal.security.permission.InlineSQLHelperUtil; 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 java.io.Serializable; import java.util.ArrayList; import java.util.Collections; import java.util.List; /** * The persistence implementation for the sistemi service. * * <p> * Caching information and settings can be found in <code>portal.properties</code> * </p> * * @author Pasturenzi Francesco * @see SistemiPersistence * @see SistemiUtil * @generated */ public class SistemiPersistenceImpl extends BasePersistenceImpl<Sistemi> implements SistemiPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use {@link SistemiUtil} to access the sistemi persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = SistemiImpl.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_SISTEMA = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findBySistema", new String[] { String.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SISTEMA = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findBySistema", new String[] { String.class.getName() }, SistemiModelImpl.SISTEMA_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_SISTEMA = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countBySistema", new String[] { String.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_DESCRIZIONE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByDescrizione", new String[] { String.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DESCRIZIONE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByDescrizione", new String[] { String.class.getName() }, SistemiModelImpl.DESCRIZIONE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_DESCRIZIONE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByDescrizione", new String[] { String.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STATUS = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStatus", new String[] { String.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STATUS = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStatus", new String[] { String.class.getName() }, SistemiModelImpl.STATUS_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_STATUS = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStatus", new String[] { String.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_STORE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByStore", new String[] { String.class.getName(), "java.lang.Integer", "java.lang.Integer", "com.liferay.portal.kernel.util.OrderByComparator" }); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STORE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByStore", new String[] { String.class.getName() }, SistemiModelImpl.STORE_COLUMN_BITMASK); public static final FinderPath FINDER_PATH_COUNT_BY_STORE = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByStore", new String[] { String.class.getName() }); public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath( SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, SistemiImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); /** * Caches the sistemi in the entity cache if it is enabled. * * @param sistemi the sistemi */ public void cacheResult(Sistemi sistemi) { EntityCacheUtil.putResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemi.getPrimaryKey(), sistemi); sistemi.resetOriginalValues(); } /** * Caches the sistemis in the entity cache if it is enabled. * * @param sistemis the sistemis */ public void cacheResult(List<Sistemi> sistemis) { for (Sistemi sistemi : sistemis) { if (EntityCacheUtil.getResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemi.getPrimaryKey()) == null) { cacheResult(sistemi); } else { sistemi.resetOriginalValues(); } } } /** * Clears the cache for all sistemis. * * <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(SistemiImpl.class.getName()); } EntityCacheUtil.clearCache(SistemiImpl.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 sistemi. * * <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(Sistemi sistemi) { EntityCacheUtil.removeResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemi.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @Override public void clearCache(List<Sistemi> sistemis) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (Sistemi sistemi : sistemis) { EntityCacheUtil.removeResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemi.getPrimaryKey()); } } /** * Creates a new sistemi with the primary key. Does not add the sistemi to the database. * * @param sistemaId the primary key for the new sistemi * @return the new sistemi */ public Sistemi create(long sistemaId) { Sistemi sistemi = new SistemiImpl(); sistemi.setNew(true); sistemi.setPrimaryKey(sistemaId); return sistemi; } /** * Removes the sistemi with the primary key from the database. Also notifies the appropriate model listeners. * * @param sistemaId the primary key of the sistemi * @return the sistemi that was removed * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi remove(long sistemaId) throws NoSuchSistemiException, SystemException { return remove(Long.valueOf(sistemaId)); } /** * Removes the sistemi with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the sistemi * @return the sistemi that was removed * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public Sistemi remove(Serializable primaryKey) throws NoSuchSistemiException, SystemException { Session session = null; try { session = openSession(); Sistemi sistemi = (Sistemi) session.get(SistemiImpl.class, primaryKey); if (sistemi == null) { if (_log.isWarnEnabled()) { _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchSistemiException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(sistemi); } catch (NoSuchSistemiException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected Sistemi removeImpl(Sistemi sistemi) throws SystemException { sistemi = toUnwrappedModel(sistemi); Session session = null; try { session = openSession(); BatchSessionUtil.delete(session, sistemi); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } clearCache(sistemi); return sistemi; } @Override public Sistemi updateImpl(com.appuntivari.esempio.model.Sistemi sistemi, boolean merge) throws SystemException { sistemi = toUnwrappedModel(sistemi); boolean isNew = sistemi.isNew(); SistemiModelImpl sistemiModelImpl = (SistemiModelImpl) sistemi; Session session = null; try { session = openSession(); BatchSessionUtil.update(session, sistemi, merge); sistemi.setNew(false); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (isNew || !SistemiModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else { if ((sistemiModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SISTEMA.getColumnBitmask()) != 0) { Object[] args = new Object[] { sistemiModelImpl.getOriginalSistema() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SISTEMA, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SISTEMA, args); args = new Object[] { sistemiModelImpl.getSistema() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_SISTEMA, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_SISTEMA, args); } if ((sistemiModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DESCRIZIONE.getColumnBitmask()) != 0) { Object[] args = new Object[] { sistemiModelImpl.getOriginalDescrizione() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DESCRIZIONE, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DESCRIZIONE, args); args = new Object[] { sistemiModelImpl.getDescrizione() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_DESCRIZIONE, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_DESCRIZIONE, args); } if ((sistemiModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STATUS.getColumnBitmask()) != 0) { Object[] args = new Object[] { sistemiModelImpl.getOriginalStatus() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STATUS, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STATUS, args); args = new Object[] { sistemiModelImpl.getStatus() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STATUS, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STATUS, args); } if ((sistemiModelImpl.getColumnBitmask() & FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STORE.getColumnBitmask()) != 0) { Object[] args = new Object[] { sistemiModelImpl.getOriginalStore() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STORE, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STORE, args); args = new Object[] { sistemiModelImpl.getStore() }; FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_STORE, args); FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_STORE, args); } } EntityCacheUtil.putResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemi.getPrimaryKey(), sistemi); return sistemi; } protected Sistemi toUnwrappedModel(Sistemi sistemi) { if (sistemi instanceof SistemiImpl) { return sistemi; } SistemiImpl sistemiImpl = new SistemiImpl(); sistemiImpl.setNew(sistemi.isNew()); sistemiImpl.setPrimaryKey(sistemi.getPrimaryKey()); sistemiImpl.setSistemaId(sistemi.getSistemaId()); sistemiImpl.setSistema(sistemi.getSistema()); sistemiImpl.setDescrizione(sistemi.getDescrizione()); sistemiImpl.setUrl_pull(sistemi.getUrl_pull()); sistemiImpl.setUrl_push(sistemi.getUrl_push()); sistemiImpl.setUsername(sistemi.getUsername()); sistemiImpl.setPass(sistemi.getPass()); sistemiImpl.setStatus(sistemi.getStatus()); sistemiImpl.setStore(sistemi.getStore()); return sistemiImpl; } /** * Returns the sistemi 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 sistemi * @return the sistemi * @throws com.liferay.portal.NoSuchModelException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public Sistemi findByPrimaryKey(Serializable primaryKey) throws NoSuchModelException, SystemException { return findByPrimaryKey(((Long) primaryKey).longValue()); } /** * Returns the sistemi with the primary key or throws a {@link com.appuntivari.esempio.NoSuchSistemiException} if it could not be found. * * @param sistemaId the primary key of the sistemi * @return the sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByPrimaryKey(long sistemaId) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByPrimaryKey(sistemaId); if (sistemi == null) { if (_log.isWarnEnabled()) { _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + sistemaId); } throw new NoSuchSistemiException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + sistemaId); } return sistemi; } /** * Returns the sistemi with the primary key or returns <code>null</code> if it could not be found. * * @param primaryKey the primary key of the sistemi * @return the sistemi, or <code>null</code> if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ @Override public Sistemi fetchByPrimaryKey(Serializable primaryKey) throws SystemException { return fetchByPrimaryKey(((Long) primaryKey).longValue()); } /** * Returns the sistemi with the primary key or returns <code>null</code> if it could not be found. * * @param sistemaId the primary key of the sistemi * @return the sistemi, or <code>null</code> if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByPrimaryKey(long sistemaId) throws SystemException { Sistemi sistemi = (Sistemi) EntityCacheUtil.getResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemaId); if (sistemi == _nullSistemi) { return null; } if (sistemi == null) { Session session = null; boolean hasException = false; try { session = openSession(); sistemi = (Sistemi) session.get(SistemiImpl.class, Long.valueOf(sistemaId)); } catch (Exception e) { hasException = true; throw processException(e); } finally { if (sistemi != null) { cacheResult(sistemi); } else if (!hasException) { EntityCacheUtil.putResult(SistemiModelImpl.ENTITY_CACHE_ENABLED, SistemiImpl.class, sistemaId, _nullSistemi); } closeSession(session); } } return sistemi; } /** * Returns all the sistemis where sistema = ?. * * @param sistema the sistema * @return the matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findBySistema(String sistema) throws SystemException { return findBySistema(sistema, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis where sistema = ?. * * <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 sistema the sistema * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findBySistema(String sistema, int start, int end) throws SystemException { return findBySistema(sistema, start, end, null); } /** * Returns an ordered range of all the sistemis where sistema = ?. * * <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 sistema the sistema * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findBySistema(String sistema, 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_SISTEMA; finderArgs = new Object[] { sistema }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_SISTEMA; finderArgs = new Object[] { sistema, start, end, orderByComparator }; } List<Sistemi> list = (List<Sistemi>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Sistemi sistemi : list) { if (!Validator.equals(sistema, sistemi.getSistema())) { list = null; break; } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SISTEMI_WHERE); if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2); } } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } list = (List<Sistemi>) 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 sistemi in the ordered set where sistema = ?. * * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findBySistema_First(String sistema, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchBySistema_First(sistema, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("sistema="); msg.append(sistema); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the first sistemi in the ordered set where sistema = ?. * * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchBySistema_First(String sistema, OrderByComparator orderByComparator) throws SystemException { List<Sistemi> list = findBySistema(sistema, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last sistemi in the ordered set where sistema = ?. * * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findBySistema_Last(String sistema, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchBySistema_Last(sistema, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("sistema="); msg.append(sistema); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the last sistemi in the ordered set where sistema = ?. * * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchBySistema_Last(String sistema, OrderByComparator orderByComparator) throws SystemException { int count = countBySistema(sistema); List<Sistemi> list = findBySistema(sistema, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the sistemis before and after the current sistemi in the ordered set where sistema = ?. * * @param sistemaId the primary key of the current sistemi * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] findBySistema_PrevAndNext(long sistemaId, String sistema, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = getBySistema_PrevAndNext(session, sistemi, sistema, orderByComparator, true); array[1] = sistemi; array[2] = getBySistema_PrevAndNext(session, sistemi, sistema, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi getBySistema_PrevAndNext(Session session, Sistemi sistemi, String sistema, 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_SISTEMI_WHERE); if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_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); } } } } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis that the user has permission to view where sistema = ?. * * @param sistema the sistema * @return the matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindBySistema(String sistema) throws SystemException { return filterFindBySistema(sistema, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis that the user has permission to view where sistema = ?. * * <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 sistema the sistema * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindBySistema(String sistema, int start, int end) throws SystemException { return filterFindBySistema(sistema, start, end, null); } /** * Returns an ordered range of all the sistemis that the user has permissions to view where sistema = ?. * * <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 sistema the sistema * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindBySistema(String sistema, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findBySistema(sistema, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } return (List<Sistemi>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the sistemis before and after the current sistemi in the ordered set of sistemis that the user has permission to view where sistema = ?. * * @param sistemaId the primary key of the current sistemi * @param sistema the sistema * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] filterFindBySistema_PrevAndNext(long sistemaId, String sistema, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findBySistema_PrevAndNext(sistemaId, sistema, orderByComparator); } Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = filterGetBySistema_PrevAndNext(session, sistemi, sistema, orderByComparator, true); array[1] = sistemi; array[2] = filterGetBySistema_PrevAndNext(session, sistemi, sistema, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi filterGetBySistema_PrevAndNext(Session session, Sistemi sistemi, String sistema, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis where descrizione = ?. * * @param descrizione the descrizione * @return the matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByDescrizione(String descrizione) throws SystemException { return findByDescrizione(descrizione, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis where descrizione = ?. * * <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 descrizione the descrizione * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByDescrizione(String descrizione, int start, int end) throws SystemException { return findByDescrizione(descrizione, start, end, null); } /** * Returns an ordered range of all the sistemis where descrizione = ?. * * <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 descrizione the descrizione * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByDescrizione(String descrizione, 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_DESCRIZIONE; finderArgs = new Object[] { descrizione }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_DESCRIZIONE; finderArgs = new Object[] { descrizione, start, end, orderByComparator }; } List<Sistemi> list = (List<Sistemi>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Sistemi sistemi : list) { if (!Validator.equals(descrizione, sistemi.getDescrizione())) { list = null; break; } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SISTEMI_WHERE); if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2); } } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } list = (List<Sistemi>) 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 sistemi in the ordered set where descrizione = ?. * * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByDescrizione_First(String descrizione, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByDescrizione_First(descrizione, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("descrizione="); msg.append(descrizione); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the first sistemi in the ordered set where descrizione = ?. * * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByDescrizione_First(String descrizione, OrderByComparator orderByComparator) throws SystemException { List<Sistemi> list = findByDescrizione(descrizione, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last sistemi in the ordered set where descrizione = ?. * * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByDescrizione_Last(String descrizione, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByDescrizione_Last(descrizione, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("descrizione="); msg.append(descrizione); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the last sistemi in the ordered set where descrizione = ?. * * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByDescrizione_Last(String descrizione, OrderByComparator orderByComparator) throws SystemException { int count = countByDescrizione(descrizione); List<Sistemi> list = findByDescrizione(descrizione, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the sistemis before and after the current sistemi in the ordered set where descrizione = ?. * * @param sistemaId the primary key of the current sistemi * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] findByDescrizione_PrevAndNext(long sistemaId, String descrizione, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = getByDescrizione_PrevAndNext(session, sistemi, descrizione, orderByComparator, true); array[1] = sistemi; array[2] = getByDescrizione_PrevAndNext(session, sistemi, descrizione, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi getByDescrizione_PrevAndNext(Session session, Sistemi sistemi, String descrizione, 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_SISTEMI_WHERE); if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_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); } } } } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis that the user has permission to view where descrizione = ?. * * @param descrizione the descrizione * @return the matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByDescrizione(String descrizione) throws SystemException { return filterFindByDescrizione(descrizione, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis that the user has permission to view where descrizione = ?. * * <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 descrizione the descrizione * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByDescrizione(String descrizione, int start, int end) throws SystemException { return filterFindByDescrizione(descrizione, start, end, null); } /** * Returns an ordered range of all the sistemis that the user has permissions to view where descrizione = ?. * * <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 descrizione the descrizione * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByDescrizione(String descrizione, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByDescrizione(descrizione, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } return (List<Sistemi>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the sistemis before and after the current sistemi in the ordered set of sistemis that the user has permission to view where descrizione = ?. * * @param sistemaId the primary key of the current sistemi * @param descrizione the descrizione * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] filterFindByDescrizione_PrevAndNext(long sistemaId, String descrizione, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByDescrizione_PrevAndNext(sistemaId, descrizione, orderByComparator); } Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = filterGetByDescrizione_PrevAndNext(session, sistemi, descrizione, orderByComparator, true); array[1] = sistemi; array[2] = filterGetByDescrizione_PrevAndNext(session, sistemi, descrizione, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi filterGetByDescrizione_PrevAndNext(Session session, Sistemi sistemi, String descrizione, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis where status = ?. * * @param status the status * @return the matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStatus(String status) throws SystemException { return findByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis where status = ?. * * <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 status the status * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStatus(String status, int start, int end) throws SystemException { return findByStatus(status, start, end, null); } /** * Returns an ordered range of all the sistemis where status = ?. * * <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 status the status * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStatus(String status, 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_STATUS; finderArgs = new Object[] { status }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STATUS; finderArgs = new Object[] { status, start, end, orderByComparator }; } List<Sistemi> list = (List<Sistemi>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Sistemi sistemi : list) { if (!Validator.equals(status, sistemi.getStatus())) { list = null; break; } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SISTEMI_WHERE); if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_2); } } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } list = (List<Sistemi>) 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 sistemi in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByStatus_First(String status, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByStatus_First(status, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the first sistemi in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByStatus_First(String status, OrderByComparator orderByComparator) throws SystemException { List<Sistemi> list = findByStatus(status, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last sistemi in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByStatus_Last(String status, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByStatus_Last(status, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("status="); msg.append(status); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the last sistemi in the ordered set where status = ?. * * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByStatus_Last(String status, OrderByComparator orderByComparator) throws SystemException { int count = countByStatus(status); List<Sistemi> list = findByStatus(status, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the sistemis before and after the current sistemi in the ordered set where status = ?. * * @param sistemaId the primary key of the current sistemi * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] findByStatus_PrevAndNext(long sistemaId, String status, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = getByStatus_PrevAndNext(session, sistemi, status, orderByComparator, true); array[1] = sistemi; array[2] = getByStatus_PrevAndNext(session, sistemi, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi getByStatus_PrevAndNext(Session session, Sistemi sistemi, String status, 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_SISTEMI_WHERE); if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_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); } } } } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis that the user has permission to view where status = ?. * * @param status the status * @return the matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStatus(String status) throws SystemException { return filterFindByStatus(status, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis that the user has permission to view where status = ?. * * <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 status the status * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStatus(String status, int start, int end) throws SystemException { return filterFindByStatus(status, start, end, null); } /** * Returns an ordered range of all the sistemis that the user has permissions to view where status = ?. * * <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 status the status * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStatus(String status, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByStatus(status, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } return (List<Sistemi>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the sistemis before and after the current sistemi in the ordered set of sistemis that the user has permission to view where status = ?. * * @param sistemaId the primary key of the current sistemi * @param status the status * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] filterFindByStatus_PrevAndNext(long sistemaId, String status, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByStatus_PrevAndNext(sistemaId, status, orderByComparator); } Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = filterGetByStatus_PrevAndNext(session, sistemi, status, orderByComparator, true); array[1] = sistemi; array[2] = filterGetByStatus_PrevAndNext(session, sistemi, status, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi filterGetByStatus_PrevAndNext(Session session, Sistemi sistemi, String status, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis where store = ?. * * @param store the store * @return the matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStore(String store) throws SystemException { return findByStore(store, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis where store = ?. * * <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 store the store * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStore(String store, int start, int end) throws SystemException { return findByStore(store, start, end, null); } /** * Returns an ordered range of all the sistemis where store = ?. * * <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 store the store * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findByStore(String store, 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_STORE; finderArgs = new Object[] { store }; } else { finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_STORE; finderArgs = new Object[] { store, start, end, orderByComparator }; } List<Sistemi> list = (List<Sistemi>) FinderCacheUtil.getResult(finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (Sistemi sistemi : list) { if (!Validator.equals(store, sistemi.getStore())) { list = null; break; } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_SISTEMI_WHERE); if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_2); } } if (orderByComparator != null) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } list = (List<Sistemi>) 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 sistemi in the ordered set where store = ?. * * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByStore_First(String store, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByStore_First(store, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("store="); msg.append(store); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the first sistemi in the ordered set where store = ?. * * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the first matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByStore_First(String store, OrderByComparator orderByComparator) throws SystemException { List<Sistemi> list = findByStore(store, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last sistemi in the ordered set where store = ?. * * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi findByStore_Last(String store, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = fetchByStore_Last(store, orderByComparator); if (sistemi != null) { return sistemi; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("store="); msg.append(store); msg.append(StringPool.CLOSE_CURLY_BRACE); throw new NoSuchSistemiException(msg.toString()); } /** * Returns the last sistemi in the ordered set where store = ?. * * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the last matching sistemi, or <code>null</code> if a matching sistemi could not be found * @throws SystemException if a system exception occurred */ public Sistemi fetchByStore_Last(String store, OrderByComparator orderByComparator) throws SystemException { int count = countByStore(store); List<Sistemi> list = findByStore(store, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the sistemis before and after the current sistemi in the ordered set where store = ?. * * @param sistemaId the primary key of the current sistemi * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] findByStore_PrevAndNext(long sistemaId, String store, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = getByStore_PrevAndNext(session, sistemi, store, orderByComparator, true); array[1] = sistemi; array[2] = getByStore_PrevAndNext(session, sistemi, store, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi getByStore_PrevAndNext(Session session, Sistemi sistemi, String store, 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_SISTEMI_WHERE); if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_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); } } } } else { query.append(SistemiModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis that the user has permission to view where store = ?. * * @param store the store * @return the matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStore(String store) throws SystemException { return filterFindByStore(store, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis that the user has permission to view where store = ?. * * <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 store the store * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStore(String store, int start, int end) throws SystemException { return filterFindByStore(store, start, end, null); } /** * Returns an ordered range of all the sistemis that the user has permissions to view where store = ?. * * <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 store the store * @param start the lower bound of the range of sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public List<Sistemi> filterFindByStore(String store, int start, int end, OrderByComparator orderByComparator) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByStore(store, start, end, orderByComparator); } StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(3 + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { if (getDB().isSupportsInlineDistinct()) { appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else { appendOrderByComparator(query, _ORDER_BY_ENTITY_TABLE, orderByComparator); } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } return (List<Sistemi>) QueryUtil.list(q, getDialect(), start, end); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the sistemis before and after the current sistemi in the ordered set of sistemis that the user has permission to view where store = ?. * * @param sistemaId the primary key of the current sistemi * @param store the store * @param orderByComparator the comparator to order the set by (optionally <code>null</code>) * @return the previous, current, and next sistemi * @throws com.appuntivari.esempio.NoSuchSistemiException if a sistemi with the primary key could not be found * @throws SystemException if a system exception occurred */ public Sistemi[] filterFindByStore_PrevAndNext(long sistemaId, String store, OrderByComparator orderByComparator) throws NoSuchSistemiException, SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return findByStore_PrevAndNext(sistemaId, store, orderByComparator); } Sistemi sistemi = findByPrimaryKey(sistemaId); Session session = null; try { session = openSession(); Sistemi[] array = new SistemiImpl[3]; array[0] = filterGetByStore_PrevAndNext(session, sistemi, store, orderByComparator, true); array[1] = sistemi; array[2] = filterGetByStore_PrevAndNext(session, sistemi, store, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected Sistemi filterGetByStore_PrevAndNext(Session session, Sistemi sistemi, String store, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler(6 + (orderByComparator.getOrderByFields().length * 6)); } else { query = new StringBundler(3); } if (getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_WHERE); } else { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1); } if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_2); } } if (!getDB().isSupportsInlineDistinct()) { query.append(_FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2); } if (orderByComparator != null) { String[] orderByConditionFields = orderByComparator.getOrderByConditionFields(); if (orderByConditionFields.length > 0) { query.append(WHERE_AND); } for (int i = 0; i < orderByConditionFields.length; i++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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++) { if (getDB().isSupportsInlineDistinct()) { query.append(_ORDER_BY_ENTITY_ALIAS); } else { query.append(_ORDER_BY_ENTITY_TABLE); } 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); } } } } else { if (getDB().isSupportsInlineDistinct()) { query.append(SistemiModelImpl.ORDER_BY_JPQL); } else { query.append(SistemiModelImpl.ORDER_BY_SQL); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); SQLQuery q = session.createSQLQuery(sql); q.setFirstResult(0); q.setMaxResults(2); if (getDB().isSupportsInlineDistinct()) { q.addEntity(_FILTER_ENTITY_ALIAS, SistemiImpl.class); } else { q.addEntity(_FILTER_ENTITY_TABLE, SistemiImpl.class); } QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } if (orderByComparator != null) { Object[] values = orderByComparator.getOrderByConditionValues(sistemi); for (Object value : values) { qPos.add(value); } } List<Sistemi> list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Returns all the sistemis. * * @return the sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findAll() throws SystemException { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the sistemis. * * <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 sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @return the range of sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> findAll(int start, int end) throws SystemException { return findAll(start, end, null); } /** * Returns an ordered range of all the sistemis. * * <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 sistemis * @param end the upper bound of the range of sistemis (not inclusive) * @param orderByComparator the comparator to order the results by (optionally <code>null</code>) * @return the ordered range of sistemis * @throws SystemException if a system exception occurred */ public List<Sistemi> 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<Sistemi> list = (List<Sistemi>) 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_SISTEMI); appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_SISTEMI.concat(SistemiModelImpl.ORDER_BY_JPQL); } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (orderByComparator == null) { list = (List<Sistemi>) QueryUtil.list(q, getDialect(), start, end, false); Collections.sort(list); } else { list = (List<Sistemi>) 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 sistemis where sistema = ? from the database. * * @param sistema the sistema * @throws SystemException if a system exception occurred */ public void removeBySistema(String sistema) throws SystemException { for (Sistemi sistemi : findBySistema(sistema)) { remove(sistemi); } } /** * Removes all the sistemis where descrizione = ? from the database. * * @param descrizione the descrizione * @throws SystemException if a system exception occurred */ public void removeByDescrizione(String descrizione) throws SystemException { for (Sistemi sistemi : findByDescrizione(descrizione)) { remove(sistemi); } } /** * Removes all the sistemis where status = ? from the database. * * @param status the status * @throws SystemException if a system exception occurred */ public void removeByStatus(String status) throws SystemException { for (Sistemi sistemi : findByStatus(status)) { remove(sistemi); } } /** * Removes all the sistemis where store = ? from the database. * * @param store the store * @throws SystemException if a system exception occurred */ public void removeByStore(String store) throws SystemException { for (Sistemi sistemi : findByStore(store)) { remove(sistemi); } } /** * Removes all the sistemis from the database. * * @throws SystemException if a system exception occurred */ public void removeAll() throws SystemException { for (Sistemi sistemi : findAll()) { remove(sistemi); } } /** * Returns the number of sistemis where sistema = ?. * * @param sistema the sistema * @return the number of matching sistemis * @throws SystemException if a system exception occurred */ public int countBySistema(String sistema) throws SystemException { Object[] finderArgs = new Object[] { sistema }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_SISTEMA, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SISTEMI_WHERE); if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2); } } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_SISTEMA, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of sistemis that the user has permission to view where sistema = ?. * * @param sistema the sistema * @return the number of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountBySistema(String sistema) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countBySistema(sistema); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_SISTEMI_WHERE); if (sistema == null) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_1); } else { if (sistema.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_3); } else { query.append(_FINDER_COLUMN_SISTEMA_SISTEMA_2); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (sistema != null) { qPos.add(sistema); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of sistemis where descrizione = ?. * * @param descrizione the descrizione * @return the number of matching sistemis * @throws SystemException if a system exception occurred */ public int countByDescrizione(String descrizione) throws SystemException { Object[] finderArgs = new Object[] { descrizione }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_DESCRIZIONE, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SISTEMI_WHERE); if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2); } } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_DESCRIZIONE, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of sistemis that the user has permission to view where descrizione = ?. * * @param descrizione the descrizione * @return the number of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByDescrizione(String descrizione) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countByDescrizione(descrizione); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_SISTEMI_WHERE); if (descrizione == null) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1); } else { if (descrizione.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3); } else { query.append(_FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (descrizione != null) { qPos.add(descrizione); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of sistemis where status = ?. * * @param status the status * @return the number of matching sistemis * @throws SystemException if a system exception occurred */ public int countByStatus(String status) throws SystemException { Object[] finderArgs = new Object[] { status }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STATUS, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SISTEMI_WHERE); if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_2); } } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STATUS, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of sistemis that the user has permission to view where status = ?. * * @param status the status * @return the number of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByStatus(String status) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countByStatus(status); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_SISTEMI_WHERE); if (status == null) { query.append(_FINDER_COLUMN_STATUS_STATUS_1); } else { if (status.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STATUS_STATUS_3); } else { query.append(_FINDER_COLUMN_STATUS_STATUS_2); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (status != null) { qPos.add(status); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of sistemis where store = ?. * * @param store the store * @return the number of matching sistemis * @throws SystemException if a system exception occurred */ public int countByStore(String store) throws SystemException { Object[] finderArgs = new Object[] { store }; Long count = (Long) FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_STORE, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_SISTEMI_WHERE); if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_2); } } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } count = (Long) q.uniqueResult(); } catch (Exception e) { throw processException(e); } finally { if (count == null) { count = Long.valueOf(0); } FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_STORE, finderArgs, count); closeSession(session); } } return count.intValue(); } /** * Returns the number of sistemis that the user has permission to view where store = ?. * * @param store the store * @return the number of matching sistemis that the user has permission to view * @throws SystemException if a system exception occurred */ public int filterCountByStore(String store) throws SystemException { if (!InlineSQLHelperUtil.isEnabled()) { return countByStore(store); } StringBundler query = new StringBundler(2); query.append(_FILTER_SQL_COUNT_SISTEMI_WHERE); if (store == null) { query.append(_FINDER_COLUMN_STORE_STORE_1); } else { if (store.equals(StringPool.BLANK)) { query.append(_FINDER_COLUMN_STORE_STORE_3); } else { query.append(_FINDER_COLUMN_STORE_STORE_2); } } String sql = InlineSQLHelperUtil.replacePermissionCheck(query.toString(), Sistemi.class.getName(), _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN); Session session = null; try { session = openSession(); SQLQuery q = session.createSQLQuery(sql); q.addScalar(COUNT_COLUMN_NAME, com.liferay.portal.kernel.dao.orm.Type.LONG); QueryPos qPos = QueryPos.getInstance(q); if (store != null) { qPos.add(store); } Long count = (Long) q.uniqueResult(); return count.intValue(); } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } /** * Returns the number of sistemis. * * @return the number of sistemis * @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_SISTEMI); 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 sistemi persistence. */ public void afterPropertiesSet() { String[] listenerClassNames = StringUtil.split(GetterUtil.getString(com.liferay.util.service.ServiceProps .get("value.object.listener.com.appuntivari.esempio.model.Sistemi"))); if (listenerClassNames.length > 0) { try { List<ModelListener<Sistemi>> listenersList = new ArrayList<ModelListener<Sistemi>>(); for (String listenerClassName : listenerClassNames) { Class<?> clazz = getClass(); listenersList.add((ModelListener<Sistemi>) InstanceFactory.newInstance(clazz.getClassLoader(), listenerClassName)); } listeners = listenersList.toArray(new ModelListener[listenersList.size()]); } catch (Exception e) { _log.error(e); } } } public void destroy() { EntityCacheUtil.removeCache(SistemiImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = ExternalUsersPersistence.class) protected ExternalUsersPersistence externalUsersPersistence; @BeanReference(type = RelazioniSistemiPersistence.class) protected RelazioniSistemiPersistence relazioniSistemiPersistence; @BeanReference(type = SistemiPersistence.class) protected SistemiPersistence sistemiPersistence; @BeanReference(type = ResourcePersistence.class) protected ResourcePersistence resourcePersistence; @BeanReference(type = UserPersistence.class) protected UserPersistence userPersistence; private static final String _SQL_SELECT_SISTEMI = "SELECT sistemi FROM Sistemi sistemi"; private static final String _SQL_SELECT_SISTEMI_WHERE = "SELECT sistemi FROM Sistemi sistemi WHERE "; private static final String _SQL_COUNT_SISTEMI = "SELECT COUNT(sistemi) FROM Sistemi sistemi"; private static final String _SQL_COUNT_SISTEMI_WHERE = "SELECT COUNT(sistemi) FROM Sistemi sistemi WHERE "; private static final String _FINDER_COLUMN_SISTEMA_SISTEMA_1 = "sistemi.sistema IS NULL"; private static final String _FINDER_COLUMN_SISTEMA_SISTEMA_2 = "sistemi.sistema = ?"; private static final String _FINDER_COLUMN_SISTEMA_SISTEMA_3 = "(sistemi.sistema IS NULL OR sistemi.sistema = ?)"; private static final String _FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_1 = "sistemi.descrizione IS NULL"; private static final String _FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_2 = "sistemi.descrizione = ?"; private static final String _FINDER_COLUMN_DESCRIZIONE_DESCRIZIONE_3 = "(sistemi.descrizione IS NULL OR sistemi.descrizione = ?)"; private static final String _FINDER_COLUMN_STATUS_STATUS_1 = "sistemi.status IS NULL"; private static final String _FINDER_COLUMN_STATUS_STATUS_2 = "sistemi.status = ?"; private static final String _FINDER_COLUMN_STATUS_STATUS_3 = "(sistemi.status IS NULL OR sistemi.status = ?)"; private static final String _FINDER_COLUMN_STORE_STORE_1 = "sistemi.store IS NULL"; private static final String _FINDER_COLUMN_STORE_STORE_2 = "sistemi.store = ?"; private static final String _FINDER_COLUMN_STORE_STORE_3 = "(sistemi.store IS NULL OR sistemi.store = ?)"; private static final String _FILTER_ENTITY_TABLE_FILTER_PK_COLUMN = "sistemi.sistemaId"; private static final String _FILTER_SQL_SELECT_SISTEMI_WHERE = "SELECT DISTINCT {sistemi.*} FROM AV_Sistemi sistemi WHERE "; private static final String _FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_1 = "SELECT {AV_Sistemi.*} FROM (SELECT DISTINCT sistemi.sistemaId FROM AV_Sistemi sistemi WHERE "; private static final String _FILTER_SQL_SELECT_SISTEMI_NO_INLINE_DISTINCT_WHERE_2 = ") TEMP_TABLE INNER JOIN AV_Sistemi ON TEMP_TABLE.sistemaId = AV_Sistemi.sistemaId"; private static final String _FILTER_SQL_COUNT_SISTEMI_WHERE = "SELECT COUNT(DISTINCT sistemi.sistemaId) AS COUNT_VALUE FROM AV_Sistemi sistemi WHERE "; private static final String _FILTER_ENTITY_ALIAS = "sistemi"; private static final String _FILTER_ENTITY_TABLE = "AV_Sistemi"; private static final String _ORDER_BY_ENTITY_ALIAS = "sistemi."; private static final String _ORDER_BY_ENTITY_TABLE = "AV_Sistemi."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No Sistemi exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No Sistemi 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(SistemiPersistenceImpl.class); private static Sistemi _nullSistemi = new SistemiImpl() { @Override public Object clone() { return this; } @Override public CacheModel<Sistemi> toCacheModel() { return _nullSistemiCacheModel; } }; private static CacheModel<Sistemi> _nullSistemiCacheModel = new CacheModel<Sistemi>() { public Sistemi toEntityModel() { return _nullSistemi; } }; }