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

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

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

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

import aQute.bnd.annotation.ProviderType;

import com.liferay.portal.kernel.bean.BeanReference;
import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
import com.liferay.portal.kernel.dao.orm.FinderPath;
import com.liferay.portal.kernel.dao.orm.Query;
import com.liferay.portal.kernel.dao.orm.QueryPos;
import com.liferay.portal.kernel.dao.orm.QueryUtil;
import com.liferay.portal.kernel.dao.orm.Session;
import com.liferay.portal.kernel.exception.NoSuchLayoutBranchException;
import com.liferay.portal.kernel.log.Log;
import com.liferay.portal.kernel.log.LogFactoryUtil;
import com.liferay.portal.kernel.model.LayoutBranch;
import com.liferay.portal.kernel.service.persistence.CompanyProvider;
import com.liferay.portal.kernel.service.persistence.CompanyProviderWrapper;
import com.liferay.portal.kernel.service.persistence.LayoutBranchPersistence;
import com.liferay.portal.kernel.service.persistence.impl.BasePersistenceImpl;
import com.liferay.portal.kernel.util.OrderByComparator;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.model.impl.LayoutBranchImpl;
import com.liferay.portal.model.impl.LayoutBranchModelImpl;

import java.io.Serializable;

import java.lang.reflect.InvocationHandler;

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

/**
 * The persistence implementation for the layout branch service.
 *
 * 

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

* * @author Brian Wing Shun Chan * @generated */ @ProviderType public class LayoutBranchPersistenceImpl extends BasePersistenceImpl implements LayoutBranchPersistence { /* * NOTE FOR DEVELOPERS: * * Never modify or reference this class directly. Always use LayoutBranchUtil to access the layout branch persistence. Modify service.xml and rerun ServiceBuilder to regenerate this class. */ public static final String FINDER_CLASS_NAME_ENTITY = LayoutBranchImpl.class.getName(); public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List1"; public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY + ".List2"; private FinderPath _finderPathWithPaginationFindAll; private FinderPath _finderPathWithoutPaginationFindAll; private FinderPath _finderPathCountAll; private FinderPath _finderPathWithPaginationFindByLayoutSetBranchId; private FinderPath _finderPathWithoutPaginationFindByLayoutSetBranchId; private FinderPath _finderPathCountByLayoutSetBranchId; /** * Returns all the layout branchs where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @return the matching layout branchs */ @Override public List findByLayoutSetBranchId(long layoutSetBranchId) { return findByLayoutSetBranchId( layoutSetBranchId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the layout branchs where layoutSetBranchId = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @return the range of matching layout branchs */ @Override public List findByLayoutSetBranchId( long layoutSetBranchId, int start, int end) { return findByLayoutSetBranchId(layoutSetBranchId, start, end, null); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching layout branchs */ @Override public List findByLayoutSetBranchId( long layoutSetBranchId, int start, int end, OrderByComparator orderByComparator) { return findByLayoutSetBranchId( layoutSetBranchId, start, end, orderByComparator, true); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching layout branchs */ @Override public List findByLayoutSetBranchId( long layoutSetBranchId, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByLayoutSetBranchId; finderArgs = new Object[] {layoutSetBranchId}; } else { finderPath = _finderPathWithPaginationFindByLayoutSetBranchId; finderArgs = new Object[] { layoutSetBranchId, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (LayoutBranch layoutBranch : list) { if ((layoutSetBranchId != layoutBranch.getLayoutSetBranchId())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 3 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2); if (orderByComparator != null) { appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByLayoutSetBranchId_First( long layoutSetBranchId, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByLayoutSetBranchId_First( layoutSetBranchId, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByLayoutSetBranchId_First( long layoutSetBranchId, OrderByComparator orderByComparator) { List list = findByLayoutSetBranchId( layoutSetBranchId, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByLayoutSetBranchId_Last( long layoutSetBranchId, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByLayoutSetBranchId_Last( layoutSetBranchId, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(4); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByLayoutSetBranchId_Last( long layoutSetBranchId, OrderByComparator orderByComparator) { int count = countByLayoutSetBranchId(layoutSetBranchId); if (count == 0) { return null; } List list = findByLayoutSetBranchId( layoutSetBranchId, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the layout branchs before and after the current layout branch in the ordered set where layoutSetBranchId = ?. * * @param layoutBranchId the primary key of the current layout branch * @param layoutSetBranchId the layout set branch ID * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next layout branch * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch[] findByLayoutSetBranchId_PrevAndNext( long layoutBranchId, long layoutSetBranchId, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = findByPrimaryKey(layoutBranchId); Session session = null; try { session = openSession(); LayoutBranch[] array = new LayoutBranchImpl[3]; array[0] = getByLayoutSetBranchId_PrevAndNext( session, layoutBranch, layoutSetBranchId, orderByComparator, true); array[1] = layoutBranch; array[2] = getByLayoutSetBranchId_PrevAndNext( session, layoutBranch, layoutSetBranchId, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected LayoutBranch getByLayoutSetBranchId_PrevAndNext( Session session, LayoutBranch layoutBranch, long layoutSetBranchId, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 4 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(3); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_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(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(layoutBranch)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the layout branchs where layoutSetBranchId = ? from the database. * * @param layoutSetBranchId the layout set branch ID */ @Override public void removeByLayoutSetBranchId(long layoutSetBranchId) { for (LayoutBranch layoutBranch : findByLayoutSetBranchId( layoutSetBranchId, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(layoutBranch); } } /** * Returns the number of layout branchs where layoutSetBranchId = ?. * * @param layoutSetBranchId the layout set branch ID * @return the number of matching layout branchs */ @Override public int countByLayoutSetBranchId(long layoutSetBranchId) { FinderPath finderPath = _finderPathCountByLayoutSetBranchId; Object[] finderArgs = new Object[] {layoutSetBranchId}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(2); query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_LAYOUTSETBRANCHID_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ?"; private FinderPath _finderPathWithPaginationFindByL_P; private FinderPath _finderPathWithoutPaginationFindByL_P; private FinderPath _finderPathCountByL_P; /** * Returns all the layout branchs where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @return the matching layout branchs */ @Override public List findByL_P(long layoutSetBranchId, long plid) { return findByL_P( layoutSetBranchId, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the layout branchs where layoutSetBranchId = ? and plid = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @return the range of matching layout branchs */ @Override public List findByL_P( long layoutSetBranchId, long plid, int start, int end) { return findByL_P(layoutSetBranchId, plid, start, end, null); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ? and plid = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching layout branchs */ @Override public List findByL_P( long layoutSetBranchId, long plid, int start, int end, OrderByComparator orderByComparator) { return findByL_P( layoutSetBranchId, plid, start, end, orderByComparator, true); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ? and plid = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching layout branchs */ @Override public List findByL_P( long layoutSetBranchId, long plid, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByL_P; finderArgs = new Object[] {layoutSetBranchId, plid}; } else { finderPath = _finderPathWithPaginationFindByL_P; finderArgs = new Object[] { layoutSetBranchId, plid, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (LayoutBranch layoutBranch : list) { if ((layoutSetBranchId != layoutBranch.getLayoutSetBranchId()) || (plid != layoutBranch.getPlid())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 4 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_PLID_2); if (orderByComparator != null) { appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByL_P_First( long layoutSetBranchId, long plid, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByL_P_First( layoutSetBranchId, plid, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append(", plid="); msg.append(plid); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_First( long layoutSetBranchId, long plid, OrderByComparator orderByComparator) { List list = findByL_P( layoutSetBranchId, plid, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByL_P_Last( long layoutSetBranchId, long plid, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByL_P_Last( layoutSetBranchId, plid, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(6); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append(", plid="); msg.append(plid); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_Last( long layoutSetBranchId, long plid, OrderByComparator orderByComparator) { int count = countByL_P(layoutSetBranchId, plid); if (count == 0) { return null; } List list = findByL_P( layoutSetBranchId, plid, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the layout branchs before and after the current layout branch in the ordered set where layoutSetBranchId = ? and plid = ?. * * @param layoutBranchId the primary key of the current layout branch * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next layout branch * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch[] findByL_P_PrevAndNext( long layoutBranchId, long layoutSetBranchId, long plid, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = findByPrimaryKey(layoutBranchId); Session session = null; try { session = openSession(); LayoutBranch[] array = new LayoutBranchImpl[3]; array[0] = getByL_P_PrevAndNext( session, layoutBranch, layoutSetBranchId, plid, orderByComparator, true); array[1] = layoutBranch; array[2] = getByL_P_PrevAndNext( session, layoutBranch, layoutSetBranchId, plid, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected LayoutBranch getByL_P_PrevAndNext( Session session, LayoutBranch layoutBranch, long layoutSetBranchId, long plid, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 5 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(4); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_PLID_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(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(layoutBranch)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the layout branchs where layoutSetBranchId = ? and plid = ? from the database. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid */ @Override public void removeByL_P(long layoutSetBranchId, long plid) { for (LayoutBranch layoutBranch : findByL_P( layoutSetBranchId, plid, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(layoutBranch); } } /** * Returns the number of layout branchs where layoutSetBranchId = ? and plid = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @return the number of matching layout branchs */ @Override public int countByL_P(long layoutSetBranchId, long plid) { FinderPath finderPath = _finderPathCountByL_P; Object[] finderArgs = new Object[] {layoutSetBranchId, plid}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(3); query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_PLID_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_L_P_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND "; private static final String _FINDER_COLUMN_L_P_PLID_2 = "layoutBranch.plid = ?"; private FinderPath _finderPathFetchByL_P_N; private FinderPath _finderPathCountByL_P_N; /** * Returns the layout branch where layoutSetBranchId = ? and plid = ? and name = ? or throws a NoSuchLayoutBranchException if it could not be found. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param name the name * @return the matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByL_P_N( long layoutSetBranchId, long plid, String name) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByL_P_N(layoutSetBranchId, plid, name); if (layoutBranch == null) { StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append(", plid="); msg.append(plid); msg.append(", name="); msg.append(name); msg.append("}"); if (_log.isDebugEnabled()) { _log.debug(msg.toString()); } throw new NoSuchLayoutBranchException(msg.toString()); } return layoutBranch; } /** * Returns the layout branch where layoutSetBranchId = ? and plid = ? and name = ? or returns null if it could not be found. Uses the finder cache. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param name the name * @return the matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_N( long layoutSetBranchId, long plid, String name) { return fetchByL_P_N(layoutSetBranchId, plid, name, true); } /** * Returns the layout branch where layoutSetBranchId = ? and plid = ? and name = ? or returns null if it could not be found, optionally using the finder cache. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param name the name * @param retrieveFromCache whether to retrieve from the finder cache * @return the matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_N( long layoutSetBranchId, long plid, String name, boolean retrieveFromCache) { name = Objects.toString(name, ""); Object[] finderArgs = new Object[] {layoutSetBranchId, plid, name}; Object result = null; if (retrieveFromCache) { result = FinderCacheUtil.getResult( _finderPathFetchByL_P_N, finderArgs, this); } if (result instanceof LayoutBranch) { LayoutBranch layoutBranch = (LayoutBranch)result; if ((layoutSetBranchId != layoutBranch.getLayoutSetBranchId()) || (plid != layoutBranch.getPlid()) || !Objects.equals(name, layoutBranch.getName())) { result = null; } } if (result == null) { StringBundler query = new StringBundler(5); query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_N_PLID_2); boolean bindName = false; if (name.isEmpty()) { query.append(_FINDER_COLUMN_L_P_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_L_P_N_NAME_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); if (bindName) { qPos.add(name); } List list = q.list(); if (list.isEmpty()) { FinderCacheUtil.putResult( _finderPathFetchByL_P_N, finderArgs, list); } else { LayoutBranch layoutBranch = list.get(0); result = layoutBranch; cacheResult(layoutBranch); } } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathFetchByL_P_N, finderArgs); throw processException(e); } finally { closeSession(session); } } if (result instanceof List) { return null; } else { return (LayoutBranch)result; } } /** * Removes the layout branch where layoutSetBranchId = ? and plid = ? and name = ? from the database. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param name the name * @return the layout branch that was removed */ @Override public LayoutBranch removeByL_P_N( long layoutSetBranchId, long plid, String name) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = findByL_P_N(layoutSetBranchId, plid, name); return remove(layoutBranch); } /** * Returns the number of layout branchs where layoutSetBranchId = ? and plid = ? and name = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param name the name * @return the number of matching layout branchs */ @Override public int countByL_P_N(long layoutSetBranchId, long plid, String name) { name = Objects.toString(name, ""); FinderPath finderPath = _finderPathCountByL_P_N; Object[] finderArgs = new Object[] {layoutSetBranchId, plid, name}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_N_PLID_2); boolean bindName = false; if (name.isEmpty()) { query.append(_FINDER_COLUMN_L_P_N_NAME_3); } else { bindName = true; query.append(_FINDER_COLUMN_L_P_N_NAME_2); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); if (bindName) { qPos.add(name); } count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_L_P_N_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND "; private static final String _FINDER_COLUMN_L_P_N_PLID_2 = "layoutBranch.plid = ? AND "; private static final String _FINDER_COLUMN_L_P_N_NAME_2 = "layoutBranch.name = ?"; private static final String _FINDER_COLUMN_L_P_N_NAME_3 = "(layoutBranch.name IS NULL OR layoutBranch.name = '')"; private FinderPath _finderPathWithPaginationFindByL_P_M; private FinderPath _finderPathWithoutPaginationFindByL_P_M; private FinderPath _finderPathCountByL_P_M; /** * Returns all the layout branchs where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @return the matching layout branchs */ @Override public List findByL_P_M( long layoutSetBranchId, long plid, boolean master) { return findByL_P_M( layoutSetBranchId, plid, master, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the layout branchs where layoutSetBranchId = ? and plid = ? and master = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @return the range of matching layout branchs */ @Override public List findByL_P_M( long layoutSetBranchId, long plid, boolean master, int start, int end) { return findByL_P_M(layoutSetBranchId, plid, master, start, end, null); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ? and plid = ? and master = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @return the ordered range of matching layout branchs */ @Override public List findByL_P_M( long layoutSetBranchId, long plid, boolean master, int start, int end, OrderByComparator orderByComparator) { return findByL_P_M( layoutSetBranchId, plid, master, start, end, orderByComparator, true); } /** * Returns an ordered range of all the layout branchs where layoutSetBranchId = ? and plid = ? and master = ?. * *

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

* * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of matching layout branchs */ @Override public List findByL_P_M( long layoutSetBranchId, long plid, boolean master, int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindByL_P_M; finderArgs = new Object[] {layoutSetBranchId, plid, master}; } else { finderPath = _finderPathWithPaginationFindByL_P_M; finderArgs = new Object[] { layoutSetBranchId, plid, master, start, end, orderByComparator }; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); if ((list != null) && !list.isEmpty()) { for (LayoutBranch layoutBranch : list) { if ((layoutSetBranchId != layoutBranch.getLayoutSetBranchId()) || (plid != layoutBranch.getPlid()) || (master != layoutBranch.isMaster())) { list = null; break; } } } } if (list == null) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 5 + (orderByComparator.getOrderByFields().length * 2)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_M_PLID_2); query.append(_FINDER_COLUMN_L_P_M_MASTER_2); if (orderByComparator != null) { appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); } else if (pagination) { query.append(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); qPos.add(master); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByL_P_M_First( long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByL_P_M_First( layoutSetBranchId, plid, master, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append(", plid="); msg.append(plid); msg.append(", master="); msg.append(master); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the first layout branch in the ordered set where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param orderByComparator the comparator to order the set by (optionally null) * @return the first matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_M_First( long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator) { List list = findByL_P_M( layoutSetBranchId, plid, master, 0, 1, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch * @throws NoSuchLayoutBranchException if a matching layout branch could not be found */ @Override public LayoutBranch findByL_P_M_Last( long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByL_P_M_Last( layoutSetBranchId, plid, master, orderByComparator); if (layoutBranch != null) { return layoutBranch; } StringBundler msg = new StringBundler(8); msg.append(_NO_SUCH_ENTITY_WITH_KEY); msg.append("layoutSetBranchId="); msg.append(layoutSetBranchId); msg.append(", plid="); msg.append(plid); msg.append(", master="); msg.append(master); msg.append("}"); throw new NoSuchLayoutBranchException(msg.toString()); } /** * Returns the last layout branch in the ordered set where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param orderByComparator the comparator to order the set by (optionally null) * @return the last matching layout branch, or null if a matching layout branch could not be found */ @Override public LayoutBranch fetchByL_P_M_Last( long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator) { int count = countByL_P_M(layoutSetBranchId, plid, master); if (count == 0) { return null; } List list = findByL_P_M( layoutSetBranchId, plid, master, count - 1, count, orderByComparator); if (!list.isEmpty()) { return list.get(0); } return null; } /** * Returns the layout branchs before and after the current layout branch in the ordered set where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutBranchId the primary key of the current layout branch * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @param orderByComparator the comparator to order the set by (optionally null) * @return the previous, current, and next layout branch * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch[] findByL_P_M_PrevAndNext( long layoutBranchId, long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = findByPrimaryKey(layoutBranchId); Session session = null; try { session = openSession(); LayoutBranch[] array = new LayoutBranchImpl[3]; array[0] = getByL_P_M_PrevAndNext( session, layoutBranch, layoutSetBranchId, plid, master, orderByComparator, true); array[1] = layoutBranch; array[2] = getByL_P_M_PrevAndNext( session, layoutBranch, layoutSetBranchId, plid, master, orderByComparator, false); return array; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } protected LayoutBranch getByL_P_M_PrevAndNext( Session session, LayoutBranch layoutBranch, long layoutSetBranchId, long plid, boolean master, OrderByComparator orderByComparator, boolean previous) { StringBundler query = null; if (orderByComparator != null) { query = new StringBundler( 6 + (orderByComparator.getOrderByConditionFields().length * 3) + (orderByComparator.getOrderByFields().length * 3)); } else { query = new StringBundler(5); } query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_M_PLID_2); query.append(_FINDER_COLUMN_L_P_M_MASTER_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(LayoutBranchModelImpl.ORDER_BY_JPQL); } String sql = query.toString(); Query q = session.createQuery(sql); q.setFirstResult(0); q.setMaxResults(2); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); qPos.add(master); if (orderByComparator != null) { for (Object orderByConditionValue : orderByComparator.getOrderByConditionValues(layoutBranch)) { qPos.add(orderByConditionValue); } } List list = q.list(); if (list.size() == 2) { return list.get(1); } else { return null; } } /** * Removes all the layout branchs where layoutSetBranchId = ? and plid = ? and master = ? from the database. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master */ @Override public void removeByL_P_M( long layoutSetBranchId, long plid, boolean master) { for (LayoutBranch layoutBranch : findByL_P_M( layoutSetBranchId, plid, master, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null)) { remove(layoutBranch); } } /** * Returns the number of layout branchs where layoutSetBranchId = ? and plid = ? and master = ?. * * @param layoutSetBranchId the layout set branch ID * @param plid the plid * @param master the master * @return the number of matching layout branchs */ @Override public int countByL_P_M(long layoutSetBranchId, long plid, boolean master) { FinderPath finderPath = _finderPathCountByL_P_M; Object[] finderArgs = new Object[] {layoutSetBranchId, plid, master}; Long count = (Long)FinderCacheUtil.getResult( finderPath, finderArgs, this); if (count == null) { StringBundler query = new StringBundler(4); query.append(_SQL_COUNT_LAYOUTBRANCH_WHERE); query.append(_FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2); query.append(_FINDER_COLUMN_L_P_M_PLID_2); query.append(_FINDER_COLUMN_L_P_M_MASTER_2); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); QueryPos qPos = QueryPos.getInstance(q); qPos.add(layoutSetBranchId); qPos.add(plid); qPos.add(master); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult(finderPath, finderArgs, count); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } private static final String _FINDER_COLUMN_L_P_M_LAYOUTSETBRANCHID_2 = "layoutBranch.layoutSetBranchId = ? AND "; private static final String _FINDER_COLUMN_L_P_M_PLID_2 = "layoutBranch.plid = ? AND "; private static final String _FINDER_COLUMN_L_P_M_MASTER_2 = "layoutBranch.master = ?"; public LayoutBranchPersistenceImpl() { setModelClass(LayoutBranch.class); } /** * Caches the layout branch in the entity cache if it is enabled. * * @param layoutBranch the layout branch */ @Override public void cacheResult(LayoutBranch layoutBranch) { EntityCacheUtil.putResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, layoutBranch.getPrimaryKey(), layoutBranch); FinderCacheUtil.putResult( _finderPathFetchByL_P_N, new Object[] { layoutBranch.getLayoutSetBranchId(), layoutBranch.getPlid(), layoutBranch.getName() }, layoutBranch); layoutBranch.resetOriginalValues(); } /** * Caches the layout branchs in the entity cache if it is enabled. * * @param layoutBranchs the layout branchs */ @Override public void cacheResult(List layoutBranchs) { for (LayoutBranch layoutBranch : layoutBranchs) { if (EntityCacheUtil.getResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, layoutBranch.getPrimaryKey()) == null) { cacheResult(layoutBranch); } else { layoutBranch.resetOriginalValues(); } } } /** * Clears the cache for all layout branchs. * *

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

*/ @Override public void clearCache() { EntityCacheUtil.clearCache(LayoutBranchImpl.class); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } /** * Clears the cache for the layout branch. * *

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

*/ @Override public void clearCache(LayoutBranch layoutBranch) { EntityCacheUtil.removeResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, layoutBranch.getPrimaryKey()); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); clearUniqueFindersCache((LayoutBranchModelImpl)layoutBranch, true); } @Override public void clearCache(List layoutBranchs) { FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); for (LayoutBranch layoutBranch : layoutBranchs) { EntityCacheUtil.removeResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, layoutBranch.getPrimaryKey()); clearUniqueFindersCache((LayoutBranchModelImpl)layoutBranch, true); } } protected void cacheUniqueFindersCache( LayoutBranchModelImpl layoutBranchModelImpl) { Object[] args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid(), layoutBranchModelImpl.getName() }; FinderCacheUtil.putResult( _finderPathCountByL_P_N, args, Long.valueOf(1), false); FinderCacheUtil.putResult( _finderPathFetchByL_P_N, args, layoutBranchModelImpl, false); } protected void clearUniqueFindersCache( LayoutBranchModelImpl layoutBranchModelImpl, boolean clearCurrent) { if (clearCurrent) { Object[] args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid(), layoutBranchModelImpl.getName() }; FinderCacheUtil.removeResult(_finderPathCountByL_P_N, args); FinderCacheUtil.removeResult(_finderPathFetchByL_P_N, args); } if ((layoutBranchModelImpl.getColumnBitmask() & _finderPathFetchByL_P_N.getColumnBitmask()) != 0) { Object[] args = new Object[] { layoutBranchModelImpl.getOriginalLayoutSetBranchId(), layoutBranchModelImpl.getOriginalPlid(), layoutBranchModelImpl.getOriginalName() }; FinderCacheUtil.removeResult(_finderPathCountByL_P_N, args); FinderCacheUtil.removeResult(_finderPathFetchByL_P_N, args); } } /** * Creates a new layout branch with the primary key. Does not add the layout branch to the database. * * @param layoutBranchId the primary key for the new layout branch * @return the new layout branch */ @Override public LayoutBranch create(long layoutBranchId) { LayoutBranch layoutBranch = new LayoutBranchImpl(); layoutBranch.setNew(true); layoutBranch.setPrimaryKey(layoutBranchId); layoutBranch.setCompanyId(companyProvider.getCompanyId()); return layoutBranch; } /** * Removes the layout branch with the primary key from the database. Also notifies the appropriate model listeners. * * @param layoutBranchId the primary key of the layout branch * @return the layout branch that was removed * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch remove(long layoutBranchId) throws NoSuchLayoutBranchException { return remove((Serializable)layoutBranchId); } /** * Removes the layout branch with the primary key from the database. Also notifies the appropriate model listeners. * * @param primaryKey the primary key of the layout branch * @return the layout branch that was removed * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch remove(Serializable primaryKey) throws NoSuchLayoutBranchException { Session session = null; try { session = openSession(); LayoutBranch layoutBranch = (LayoutBranch)session.get( LayoutBranchImpl.class, primaryKey); if (layoutBranch == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchLayoutBranchException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return remove(layoutBranch); } catch (NoSuchLayoutBranchException nsee) { throw nsee; } catch (Exception e) { throw processException(e); } finally { closeSession(session); } } @Override protected LayoutBranch removeImpl(LayoutBranch layoutBranch) { Session session = null; try { session = openSession(); if (!session.contains(layoutBranch)) { layoutBranch = (LayoutBranch)session.get( LayoutBranchImpl.class, layoutBranch.getPrimaryKeyObj()); } if (layoutBranch != null) { session.delete(layoutBranch); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } if (layoutBranch != null) { clearCache(layoutBranch); } return layoutBranch; } @Override public LayoutBranch updateImpl(LayoutBranch layoutBranch) { boolean isNew = layoutBranch.isNew(); if (!(layoutBranch instanceof LayoutBranchModelImpl)) { InvocationHandler invocationHandler = null; if (ProxyUtil.isProxyClass(layoutBranch.getClass())) { invocationHandler = ProxyUtil.getInvocationHandler( layoutBranch); throw new IllegalArgumentException( "Implement ModelWrapper in layoutBranch proxy " + invocationHandler.getClass()); } throw new IllegalArgumentException( "Implement ModelWrapper in custom LayoutBranch implementation " + layoutBranch.getClass()); } LayoutBranchModelImpl layoutBranchModelImpl = (LayoutBranchModelImpl)layoutBranch; Session session = null; try { session = openSession(); if (layoutBranch.isNew()) { session.save(layoutBranch); layoutBranch.setNew(false); } else { layoutBranch = (LayoutBranch)session.merge(layoutBranch); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); if (!LayoutBranchModelImpl.COLUMN_BITMASK_ENABLED) { FinderCacheUtil.clearCache( FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } else if (isNew) { Object[] args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId() }; FinderCacheUtil.removeResult( _finderPathCountByLayoutSetBranchId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByLayoutSetBranchId, args); args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid() }; FinderCacheUtil.removeResult(_finderPathCountByL_P, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P, args); args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid(), layoutBranchModelImpl.isMaster() }; FinderCacheUtil.removeResult(_finderPathCountByL_P_M, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P_M, args); FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindAll, FINDER_ARGS_EMPTY); } else { if ((layoutBranchModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByLayoutSetBranchId. getColumnBitmask()) != 0) { Object[] args = new Object[] { layoutBranchModelImpl.getOriginalLayoutSetBranchId() }; FinderCacheUtil.removeResult( _finderPathCountByLayoutSetBranchId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByLayoutSetBranchId, args); args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId() }; FinderCacheUtil.removeResult( _finderPathCountByLayoutSetBranchId, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByLayoutSetBranchId, args); } if ((layoutBranchModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByL_P.getColumnBitmask()) != 0) { Object[] args = new Object[] { layoutBranchModelImpl.getOriginalLayoutSetBranchId(), layoutBranchModelImpl.getOriginalPlid() }; FinderCacheUtil.removeResult(_finderPathCountByL_P, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P, args); args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid() }; FinderCacheUtil.removeResult(_finderPathCountByL_P, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P, args); } if ((layoutBranchModelImpl.getColumnBitmask() & _finderPathWithoutPaginationFindByL_P_M.getColumnBitmask()) != 0) { Object[] args = new Object[] { layoutBranchModelImpl.getOriginalLayoutSetBranchId(), layoutBranchModelImpl.getOriginalPlid(), layoutBranchModelImpl.getOriginalMaster() }; FinderCacheUtil.removeResult(_finderPathCountByL_P_M, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P_M, args); args = new Object[] { layoutBranchModelImpl.getLayoutSetBranchId(), layoutBranchModelImpl.getPlid(), layoutBranchModelImpl.isMaster() }; FinderCacheUtil.removeResult(_finderPathCountByL_P_M, args); FinderCacheUtil.removeResult( _finderPathWithoutPaginationFindByL_P_M, args); } } EntityCacheUtil.putResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, layoutBranch.getPrimaryKey(), layoutBranch, false); clearUniqueFindersCache(layoutBranchModelImpl, false); cacheUniqueFindersCache(layoutBranchModelImpl); layoutBranch.resetOriginalValues(); return layoutBranch; } /** * Returns the layout branch with the primary key or throws a com.liferay.portal.kernel.exception.NoSuchModelException if it could not be found. * * @param primaryKey the primary key of the layout branch * @return the layout branch * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch findByPrimaryKey(Serializable primaryKey) throws NoSuchLayoutBranchException { LayoutBranch layoutBranch = fetchByPrimaryKey(primaryKey); if (layoutBranch == null) { if (_log.isDebugEnabled()) { _log.debug(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } throw new NoSuchLayoutBranchException( _NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey); } return layoutBranch; } /** * Returns the layout branch with the primary key or throws a NoSuchLayoutBranchException if it could not be found. * * @param layoutBranchId the primary key of the layout branch * @return the layout branch * @throws NoSuchLayoutBranchException if a layout branch with the primary key could not be found */ @Override public LayoutBranch findByPrimaryKey(long layoutBranchId) throws NoSuchLayoutBranchException { return findByPrimaryKey((Serializable)layoutBranchId); } /** * Returns the layout branch with the primary key or returns null if it could not be found. * * @param primaryKey the primary key of the layout branch * @return the layout branch, or null if a layout branch with the primary key could not be found */ @Override public LayoutBranch fetchByPrimaryKey(Serializable primaryKey) { Serializable serializable = EntityCacheUtil.getResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, primaryKey); if (serializable == nullModel) { return null; } LayoutBranch layoutBranch = (LayoutBranch)serializable; if (layoutBranch == null) { Session session = null; try { session = openSession(); layoutBranch = (LayoutBranch)session.get( LayoutBranchImpl.class, primaryKey); if (layoutBranch != null) { cacheResult(layoutBranch); } else { EntityCacheUtil.putResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, primaryKey, nullModel); } } catch (Exception e) { EntityCacheUtil.removeResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, primaryKey); throw processException(e); } finally { closeSession(session); } } return layoutBranch; } /** * Returns the layout branch with the primary key or returns null if it could not be found. * * @param layoutBranchId the primary key of the layout branch * @return the layout branch, or null if a layout branch with the primary key could not be found */ @Override public LayoutBranch fetchByPrimaryKey(long layoutBranchId) { return fetchByPrimaryKey((Serializable)layoutBranchId); } @Override public Map fetchByPrimaryKeys( Set primaryKeys) { if (primaryKeys.isEmpty()) { return Collections.emptyMap(); } Map map = new HashMap(); if (primaryKeys.size() == 1) { Iterator iterator = primaryKeys.iterator(); Serializable primaryKey = iterator.next(); LayoutBranch layoutBranch = fetchByPrimaryKey(primaryKey); if (layoutBranch != null) { map.put(primaryKey, layoutBranch); } return map; } Set uncachedPrimaryKeys = null; for (Serializable primaryKey : primaryKeys) { Serializable serializable = EntityCacheUtil.getResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, primaryKey); if (serializable != nullModel) { if (serializable == null) { if (uncachedPrimaryKeys == null) { uncachedPrimaryKeys = new HashSet(); } uncachedPrimaryKeys.add(primaryKey); } else { map.put(primaryKey, (LayoutBranch)serializable); } } } if (uncachedPrimaryKeys == null) { return map; } StringBundler query = new StringBundler( uncachedPrimaryKeys.size() * 2 + 1); query.append(_SQL_SELECT_LAYOUTBRANCH_WHERE_PKS_IN); for (Serializable primaryKey : uncachedPrimaryKeys) { query.append((long)primaryKey); query.append(","); } query.setIndex(query.index() - 1); query.append(")"); String sql = query.toString(); Session session = null; try { session = openSession(); Query q = session.createQuery(sql); for (LayoutBranch layoutBranch : (List)q.list()) { map.put(layoutBranch.getPrimaryKeyObj(), layoutBranch); cacheResult(layoutBranch); uncachedPrimaryKeys.remove(layoutBranch.getPrimaryKeyObj()); } for (Serializable primaryKey : uncachedPrimaryKeys) { EntityCacheUtil.putResult( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchImpl.class, primaryKey, nullModel); } } catch (Exception e) { throw processException(e); } finally { closeSession(session); } return map; } /** * Returns all the layout branchs. * * @return the layout branchs */ @Override public List findAll() { return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null); } /** * Returns a range of all the layout branchs. * *

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

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

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

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

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

* * @param start the lower bound of the range of layout branchs * @param end the upper bound of the range of layout branchs (not inclusive) * @param orderByComparator the comparator to order the results by (optionally null) * @param retrieveFromCache whether to retrieve from the finder cache * @return the ordered range of layout branchs */ @Override public List findAll( int start, int end, OrderByComparator orderByComparator, boolean retrieveFromCache) { boolean pagination = true; FinderPath finderPath = null; Object[] finderArgs = null; if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) && (orderByComparator == null)) { pagination = false; finderPath = _finderPathWithoutPaginationFindAll; finderArgs = FINDER_ARGS_EMPTY; } else { finderPath = _finderPathWithPaginationFindAll; finderArgs = new Object[] {start, end, orderByComparator}; } List list = null; if (retrieveFromCache) { list = (List)FinderCacheUtil.getResult( finderPath, finderArgs, this); } if (list == null) { StringBundler query = null; String sql = null; if (orderByComparator != null) { query = new StringBundler( 2 + (orderByComparator.getOrderByFields().length * 2)); query.append(_SQL_SELECT_LAYOUTBRANCH); appendOrderByComparator( query, _ORDER_BY_ENTITY_ALIAS, orderByComparator); sql = query.toString(); } else { sql = _SQL_SELECT_LAYOUTBRANCH; if (pagination) { sql = sql.concat(LayoutBranchModelImpl.ORDER_BY_JPQL); } } Session session = null; try { session = openSession(); Query q = session.createQuery(sql); if (!pagination) { list = (List)QueryUtil.list( q, getDialect(), start, end, false); Collections.sort(list); list = Collections.unmodifiableList(list); } else { list = (List)QueryUtil.list( q, getDialect(), start, end); } cacheResult(list); FinderCacheUtil.putResult(finderPath, finderArgs, list); } catch (Exception e) { FinderCacheUtil.removeResult(finderPath, finderArgs); throw processException(e); } finally { closeSession(session); } } return list; } /** * Removes all the layout branchs from the database. * */ @Override public void removeAll() { for (LayoutBranch layoutBranch : findAll()) { remove(layoutBranch); } } /** * Returns the number of layout branchs. * * @return the number of layout branchs */ @Override public int countAll() { Long count = (Long)FinderCacheUtil.getResult( _finderPathCountAll, FINDER_ARGS_EMPTY, this); if (count == null) { Session session = null; try { session = openSession(); Query q = session.createQuery(_SQL_COUNT_LAYOUTBRANCH); count = (Long)q.uniqueResult(); FinderCacheUtil.putResult( _finderPathCountAll, FINDER_ARGS_EMPTY, count); } catch (Exception e) { FinderCacheUtil.removeResult( _finderPathCountAll, FINDER_ARGS_EMPTY); throw processException(e); } finally { closeSession(session); } } return count.intValue(); } @Override protected Map getTableColumnsMap() { return LayoutBranchModelImpl.TABLE_COLUMNS_MAP; } /** * Initializes the layout branch persistence. */ public void afterPropertiesSet() { _finderPathWithPaginationFindAll = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]); _finderPathWithoutPaginationFindAll = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]); _finderPathCountAll = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]); _finderPathWithPaginationFindByLayoutSetBranchId = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByLayoutSetBranchId", new String[] { Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByLayoutSetBranchId = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByLayoutSetBranchId", new String[] {Long.class.getName()}, LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK); _finderPathCountByLayoutSetBranchId = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByLayoutSetBranchId", new String[] {Long.class.getName()}); _finderPathWithPaginationFindByL_P = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P", new String[] { Long.class.getName(), Long.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByL_P = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P", new String[] {Long.class.getName(), Long.class.getName()}, LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK | LayoutBranchModelImpl.PLID_COLUMN_BITMASK); _finderPathCountByL_P = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P", new String[] {Long.class.getName(), Long.class.getName()}); _finderPathFetchByL_P_N = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_ENTITY, "fetchByL_P_N", new String[] { Long.class.getName(), Long.class.getName(), String.class.getName() }, LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK | LayoutBranchModelImpl.PLID_COLUMN_BITMASK | LayoutBranchModelImpl.NAME_COLUMN_BITMASK); _finderPathCountByL_P_N = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_N", new String[] { Long.class.getName(), Long.class.getName(), String.class.getName() }); _finderPathWithPaginationFindByL_P_M = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByL_P_M", new String[] { Long.class.getName(), Long.class.getName(), Boolean.class.getName(), Integer.class.getName(), Integer.class.getName(), OrderByComparator.class.getName() }); _finderPathWithoutPaginationFindByL_P_M = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, LayoutBranchImpl.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByL_P_M", new String[] { Long.class.getName(), Long.class.getName(), Boolean.class.getName() }, LayoutBranchModelImpl.LAYOUTSETBRANCHID_COLUMN_BITMASK | LayoutBranchModelImpl.PLID_COLUMN_BITMASK | LayoutBranchModelImpl.MASTER_COLUMN_BITMASK); _finderPathCountByL_P_M = new FinderPath( LayoutBranchModelImpl.ENTITY_CACHE_ENABLED, LayoutBranchModelImpl.FINDER_CACHE_ENABLED, Long.class, FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByL_P_M", new String[] { Long.class.getName(), Long.class.getName(), Boolean.class.getName() }); } public void destroy() { EntityCacheUtil.removeCache(LayoutBranchImpl.class.getName()); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION); FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION); } @BeanReference(type = CompanyProviderWrapper.class) protected CompanyProvider companyProvider; private static final String _SQL_SELECT_LAYOUTBRANCH = "SELECT layoutBranch FROM LayoutBranch layoutBranch"; private static final String _SQL_SELECT_LAYOUTBRANCH_WHERE_PKS_IN = "SELECT layoutBranch FROM LayoutBranch layoutBranch WHERE layoutBranchId IN ("; private static final String _SQL_SELECT_LAYOUTBRANCH_WHERE = "SELECT layoutBranch FROM LayoutBranch layoutBranch WHERE "; private static final String _SQL_COUNT_LAYOUTBRANCH = "SELECT COUNT(layoutBranch) FROM LayoutBranch layoutBranch"; private static final String _SQL_COUNT_LAYOUTBRANCH_WHERE = "SELECT COUNT(layoutBranch) FROM LayoutBranch layoutBranch WHERE "; private static final String _ORDER_BY_ENTITY_ALIAS = "layoutBranch."; private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No LayoutBranch exists with the primary key "; private static final String _NO_SUCH_ENTITY_WITH_KEY = "No LayoutBranch exists with the key {"; private static final Log _log = LogFactoryUtil.getLog( LayoutBranchPersistenceImpl.class); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy