001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.asset.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.ModelListener;
037    import com.liferay.portal.service.persistence.BatchSessionUtil;
038    import com.liferay.portal.service.persistence.ResourcePersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.asset.NoSuchLinkException;
043    import com.liferay.portlet.asset.model.AssetLink;
044    import com.liferay.portlet.asset.model.impl.AssetLinkImpl;
045    import com.liferay.portlet.asset.model.impl.AssetLinkModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * The persistence implementation for the asset link service.
055     *
056     * <p>
057     * Never modify or reference this class directly. Always use {@link AssetLinkUtil} to access the asset link persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
058     * </p>
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see AssetLinkPersistence
066     * @see AssetLinkUtil
067     * @generated
068     */
069    public class AssetLinkPersistenceImpl extends BasePersistenceImpl<AssetLink>
070            implements AssetLinkPersistence {
071            public static final String FINDER_CLASS_NAME_ENTITY = AssetLinkImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
073                    ".List";
074            public static final FinderPath FINDER_PATH_FIND_BY_E1 = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
075                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
076                            "findByE1",
077                            new String[] {
078                                    Long.class.getName(),
079                                    
080                            "java.lang.Integer", "java.lang.Integer",
081                                    "com.liferay.portal.kernel.util.OrderByComparator"
082                            });
083            public static final FinderPath FINDER_PATH_COUNT_BY_E1 = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
084                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
085                            "countByE1", new String[] { Long.class.getName() });
086            public static final FinderPath FINDER_PATH_FIND_BY_E2 = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
087                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
088                            "findByE2",
089                            new String[] {
090                                    Long.class.getName(),
091                                    
092                            "java.lang.Integer", "java.lang.Integer",
093                                    "com.liferay.portal.kernel.util.OrderByComparator"
094                            });
095            public static final FinderPath FINDER_PATH_COUNT_BY_E2 = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
096                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
097                            "countByE2", new String[] { Long.class.getName() });
098            public static final FinderPath FINDER_PATH_FIND_BY_E_E = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
099                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
100                            "findByE_E",
101                            new String[] {
102                                    Long.class.getName(), Long.class.getName(),
103                                    
104                            "java.lang.Integer", "java.lang.Integer",
105                                    "com.liferay.portal.kernel.util.OrderByComparator"
106                            });
107            public static final FinderPath FINDER_PATH_COUNT_BY_E_E = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
108                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
109                            "countByE_E",
110                            new String[] { Long.class.getName(), Long.class.getName() });
111            public static final FinderPath FINDER_PATH_FIND_BY_E1_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
112                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
113                            "findByE1_T",
114                            new String[] {
115                                    Long.class.getName(), Integer.class.getName(),
116                                    
117                            "java.lang.Integer", "java.lang.Integer",
118                                    "com.liferay.portal.kernel.util.OrderByComparator"
119                            });
120            public static final FinderPath FINDER_PATH_COUNT_BY_E1_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
121                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
122                            "countByE1_T",
123                            new String[] { Long.class.getName(), Integer.class.getName() });
124            public static final FinderPath FINDER_PATH_FIND_BY_E2_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
125                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
126                            "findByE2_T",
127                            new String[] {
128                                    Long.class.getName(), Integer.class.getName(),
129                                    
130                            "java.lang.Integer", "java.lang.Integer",
131                                    "com.liferay.portal.kernel.util.OrderByComparator"
132                            });
133            public static final FinderPath FINDER_PATH_COUNT_BY_E2_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
134                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
135                            "countByE2_T",
136                            new String[] { Long.class.getName(), Integer.class.getName() });
137            public static final FinderPath FINDER_PATH_FIND_BY_E_E_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
138                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
139                            "findByE_E_T",
140                            new String[] {
141                                    Long.class.getName(), Long.class.getName(),
142                                    Integer.class.getName(),
143                                    
144                            "java.lang.Integer", "java.lang.Integer",
145                                    "com.liferay.portal.kernel.util.OrderByComparator"
146                            });
147            public static final FinderPath FINDER_PATH_COUNT_BY_E_E_T = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
148                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
149                            "countByE_E_T",
150                            new String[] {
151                                    Long.class.getName(), Long.class.getName(),
152                                    Integer.class.getName()
153                            });
154            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
155                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
156                            "findAll", new String[0]);
157            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
158                            AssetLinkModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
159                            "countAll", new String[0]);
160    
161            /**
162             * Caches the asset link in the entity cache if it is enabled.
163             *
164             * @param assetLink the asset link to cache
165             */
166            public void cacheResult(AssetLink assetLink) {
167                    EntityCacheUtil.putResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
168                            AssetLinkImpl.class, assetLink.getPrimaryKey(), assetLink);
169            }
170    
171            /**
172             * Caches the asset links in the entity cache if it is enabled.
173             *
174             * @param assetLinks the asset links to cache
175             */
176            public void cacheResult(List<AssetLink> assetLinks) {
177                    for (AssetLink assetLink : assetLinks) {
178                            if (EntityCacheUtil.getResult(
179                                                    AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
180                                                    AssetLinkImpl.class, assetLink.getPrimaryKey(), this) == null) {
181                                    cacheResult(assetLink);
182                            }
183                    }
184            }
185    
186            /**
187             * Clears the cache for all asset links.
188             *
189             * <p>
190             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
191             * </p>
192             */
193            public void clearCache() {
194                    CacheRegistryUtil.clear(AssetLinkImpl.class.getName());
195                    EntityCacheUtil.clearCache(AssetLinkImpl.class.getName());
196                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
197                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
198            }
199    
200            /**
201             * Clears the cache for the asset link.
202             *
203             * <p>
204             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
205             * </p>
206             */
207            public void clearCache(AssetLink assetLink) {
208                    EntityCacheUtil.removeResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
209                            AssetLinkImpl.class, assetLink.getPrimaryKey());
210            }
211    
212            /**
213             * Creates a new asset link with the primary key. Does not add the asset link to the database.
214             *
215             * @param linkId the primary key for the new asset link
216             * @return the new asset link
217             */
218            public AssetLink create(long linkId) {
219                    AssetLink assetLink = new AssetLinkImpl();
220    
221                    assetLink.setNew(true);
222                    assetLink.setPrimaryKey(linkId);
223    
224                    return assetLink;
225            }
226    
227            /**
228             * Removes the asset link with the primary key from the database. Also notifies the appropriate model listeners.
229             *
230             * @param primaryKey the primary key of the asset link to remove
231             * @return the asset link that was removed
232             * @throws com.liferay.portal.NoSuchModelException if a asset link with the primary key could not be found
233             * @throws SystemException if a system exception occurred
234             */
235            public AssetLink remove(Serializable primaryKey)
236                    throws NoSuchModelException, SystemException {
237                    return remove(((Long)primaryKey).longValue());
238            }
239    
240            /**
241             * Removes the asset link with the primary key from the database. Also notifies the appropriate model listeners.
242             *
243             * @param linkId the primary key of the asset link to remove
244             * @return the asset link that was removed
245             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
246             * @throws SystemException if a system exception occurred
247             */
248            public AssetLink remove(long linkId)
249                    throws NoSuchLinkException, SystemException {
250                    Session session = null;
251    
252                    try {
253                            session = openSession();
254    
255                            AssetLink assetLink = (AssetLink)session.get(AssetLinkImpl.class,
256                                            new Long(linkId));
257    
258                            if (assetLink == null) {
259                                    if (_log.isWarnEnabled()) {
260                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + linkId);
261                                    }
262    
263                                    throw new NoSuchLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
264                                            linkId);
265                            }
266    
267                            return remove(assetLink);
268                    }
269                    catch (NoSuchLinkException nsee) {
270                            throw nsee;
271                    }
272                    catch (Exception e) {
273                            throw processException(e);
274                    }
275                    finally {
276                            closeSession(session);
277                    }
278            }
279    
280            protected AssetLink removeImpl(AssetLink assetLink)
281                    throws SystemException {
282                    assetLink = toUnwrappedModel(assetLink);
283    
284                    Session session = null;
285    
286                    try {
287                            session = openSession();
288    
289                            if (assetLink.isCachedModel() || BatchSessionUtil.isEnabled()) {
290                                    Object staleObject = session.get(AssetLinkImpl.class,
291                                                    assetLink.getPrimaryKeyObj());
292    
293                                    if (staleObject != null) {
294                                            session.evict(staleObject);
295                                    }
296                            }
297    
298                            session.delete(assetLink);
299    
300                            session.flush();
301                    }
302                    catch (Exception e) {
303                            throw processException(e);
304                    }
305                    finally {
306                            closeSession(session);
307                    }
308    
309                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
310    
311                    EntityCacheUtil.removeResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
312                            AssetLinkImpl.class, assetLink.getPrimaryKey());
313    
314                    return assetLink;
315            }
316    
317            public AssetLink updateImpl(
318                    com.liferay.portlet.asset.model.AssetLink assetLink, boolean merge)
319                    throws SystemException {
320                    assetLink = toUnwrappedModel(assetLink);
321    
322                    Session session = null;
323    
324                    try {
325                            session = openSession();
326    
327                            BatchSessionUtil.update(session, assetLink, merge);
328    
329                            assetLink.setNew(false);
330                    }
331                    catch (Exception e) {
332                            throw processException(e);
333                    }
334                    finally {
335                            closeSession(session);
336                    }
337    
338                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
339    
340                    EntityCacheUtil.putResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
341                            AssetLinkImpl.class, assetLink.getPrimaryKey(), assetLink);
342    
343                    return assetLink;
344            }
345    
346            protected AssetLink toUnwrappedModel(AssetLink assetLink) {
347                    if (assetLink instanceof AssetLinkImpl) {
348                            return assetLink;
349                    }
350    
351                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
352    
353                    assetLinkImpl.setNew(assetLink.isNew());
354                    assetLinkImpl.setPrimaryKey(assetLink.getPrimaryKey());
355    
356                    assetLinkImpl.setLinkId(assetLink.getLinkId());
357                    assetLinkImpl.setCompanyId(assetLink.getCompanyId());
358                    assetLinkImpl.setUserId(assetLink.getUserId());
359                    assetLinkImpl.setUserName(assetLink.getUserName());
360                    assetLinkImpl.setCreateDate(assetLink.getCreateDate());
361                    assetLinkImpl.setEntryId1(assetLink.getEntryId1());
362                    assetLinkImpl.setEntryId2(assetLink.getEntryId2());
363                    assetLinkImpl.setType(assetLink.getType());
364                    assetLinkImpl.setWeight(assetLink.getWeight());
365    
366                    return assetLinkImpl;
367            }
368    
369            /**
370             * Finds the asset link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
371             *
372             * @param primaryKey the primary key of the asset link to find
373             * @return the asset link
374             * @throws com.liferay.portal.NoSuchModelException if a asset link with the primary key could not be found
375             * @throws SystemException if a system exception occurred
376             */
377            public AssetLink findByPrimaryKey(Serializable primaryKey)
378                    throws NoSuchModelException, SystemException {
379                    return findByPrimaryKey(((Long)primaryKey).longValue());
380            }
381    
382            /**
383             * Finds the asset link with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchLinkException} if it could not be found.
384             *
385             * @param linkId the primary key of the asset link to find
386             * @return the asset link
387             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
388             * @throws SystemException if a system exception occurred
389             */
390            public AssetLink findByPrimaryKey(long linkId)
391                    throws NoSuchLinkException, SystemException {
392                    AssetLink assetLink = fetchByPrimaryKey(linkId);
393    
394                    if (assetLink == null) {
395                            if (_log.isWarnEnabled()) {
396                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + linkId);
397                            }
398    
399                            throw new NoSuchLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
400                                    linkId);
401                    }
402    
403                    return assetLink;
404            }
405    
406            /**
407             * Finds the asset link with the primary key or returns <code>null</code> if it could not be found.
408             *
409             * @param primaryKey the primary key of the asset link to find
410             * @return the asset link, or <code>null</code> if a asset link with the primary key could not be found
411             * @throws SystemException if a system exception occurred
412             */
413            public AssetLink fetchByPrimaryKey(Serializable primaryKey)
414                    throws SystemException {
415                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
416            }
417    
418            /**
419             * Finds the asset link with the primary key or returns <code>null</code> if it could not be found.
420             *
421             * @param linkId the primary key of the asset link to find
422             * @return the asset link, or <code>null</code> if a asset link with the primary key could not be found
423             * @throws SystemException if a system exception occurred
424             */
425            public AssetLink fetchByPrimaryKey(long linkId) throws SystemException {
426                    AssetLink assetLink = (AssetLink)EntityCacheUtil.getResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
427                                    AssetLinkImpl.class, linkId, this);
428    
429                    if (assetLink == null) {
430                            Session session = null;
431    
432                            try {
433                                    session = openSession();
434    
435                                    assetLink = (AssetLink)session.get(AssetLinkImpl.class,
436                                                    new Long(linkId));
437                            }
438                            catch (Exception e) {
439                                    throw processException(e);
440                            }
441                            finally {
442                                    if (assetLink != null) {
443                                            cacheResult(assetLink);
444                                    }
445    
446                                    closeSession(session);
447                            }
448                    }
449    
450                    return assetLink;
451            }
452    
453            /**
454             * Finds all the asset links where entryId1 = &#63;.
455             *
456             * @param entryId1 the entry id1 to search with
457             * @return the matching asset links
458             * @throws SystemException if a system exception occurred
459             */
460            public List<AssetLink> findByE1(long entryId1) throws SystemException {
461                    return findByE1(entryId1, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
462            }
463    
464            /**
465             * Finds a range of all the asset links where entryId1 = &#63;.
466             *
467             * <p>
468             * 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.
469             * </p>
470             *
471             * @param entryId1 the entry id1 to search with
472             * @param start the lower bound of the range of asset links to return
473             * @param end the upper bound of the range of asset links to return (not inclusive)
474             * @return the range of matching asset links
475             * @throws SystemException if a system exception occurred
476             */
477            public List<AssetLink> findByE1(long entryId1, int start, int end)
478                    throws SystemException {
479                    return findByE1(entryId1, start, end, null);
480            }
481    
482            /**
483             * Finds an ordered range of all the asset links where entryId1 = &#63;.
484             *
485             * <p>
486             * 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.
487             * </p>
488             *
489             * @param entryId1 the entry id1 to search with
490             * @param start the lower bound of the range of asset links to return
491             * @param end the upper bound of the range of asset links to return (not inclusive)
492             * @param orderByComparator the comparator to order the results by
493             * @return the ordered range of matching asset links
494             * @throws SystemException if a system exception occurred
495             */
496            public List<AssetLink> findByE1(long entryId1, int start, int end,
497                    OrderByComparator orderByComparator) throws SystemException {
498                    Object[] finderArgs = new Object[] {
499                                    entryId1,
500                                    
501                                    String.valueOf(start), String.valueOf(end),
502                                    String.valueOf(orderByComparator)
503                            };
504    
505                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E1,
506                                    finderArgs, this);
507    
508                    if (list == null) {
509                            Session session = null;
510    
511                            try {
512                                    session = openSession();
513    
514                                    StringBundler query = null;
515    
516                                    if (orderByComparator != null) {
517                                            query = new StringBundler(3 +
518                                                            (orderByComparator.getOrderByFields().length * 3));
519                                    }
520                                    else {
521                                            query = new StringBundler(3);
522                                    }
523    
524                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
525    
526                                    query.append(_FINDER_COLUMN_E1_ENTRYID1_2);
527    
528                                    if (orderByComparator != null) {
529                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
530                                                    orderByComparator);
531                                    }
532    
533                                    else {
534                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
535                                    }
536    
537                                    String sql = query.toString();
538    
539                                    Query q = session.createQuery(sql);
540    
541                                    QueryPos qPos = QueryPos.getInstance(q);
542    
543                                    qPos.add(entryId1);
544    
545                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
546                                                    end);
547                            }
548                            catch (Exception e) {
549                                    throw processException(e);
550                            }
551                            finally {
552                                    if (list == null) {
553                                            list = new ArrayList<AssetLink>();
554                                    }
555    
556                                    cacheResult(list);
557    
558                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E1, finderArgs,
559                                            list);
560    
561                                    closeSession(session);
562                            }
563                    }
564    
565                    return list;
566            }
567    
568            /**
569             * Finds the first asset link in the ordered set where entryId1 = &#63;.
570             *
571             * <p>
572             * 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.
573             * </p>
574             *
575             * @param entryId1 the entry id1 to search with
576             * @param orderByComparator the comparator to order the set by
577             * @return the first matching asset link
578             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
579             * @throws SystemException if a system exception occurred
580             */
581            public AssetLink findByE1_First(long entryId1,
582                    OrderByComparator orderByComparator)
583                    throws NoSuchLinkException, SystemException {
584                    List<AssetLink> list = findByE1(entryId1, 0, 1, orderByComparator);
585    
586                    if (list.isEmpty()) {
587                            StringBundler msg = new StringBundler(4);
588    
589                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
590    
591                            msg.append("entryId1=");
592                            msg.append(entryId1);
593    
594                            msg.append(StringPool.CLOSE_CURLY_BRACE);
595    
596                            throw new NoSuchLinkException(msg.toString());
597                    }
598                    else {
599                            return list.get(0);
600                    }
601            }
602    
603            /**
604             * Finds the last asset link in the ordered set where entryId1 = &#63;.
605             *
606             * <p>
607             * 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.
608             * </p>
609             *
610             * @param entryId1 the entry id1 to search with
611             * @param orderByComparator the comparator to order the set by
612             * @return the last matching asset link
613             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
614             * @throws SystemException if a system exception occurred
615             */
616            public AssetLink findByE1_Last(long entryId1,
617                    OrderByComparator orderByComparator)
618                    throws NoSuchLinkException, SystemException {
619                    int count = countByE1(entryId1);
620    
621                    List<AssetLink> list = findByE1(entryId1, count - 1, count,
622                                    orderByComparator);
623    
624                    if (list.isEmpty()) {
625                            StringBundler msg = new StringBundler(4);
626    
627                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
628    
629                            msg.append("entryId1=");
630                            msg.append(entryId1);
631    
632                            msg.append(StringPool.CLOSE_CURLY_BRACE);
633    
634                            throw new NoSuchLinkException(msg.toString());
635                    }
636                    else {
637                            return list.get(0);
638                    }
639            }
640    
641            /**
642             * Finds the asset links before and after the current asset link in the ordered set where entryId1 = &#63;.
643             *
644             * <p>
645             * 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.
646             * </p>
647             *
648             * @param linkId the primary key of the current asset link
649             * @param entryId1 the entry id1 to search with
650             * @param orderByComparator the comparator to order the set by
651             * @return the previous, current, and next asset link
652             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
653             * @throws SystemException if a system exception occurred
654             */
655            public AssetLink[] findByE1_PrevAndNext(long linkId, long entryId1,
656                    OrderByComparator orderByComparator)
657                    throws NoSuchLinkException, SystemException {
658                    AssetLink assetLink = findByPrimaryKey(linkId);
659    
660                    Session session = null;
661    
662                    try {
663                            session = openSession();
664    
665                            AssetLink[] array = new AssetLinkImpl[3];
666    
667                            array[0] = getByE1_PrevAndNext(session, assetLink, entryId1,
668                                            orderByComparator, true);
669    
670                            array[1] = assetLink;
671    
672                            array[2] = getByE1_PrevAndNext(session, assetLink, entryId1,
673                                            orderByComparator, false);
674    
675                            return array;
676                    }
677                    catch (Exception e) {
678                            throw processException(e);
679                    }
680                    finally {
681                            closeSession(session);
682                    }
683            }
684    
685            protected AssetLink getByE1_PrevAndNext(Session session,
686                    AssetLink assetLink, long entryId1,
687                    OrderByComparator orderByComparator, boolean previous) {
688                    StringBundler query = null;
689    
690                    if (orderByComparator != null) {
691                            query = new StringBundler(6 +
692                                            (orderByComparator.getOrderByFields().length * 6));
693                    }
694                    else {
695                            query = new StringBundler(3);
696                    }
697    
698                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
699    
700                    query.append(_FINDER_COLUMN_E1_ENTRYID1_2);
701    
702                    if (orderByComparator != null) {
703                            String[] orderByFields = orderByComparator.getOrderByFields();
704    
705                            if (orderByFields.length > 0) {
706                                    query.append(WHERE_AND);
707                            }
708    
709                            for (int i = 0; i < orderByFields.length; i++) {
710                                    query.append(_ORDER_BY_ENTITY_ALIAS);
711                                    query.append(orderByFields[i]);
712    
713                                    if ((i + 1) < orderByFields.length) {
714                                            if (orderByComparator.isAscending() ^ previous) {
715                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
716                                            }
717                                            else {
718                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
719                                            }
720                                    }
721                                    else {
722                                            if (orderByComparator.isAscending() ^ previous) {
723                                                    query.append(WHERE_GREATER_THAN);
724                                            }
725                                            else {
726                                                    query.append(WHERE_LESSER_THAN);
727                                            }
728                                    }
729                            }
730    
731                            query.append(ORDER_BY_CLAUSE);
732    
733                            for (int i = 0; i < orderByFields.length; i++) {
734                                    query.append(_ORDER_BY_ENTITY_ALIAS);
735                                    query.append(orderByFields[i]);
736    
737                                    if ((i + 1) < orderByFields.length) {
738                                            if (orderByComparator.isAscending() ^ previous) {
739                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
740                                            }
741                                            else {
742                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
743                                            }
744                                    }
745                                    else {
746                                            if (orderByComparator.isAscending() ^ previous) {
747                                                    query.append(ORDER_BY_ASC);
748                                            }
749                                            else {
750                                                    query.append(ORDER_BY_DESC);
751                                            }
752                                    }
753                            }
754                    }
755    
756                    else {
757                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
758                    }
759    
760                    String sql = query.toString();
761    
762                    Query q = session.createQuery(sql);
763    
764                    q.setFirstResult(0);
765                    q.setMaxResults(2);
766    
767                    QueryPos qPos = QueryPos.getInstance(q);
768    
769                    qPos.add(entryId1);
770    
771                    if (orderByComparator != null) {
772                            Object[] values = orderByComparator.getOrderByValues(assetLink);
773    
774                            for (Object value : values) {
775                                    qPos.add(value);
776                            }
777                    }
778    
779                    List<AssetLink> list = q.list();
780    
781                    if (list.size() == 2) {
782                            return list.get(1);
783                    }
784                    else {
785                            return null;
786                    }
787            }
788    
789            /**
790             * Finds all the asset links where entryId2 = &#63;.
791             *
792             * @param entryId2 the entry id2 to search with
793             * @return the matching asset links
794             * @throws SystemException if a system exception occurred
795             */
796            public List<AssetLink> findByE2(long entryId2) throws SystemException {
797                    return findByE2(entryId2, QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
798            }
799    
800            /**
801             * Finds a range of all the asset links where entryId2 = &#63;.
802             *
803             * <p>
804             * 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.
805             * </p>
806             *
807             * @param entryId2 the entry id2 to search with
808             * @param start the lower bound of the range of asset links to return
809             * @param end the upper bound of the range of asset links to return (not inclusive)
810             * @return the range of matching asset links
811             * @throws SystemException if a system exception occurred
812             */
813            public List<AssetLink> findByE2(long entryId2, int start, int end)
814                    throws SystemException {
815                    return findByE2(entryId2, start, end, null);
816            }
817    
818            /**
819             * Finds an ordered range of all the asset links where entryId2 = &#63;.
820             *
821             * <p>
822             * 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.
823             * </p>
824             *
825             * @param entryId2 the entry id2 to search with
826             * @param start the lower bound of the range of asset links to return
827             * @param end the upper bound of the range of asset links to return (not inclusive)
828             * @param orderByComparator the comparator to order the results by
829             * @return the ordered range of matching asset links
830             * @throws SystemException if a system exception occurred
831             */
832            public List<AssetLink> findByE2(long entryId2, int start, int end,
833                    OrderByComparator orderByComparator) throws SystemException {
834                    Object[] finderArgs = new Object[] {
835                                    entryId2,
836                                    
837                                    String.valueOf(start), String.valueOf(end),
838                                    String.valueOf(orderByComparator)
839                            };
840    
841                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E2,
842                                    finderArgs, this);
843    
844                    if (list == null) {
845                            Session session = null;
846    
847                            try {
848                                    session = openSession();
849    
850                                    StringBundler query = null;
851    
852                                    if (orderByComparator != null) {
853                                            query = new StringBundler(3 +
854                                                            (orderByComparator.getOrderByFields().length * 3));
855                                    }
856                                    else {
857                                            query = new StringBundler(3);
858                                    }
859    
860                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
861    
862                                    query.append(_FINDER_COLUMN_E2_ENTRYID2_2);
863    
864                                    if (orderByComparator != null) {
865                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
866                                                    orderByComparator);
867                                    }
868    
869                                    else {
870                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
871                                    }
872    
873                                    String sql = query.toString();
874    
875                                    Query q = session.createQuery(sql);
876    
877                                    QueryPos qPos = QueryPos.getInstance(q);
878    
879                                    qPos.add(entryId2);
880    
881                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
882                                                    end);
883                            }
884                            catch (Exception e) {
885                                    throw processException(e);
886                            }
887                            finally {
888                                    if (list == null) {
889                                            list = new ArrayList<AssetLink>();
890                                    }
891    
892                                    cacheResult(list);
893    
894                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E2, finderArgs,
895                                            list);
896    
897                                    closeSession(session);
898                            }
899                    }
900    
901                    return list;
902            }
903    
904            /**
905             * Finds the first asset link in the ordered set where entryId2 = &#63;.
906             *
907             * <p>
908             * 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.
909             * </p>
910             *
911             * @param entryId2 the entry id2 to search with
912             * @param orderByComparator the comparator to order the set by
913             * @return the first matching asset link
914             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
915             * @throws SystemException if a system exception occurred
916             */
917            public AssetLink findByE2_First(long entryId2,
918                    OrderByComparator orderByComparator)
919                    throws NoSuchLinkException, SystemException {
920                    List<AssetLink> list = findByE2(entryId2, 0, 1, orderByComparator);
921    
922                    if (list.isEmpty()) {
923                            StringBundler msg = new StringBundler(4);
924    
925                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
926    
927                            msg.append("entryId2=");
928                            msg.append(entryId2);
929    
930                            msg.append(StringPool.CLOSE_CURLY_BRACE);
931    
932                            throw new NoSuchLinkException(msg.toString());
933                    }
934                    else {
935                            return list.get(0);
936                    }
937            }
938    
939            /**
940             * Finds the last asset link in the ordered set where entryId2 = &#63;.
941             *
942             * <p>
943             * 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.
944             * </p>
945             *
946             * @param entryId2 the entry id2 to search with
947             * @param orderByComparator the comparator to order the set by
948             * @return the last matching asset link
949             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
950             * @throws SystemException if a system exception occurred
951             */
952            public AssetLink findByE2_Last(long entryId2,
953                    OrderByComparator orderByComparator)
954                    throws NoSuchLinkException, SystemException {
955                    int count = countByE2(entryId2);
956    
957                    List<AssetLink> list = findByE2(entryId2, count - 1, count,
958                                    orderByComparator);
959    
960                    if (list.isEmpty()) {
961                            StringBundler msg = new StringBundler(4);
962    
963                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
964    
965                            msg.append("entryId2=");
966                            msg.append(entryId2);
967    
968                            msg.append(StringPool.CLOSE_CURLY_BRACE);
969    
970                            throw new NoSuchLinkException(msg.toString());
971                    }
972                    else {
973                            return list.get(0);
974                    }
975            }
976    
977            /**
978             * Finds the asset links before and after the current asset link in the ordered set where entryId2 = &#63;.
979             *
980             * <p>
981             * 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.
982             * </p>
983             *
984             * @param linkId the primary key of the current asset link
985             * @param entryId2 the entry id2 to search with
986             * @param orderByComparator the comparator to order the set by
987             * @return the previous, current, and next asset link
988             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
989             * @throws SystemException if a system exception occurred
990             */
991            public AssetLink[] findByE2_PrevAndNext(long linkId, long entryId2,
992                    OrderByComparator orderByComparator)
993                    throws NoSuchLinkException, SystemException {
994                    AssetLink assetLink = findByPrimaryKey(linkId);
995    
996                    Session session = null;
997    
998                    try {
999                            session = openSession();
1000    
1001                            AssetLink[] array = new AssetLinkImpl[3];
1002    
1003                            array[0] = getByE2_PrevAndNext(session, assetLink, entryId2,
1004                                            orderByComparator, true);
1005    
1006                            array[1] = assetLink;
1007    
1008                            array[2] = getByE2_PrevAndNext(session, assetLink, entryId2,
1009                                            orderByComparator, false);
1010    
1011                            return array;
1012                    }
1013                    catch (Exception e) {
1014                            throw processException(e);
1015                    }
1016                    finally {
1017                            closeSession(session);
1018                    }
1019            }
1020    
1021            protected AssetLink getByE2_PrevAndNext(Session session,
1022                    AssetLink assetLink, long entryId2,
1023                    OrderByComparator orderByComparator, boolean previous) {
1024                    StringBundler query = null;
1025    
1026                    if (orderByComparator != null) {
1027                            query = new StringBundler(6 +
1028                                            (orderByComparator.getOrderByFields().length * 6));
1029                    }
1030                    else {
1031                            query = new StringBundler(3);
1032                    }
1033    
1034                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1035    
1036                    query.append(_FINDER_COLUMN_E2_ENTRYID2_2);
1037    
1038                    if (orderByComparator != null) {
1039                            String[] orderByFields = orderByComparator.getOrderByFields();
1040    
1041                            if (orderByFields.length > 0) {
1042                                    query.append(WHERE_AND);
1043                            }
1044    
1045                            for (int i = 0; i < orderByFields.length; i++) {
1046                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1047                                    query.append(orderByFields[i]);
1048    
1049                                    if ((i + 1) < orderByFields.length) {
1050                                            if (orderByComparator.isAscending() ^ previous) {
1051                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1052                                            }
1053                                            else {
1054                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1055                                            }
1056                                    }
1057                                    else {
1058                                            if (orderByComparator.isAscending() ^ previous) {
1059                                                    query.append(WHERE_GREATER_THAN);
1060                                            }
1061                                            else {
1062                                                    query.append(WHERE_LESSER_THAN);
1063                                            }
1064                                    }
1065                            }
1066    
1067                            query.append(ORDER_BY_CLAUSE);
1068    
1069                            for (int i = 0; i < orderByFields.length; i++) {
1070                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1071                                    query.append(orderByFields[i]);
1072    
1073                                    if ((i + 1) < orderByFields.length) {
1074                                            if (orderByComparator.isAscending() ^ previous) {
1075                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1076                                            }
1077                                            else {
1078                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1079                                            }
1080                                    }
1081                                    else {
1082                                            if (orderByComparator.isAscending() ^ previous) {
1083                                                    query.append(ORDER_BY_ASC);
1084                                            }
1085                                            else {
1086                                                    query.append(ORDER_BY_DESC);
1087                                            }
1088                                    }
1089                            }
1090                    }
1091    
1092                    else {
1093                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1094                    }
1095    
1096                    String sql = query.toString();
1097    
1098                    Query q = session.createQuery(sql);
1099    
1100                    q.setFirstResult(0);
1101                    q.setMaxResults(2);
1102    
1103                    QueryPos qPos = QueryPos.getInstance(q);
1104    
1105                    qPos.add(entryId2);
1106    
1107                    if (orderByComparator != null) {
1108                            Object[] values = orderByComparator.getOrderByValues(assetLink);
1109    
1110                            for (Object value : values) {
1111                                    qPos.add(value);
1112                            }
1113                    }
1114    
1115                    List<AssetLink> list = q.list();
1116    
1117                    if (list.size() == 2) {
1118                            return list.get(1);
1119                    }
1120                    else {
1121                            return null;
1122                    }
1123            }
1124    
1125            /**
1126             * Finds all the asset links where entryId1 = &#63; and entryId2 = &#63;.
1127             *
1128             * @param entryId1 the entry id1 to search with
1129             * @param entryId2 the entry id2 to search with
1130             * @return the matching asset links
1131             * @throws SystemException if a system exception occurred
1132             */
1133            public List<AssetLink> findByE_E(long entryId1, long entryId2)
1134                    throws SystemException {
1135                    return findByE_E(entryId1, entryId2, QueryUtil.ALL_POS,
1136                            QueryUtil.ALL_POS, null);
1137            }
1138    
1139            /**
1140             * Finds a range of all the asset links where entryId1 = &#63; and entryId2 = &#63;.
1141             *
1142             * <p>
1143             * 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.
1144             * </p>
1145             *
1146             * @param entryId1 the entry id1 to search with
1147             * @param entryId2 the entry id2 to search with
1148             * @param start the lower bound of the range of asset links to return
1149             * @param end the upper bound of the range of asset links to return (not inclusive)
1150             * @return the range of matching asset links
1151             * @throws SystemException if a system exception occurred
1152             */
1153            public List<AssetLink> findByE_E(long entryId1, long entryId2, int start,
1154                    int end) throws SystemException {
1155                    return findByE_E(entryId1, entryId2, start, end, null);
1156            }
1157    
1158            /**
1159             * Finds an ordered range of all the asset links where entryId1 = &#63; and entryId2 = &#63;.
1160             *
1161             * <p>
1162             * 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.
1163             * </p>
1164             *
1165             * @param entryId1 the entry id1 to search with
1166             * @param entryId2 the entry id2 to search with
1167             * @param start the lower bound of the range of asset links to return
1168             * @param end the upper bound of the range of asset links to return (not inclusive)
1169             * @param orderByComparator the comparator to order the results by
1170             * @return the ordered range of matching asset links
1171             * @throws SystemException if a system exception occurred
1172             */
1173            public List<AssetLink> findByE_E(long entryId1, long entryId2, int start,
1174                    int end, OrderByComparator orderByComparator) throws SystemException {
1175                    Object[] finderArgs = new Object[] {
1176                                    entryId1, entryId2,
1177                                    
1178                                    String.valueOf(start), String.valueOf(end),
1179                                    String.valueOf(orderByComparator)
1180                            };
1181    
1182                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E_E,
1183                                    finderArgs, this);
1184    
1185                    if (list == null) {
1186                            Session session = null;
1187    
1188                            try {
1189                                    session = openSession();
1190    
1191                                    StringBundler query = null;
1192    
1193                                    if (orderByComparator != null) {
1194                                            query = new StringBundler(4 +
1195                                                            (orderByComparator.getOrderByFields().length * 3));
1196                                    }
1197                                    else {
1198                                            query = new StringBundler(4);
1199                                    }
1200    
1201                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1202    
1203                                    query.append(_FINDER_COLUMN_E_E_ENTRYID1_2);
1204    
1205                                    query.append(_FINDER_COLUMN_E_E_ENTRYID2_2);
1206    
1207                                    if (orderByComparator != null) {
1208                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1209                                                    orderByComparator);
1210                                    }
1211    
1212                                    else {
1213                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1214                                    }
1215    
1216                                    String sql = query.toString();
1217    
1218                                    Query q = session.createQuery(sql);
1219    
1220                                    QueryPos qPos = QueryPos.getInstance(q);
1221    
1222                                    qPos.add(entryId1);
1223    
1224                                    qPos.add(entryId2);
1225    
1226                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
1227                                                    end);
1228                            }
1229                            catch (Exception e) {
1230                                    throw processException(e);
1231                            }
1232                            finally {
1233                                    if (list == null) {
1234                                            list = new ArrayList<AssetLink>();
1235                                    }
1236    
1237                                    cacheResult(list);
1238    
1239                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E_E, finderArgs,
1240                                            list);
1241    
1242                                    closeSession(session);
1243                            }
1244                    }
1245    
1246                    return list;
1247            }
1248    
1249            /**
1250             * Finds the first asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63;.
1251             *
1252             * <p>
1253             * 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.
1254             * </p>
1255             *
1256             * @param entryId1 the entry id1 to search with
1257             * @param entryId2 the entry id2 to search with
1258             * @param orderByComparator the comparator to order the set by
1259             * @return the first matching asset link
1260             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
1261             * @throws SystemException if a system exception occurred
1262             */
1263            public AssetLink findByE_E_First(long entryId1, long entryId2,
1264                    OrderByComparator orderByComparator)
1265                    throws NoSuchLinkException, SystemException {
1266                    List<AssetLink> list = findByE_E(entryId1, entryId2, 0, 1,
1267                                    orderByComparator);
1268    
1269                    if (list.isEmpty()) {
1270                            StringBundler msg = new StringBundler(6);
1271    
1272                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1273    
1274                            msg.append("entryId1=");
1275                            msg.append(entryId1);
1276    
1277                            msg.append(", entryId2=");
1278                            msg.append(entryId2);
1279    
1280                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1281    
1282                            throw new NoSuchLinkException(msg.toString());
1283                    }
1284                    else {
1285                            return list.get(0);
1286                    }
1287            }
1288    
1289            /**
1290             * Finds the last asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63;.
1291             *
1292             * <p>
1293             * 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.
1294             * </p>
1295             *
1296             * @param entryId1 the entry id1 to search with
1297             * @param entryId2 the entry id2 to search with
1298             * @param orderByComparator the comparator to order the set by
1299             * @return the last matching asset link
1300             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
1301             * @throws SystemException if a system exception occurred
1302             */
1303            public AssetLink findByE_E_Last(long entryId1, long entryId2,
1304                    OrderByComparator orderByComparator)
1305                    throws NoSuchLinkException, SystemException {
1306                    int count = countByE_E(entryId1, entryId2);
1307    
1308                    List<AssetLink> list = findByE_E(entryId1, entryId2, count - 1, count,
1309                                    orderByComparator);
1310    
1311                    if (list.isEmpty()) {
1312                            StringBundler msg = new StringBundler(6);
1313    
1314                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1315    
1316                            msg.append("entryId1=");
1317                            msg.append(entryId1);
1318    
1319                            msg.append(", entryId2=");
1320                            msg.append(entryId2);
1321    
1322                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1323    
1324                            throw new NoSuchLinkException(msg.toString());
1325                    }
1326                    else {
1327                            return list.get(0);
1328                    }
1329            }
1330    
1331            /**
1332             * Finds the asset links before and after the current asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63;.
1333             *
1334             * <p>
1335             * 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.
1336             * </p>
1337             *
1338             * @param linkId the primary key of the current asset link
1339             * @param entryId1 the entry id1 to search with
1340             * @param entryId2 the entry id2 to search with
1341             * @param orderByComparator the comparator to order the set by
1342             * @return the previous, current, and next asset link
1343             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
1344             * @throws SystemException if a system exception occurred
1345             */
1346            public AssetLink[] findByE_E_PrevAndNext(long linkId, long entryId1,
1347                    long entryId2, OrderByComparator orderByComparator)
1348                    throws NoSuchLinkException, SystemException {
1349                    AssetLink assetLink = findByPrimaryKey(linkId);
1350    
1351                    Session session = null;
1352    
1353                    try {
1354                            session = openSession();
1355    
1356                            AssetLink[] array = new AssetLinkImpl[3];
1357    
1358                            array[0] = getByE_E_PrevAndNext(session, assetLink, entryId1,
1359                                            entryId2, orderByComparator, true);
1360    
1361                            array[1] = assetLink;
1362    
1363                            array[2] = getByE_E_PrevAndNext(session, assetLink, entryId1,
1364                                            entryId2, orderByComparator, false);
1365    
1366                            return array;
1367                    }
1368                    catch (Exception e) {
1369                            throw processException(e);
1370                    }
1371                    finally {
1372                            closeSession(session);
1373                    }
1374            }
1375    
1376            protected AssetLink getByE_E_PrevAndNext(Session session,
1377                    AssetLink assetLink, long entryId1, long entryId2,
1378                    OrderByComparator orderByComparator, boolean previous) {
1379                    StringBundler query = null;
1380    
1381                    if (orderByComparator != null) {
1382                            query = new StringBundler(6 +
1383                                            (orderByComparator.getOrderByFields().length * 6));
1384                    }
1385                    else {
1386                            query = new StringBundler(3);
1387                    }
1388    
1389                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1390    
1391                    query.append(_FINDER_COLUMN_E_E_ENTRYID1_2);
1392    
1393                    query.append(_FINDER_COLUMN_E_E_ENTRYID2_2);
1394    
1395                    if (orderByComparator != null) {
1396                            String[] orderByFields = orderByComparator.getOrderByFields();
1397    
1398                            if (orderByFields.length > 0) {
1399                                    query.append(WHERE_AND);
1400                            }
1401    
1402                            for (int i = 0; i < orderByFields.length; i++) {
1403                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1404                                    query.append(orderByFields[i]);
1405    
1406                                    if ((i + 1) < orderByFields.length) {
1407                                            if (orderByComparator.isAscending() ^ previous) {
1408                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1409                                            }
1410                                            else {
1411                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1412                                            }
1413                                    }
1414                                    else {
1415                                            if (orderByComparator.isAscending() ^ previous) {
1416                                                    query.append(WHERE_GREATER_THAN);
1417                                            }
1418                                            else {
1419                                                    query.append(WHERE_LESSER_THAN);
1420                                            }
1421                                    }
1422                            }
1423    
1424                            query.append(ORDER_BY_CLAUSE);
1425    
1426                            for (int i = 0; i < orderByFields.length; i++) {
1427                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1428                                    query.append(orderByFields[i]);
1429    
1430                                    if ((i + 1) < orderByFields.length) {
1431                                            if (orderByComparator.isAscending() ^ previous) {
1432                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1433                                            }
1434                                            else {
1435                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1436                                            }
1437                                    }
1438                                    else {
1439                                            if (orderByComparator.isAscending() ^ previous) {
1440                                                    query.append(ORDER_BY_ASC);
1441                                            }
1442                                            else {
1443                                                    query.append(ORDER_BY_DESC);
1444                                            }
1445                                    }
1446                            }
1447                    }
1448    
1449                    else {
1450                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1451                    }
1452    
1453                    String sql = query.toString();
1454    
1455                    Query q = session.createQuery(sql);
1456    
1457                    q.setFirstResult(0);
1458                    q.setMaxResults(2);
1459    
1460                    QueryPos qPos = QueryPos.getInstance(q);
1461    
1462                    qPos.add(entryId1);
1463    
1464                    qPos.add(entryId2);
1465    
1466                    if (orderByComparator != null) {
1467                            Object[] values = orderByComparator.getOrderByValues(assetLink);
1468    
1469                            for (Object value : values) {
1470                                    qPos.add(value);
1471                            }
1472                    }
1473    
1474                    List<AssetLink> list = q.list();
1475    
1476                    if (list.size() == 2) {
1477                            return list.get(1);
1478                    }
1479                    else {
1480                            return null;
1481                    }
1482            }
1483    
1484            /**
1485             * Finds all the asset links where entryId1 = &#63; and type = &#63;.
1486             *
1487             * @param entryId1 the entry id1 to search with
1488             * @param type the type to search with
1489             * @return the matching asset links
1490             * @throws SystemException if a system exception occurred
1491             */
1492            public List<AssetLink> findByE1_T(long entryId1, int type)
1493                    throws SystemException {
1494                    return findByE1_T(entryId1, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1495                            null);
1496            }
1497    
1498            /**
1499             * Finds a range of all the asset links where entryId1 = &#63; and type = &#63;.
1500             *
1501             * <p>
1502             * 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.
1503             * </p>
1504             *
1505             * @param entryId1 the entry id1 to search with
1506             * @param type the type to search with
1507             * @param start the lower bound of the range of asset links to return
1508             * @param end the upper bound of the range of asset links to return (not inclusive)
1509             * @return the range of matching asset links
1510             * @throws SystemException if a system exception occurred
1511             */
1512            public List<AssetLink> findByE1_T(long entryId1, int type, int start,
1513                    int end) throws SystemException {
1514                    return findByE1_T(entryId1, type, start, end, null);
1515            }
1516    
1517            /**
1518             * Finds an ordered range of all the asset links where entryId1 = &#63; and type = &#63;.
1519             *
1520             * <p>
1521             * 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.
1522             * </p>
1523             *
1524             * @param entryId1 the entry id1 to search with
1525             * @param type the type to search with
1526             * @param start the lower bound of the range of asset links to return
1527             * @param end the upper bound of the range of asset links to return (not inclusive)
1528             * @param orderByComparator the comparator to order the results by
1529             * @return the ordered range of matching asset links
1530             * @throws SystemException if a system exception occurred
1531             */
1532            public List<AssetLink> findByE1_T(long entryId1, int type, int start,
1533                    int end, OrderByComparator orderByComparator) throws SystemException {
1534                    Object[] finderArgs = new Object[] {
1535                                    entryId1, type,
1536                                    
1537                                    String.valueOf(start), String.valueOf(end),
1538                                    String.valueOf(orderByComparator)
1539                            };
1540    
1541                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E1_T,
1542                                    finderArgs, this);
1543    
1544                    if (list == null) {
1545                            Session session = null;
1546    
1547                            try {
1548                                    session = openSession();
1549    
1550                                    StringBundler query = null;
1551    
1552                                    if (orderByComparator != null) {
1553                                            query = new StringBundler(4 +
1554                                                            (orderByComparator.getOrderByFields().length * 3));
1555                                    }
1556                                    else {
1557                                            query = new StringBundler(4);
1558                                    }
1559    
1560                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1561    
1562                                    query.append(_FINDER_COLUMN_E1_T_ENTRYID1_2);
1563    
1564                                    query.append(_FINDER_COLUMN_E1_T_TYPE_2);
1565    
1566                                    if (orderByComparator != null) {
1567                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1568                                                    orderByComparator);
1569                                    }
1570    
1571                                    else {
1572                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1573                                    }
1574    
1575                                    String sql = query.toString();
1576    
1577                                    Query q = session.createQuery(sql);
1578    
1579                                    QueryPos qPos = QueryPos.getInstance(q);
1580    
1581                                    qPos.add(entryId1);
1582    
1583                                    qPos.add(type);
1584    
1585                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
1586                                                    end);
1587                            }
1588                            catch (Exception e) {
1589                                    throw processException(e);
1590                            }
1591                            finally {
1592                                    if (list == null) {
1593                                            list = new ArrayList<AssetLink>();
1594                                    }
1595    
1596                                    cacheResult(list);
1597    
1598                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E1_T, finderArgs,
1599                                            list);
1600    
1601                                    closeSession(session);
1602                            }
1603                    }
1604    
1605                    return list;
1606            }
1607    
1608            /**
1609             * Finds the first asset link in the ordered set where entryId1 = &#63; and type = &#63;.
1610             *
1611             * <p>
1612             * 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.
1613             * </p>
1614             *
1615             * @param entryId1 the entry id1 to search with
1616             * @param type the type to search with
1617             * @param orderByComparator the comparator to order the set by
1618             * @return the first matching asset link
1619             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
1620             * @throws SystemException if a system exception occurred
1621             */
1622            public AssetLink findByE1_T_First(long entryId1, int type,
1623                    OrderByComparator orderByComparator)
1624                    throws NoSuchLinkException, SystemException {
1625                    List<AssetLink> list = findByE1_T(entryId1, type, 0, 1,
1626                                    orderByComparator);
1627    
1628                    if (list.isEmpty()) {
1629                            StringBundler msg = new StringBundler(6);
1630    
1631                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1632    
1633                            msg.append("entryId1=");
1634                            msg.append(entryId1);
1635    
1636                            msg.append(", type=");
1637                            msg.append(type);
1638    
1639                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1640    
1641                            throw new NoSuchLinkException(msg.toString());
1642                    }
1643                    else {
1644                            return list.get(0);
1645                    }
1646            }
1647    
1648            /**
1649             * Finds the last asset link in the ordered set where entryId1 = &#63; and type = &#63;.
1650             *
1651             * <p>
1652             * 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.
1653             * </p>
1654             *
1655             * @param entryId1 the entry id1 to search with
1656             * @param type the type to search with
1657             * @param orderByComparator the comparator to order the set by
1658             * @return the last matching asset link
1659             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
1660             * @throws SystemException if a system exception occurred
1661             */
1662            public AssetLink findByE1_T_Last(long entryId1, int type,
1663                    OrderByComparator orderByComparator)
1664                    throws NoSuchLinkException, SystemException {
1665                    int count = countByE1_T(entryId1, type);
1666    
1667                    List<AssetLink> list = findByE1_T(entryId1, type, count - 1, count,
1668                                    orderByComparator);
1669    
1670                    if (list.isEmpty()) {
1671                            StringBundler msg = new StringBundler(6);
1672    
1673                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1674    
1675                            msg.append("entryId1=");
1676                            msg.append(entryId1);
1677    
1678                            msg.append(", type=");
1679                            msg.append(type);
1680    
1681                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1682    
1683                            throw new NoSuchLinkException(msg.toString());
1684                    }
1685                    else {
1686                            return list.get(0);
1687                    }
1688            }
1689    
1690            /**
1691             * Finds the asset links before and after the current asset link in the ordered set where entryId1 = &#63; and type = &#63;.
1692             *
1693             * <p>
1694             * 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.
1695             * </p>
1696             *
1697             * @param linkId the primary key of the current asset link
1698             * @param entryId1 the entry id1 to search with
1699             * @param type the type to search with
1700             * @param orderByComparator the comparator to order the set by
1701             * @return the previous, current, and next asset link
1702             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
1703             * @throws SystemException if a system exception occurred
1704             */
1705            public AssetLink[] findByE1_T_PrevAndNext(long linkId, long entryId1,
1706                    int type, OrderByComparator orderByComparator)
1707                    throws NoSuchLinkException, SystemException {
1708                    AssetLink assetLink = findByPrimaryKey(linkId);
1709    
1710                    Session session = null;
1711    
1712                    try {
1713                            session = openSession();
1714    
1715                            AssetLink[] array = new AssetLinkImpl[3];
1716    
1717                            array[0] = getByE1_T_PrevAndNext(session, assetLink, entryId1,
1718                                            type, orderByComparator, true);
1719    
1720                            array[1] = assetLink;
1721    
1722                            array[2] = getByE1_T_PrevAndNext(session, assetLink, entryId1,
1723                                            type, orderByComparator, false);
1724    
1725                            return array;
1726                    }
1727                    catch (Exception e) {
1728                            throw processException(e);
1729                    }
1730                    finally {
1731                            closeSession(session);
1732                    }
1733            }
1734    
1735            protected AssetLink getByE1_T_PrevAndNext(Session session,
1736                    AssetLink assetLink, long entryId1, int type,
1737                    OrderByComparator orderByComparator, boolean previous) {
1738                    StringBundler query = null;
1739    
1740                    if (orderByComparator != null) {
1741                            query = new StringBundler(6 +
1742                                            (orderByComparator.getOrderByFields().length * 6));
1743                    }
1744                    else {
1745                            query = new StringBundler(3);
1746                    }
1747    
1748                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1749    
1750                    query.append(_FINDER_COLUMN_E1_T_ENTRYID1_2);
1751    
1752                    query.append(_FINDER_COLUMN_E1_T_TYPE_2);
1753    
1754                    if (orderByComparator != null) {
1755                            String[] orderByFields = orderByComparator.getOrderByFields();
1756    
1757                            if (orderByFields.length > 0) {
1758                                    query.append(WHERE_AND);
1759                            }
1760    
1761                            for (int i = 0; i < orderByFields.length; i++) {
1762                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1763                                    query.append(orderByFields[i]);
1764    
1765                                    if ((i + 1) < orderByFields.length) {
1766                                            if (orderByComparator.isAscending() ^ previous) {
1767                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1768                                            }
1769                                            else {
1770                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1771                                            }
1772                                    }
1773                                    else {
1774                                            if (orderByComparator.isAscending() ^ previous) {
1775                                                    query.append(WHERE_GREATER_THAN);
1776                                            }
1777                                            else {
1778                                                    query.append(WHERE_LESSER_THAN);
1779                                            }
1780                                    }
1781                            }
1782    
1783                            query.append(ORDER_BY_CLAUSE);
1784    
1785                            for (int i = 0; i < orderByFields.length; i++) {
1786                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1787                                    query.append(orderByFields[i]);
1788    
1789                                    if ((i + 1) < orderByFields.length) {
1790                                            if (orderByComparator.isAscending() ^ previous) {
1791                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1792                                            }
1793                                            else {
1794                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1795                                            }
1796                                    }
1797                                    else {
1798                                            if (orderByComparator.isAscending() ^ previous) {
1799                                                    query.append(ORDER_BY_ASC);
1800                                            }
1801                                            else {
1802                                                    query.append(ORDER_BY_DESC);
1803                                            }
1804                                    }
1805                            }
1806                    }
1807    
1808                    else {
1809                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1810                    }
1811    
1812                    String sql = query.toString();
1813    
1814                    Query q = session.createQuery(sql);
1815    
1816                    q.setFirstResult(0);
1817                    q.setMaxResults(2);
1818    
1819                    QueryPos qPos = QueryPos.getInstance(q);
1820    
1821                    qPos.add(entryId1);
1822    
1823                    qPos.add(type);
1824    
1825                    if (orderByComparator != null) {
1826                            Object[] values = orderByComparator.getOrderByValues(assetLink);
1827    
1828                            for (Object value : values) {
1829                                    qPos.add(value);
1830                            }
1831                    }
1832    
1833                    List<AssetLink> list = q.list();
1834    
1835                    if (list.size() == 2) {
1836                            return list.get(1);
1837                    }
1838                    else {
1839                            return null;
1840                    }
1841            }
1842    
1843            /**
1844             * Finds all the asset links where entryId2 = &#63; and type = &#63;.
1845             *
1846             * @param entryId2 the entry id2 to search with
1847             * @param type the type to search with
1848             * @return the matching asset links
1849             * @throws SystemException if a system exception occurred
1850             */
1851            public List<AssetLink> findByE2_T(long entryId2, int type)
1852                    throws SystemException {
1853                    return findByE2_T(entryId2, type, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1854                            null);
1855            }
1856    
1857            /**
1858             * Finds a range of all the asset links where entryId2 = &#63; and type = &#63;.
1859             *
1860             * <p>
1861             * 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.
1862             * </p>
1863             *
1864             * @param entryId2 the entry id2 to search with
1865             * @param type the type to search with
1866             * @param start the lower bound of the range of asset links to return
1867             * @param end the upper bound of the range of asset links to return (not inclusive)
1868             * @return the range of matching asset links
1869             * @throws SystemException if a system exception occurred
1870             */
1871            public List<AssetLink> findByE2_T(long entryId2, int type, int start,
1872                    int end) throws SystemException {
1873                    return findByE2_T(entryId2, type, start, end, null);
1874            }
1875    
1876            /**
1877             * Finds an ordered range of all the asset links where entryId2 = &#63; and type = &#63;.
1878             *
1879             * <p>
1880             * 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.
1881             * </p>
1882             *
1883             * @param entryId2 the entry id2 to search with
1884             * @param type the type to search with
1885             * @param start the lower bound of the range of asset links to return
1886             * @param end the upper bound of the range of asset links to return (not inclusive)
1887             * @param orderByComparator the comparator to order the results by
1888             * @return the ordered range of matching asset links
1889             * @throws SystemException if a system exception occurred
1890             */
1891            public List<AssetLink> findByE2_T(long entryId2, int type, int start,
1892                    int end, OrderByComparator orderByComparator) throws SystemException {
1893                    Object[] finderArgs = new Object[] {
1894                                    entryId2, type,
1895                                    
1896                                    String.valueOf(start), String.valueOf(end),
1897                                    String.valueOf(orderByComparator)
1898                            };
1899    
1900                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E2_T,
1901                                    finderArgs, this);
1902    
1903                    if (list == null) {
1904                            Session session = null;
1905    
1906                            try {
1907                                    session = openSession();
1908    
1909                                    StringBundler query = null;
1910    
1911                                    if (orderByComparator != null) {
1912                                            query = new StringBundler(4 +
1913                                                            (orderByComparator.getOrderByFields().length * 3));
1914                                    }
1915                                    else {
1916                                            query = new StringBundler(4);
1917                                    }
1918    
1919                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
1920    
1921                                    query.append(_FINDER_COLUMN_E2_T_ENTRYID2_2);
1922    
1923                                    query.append(_FINDER_COLUMN_E2_T_TYPE_2);
1924    
1925                                    if (orderByComparator != null) {
1926                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1927                                                    orderByComparator);
1928                                    }
1929    
1930                                    else {
1931                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
1932                                    }
1933    
1934                                    String sql = query.toString();
1935    
1936                                    Query q = session.createQuery(sql);
1937    
1938                                    QueryPos qPos = QueryPos.getInstance(q);
1939    
1940                                    qPos.add(entryId2);
1941    
1942                                    qPos.add(type);
1943    
1944                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
1945                                                    end);
1946                            }
1947                            catch (Exception e) {
1948                                    throw processException(e);
1949                            }
1950                            finally {
1951                                    if (list == null) {
1952                                            list = new ArrayList<AssetLink>();
1953                                    }
1954    
1955                                    cacheResult(list);
1956    
1957                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E2_T, finderArgs,
1958                                            list);
1959    
1960                                    closeSession(session);
1961                            }
1962                    }
1963    
1964                    return list;
1965            }
1966    
1967            /**
1968             * Finds the first asset link in the ordered set where entryId2 = &#63; and type = &#63;.
1969             *
1970             * <p>
1971             * 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.
1972             * </p>
1973             *
1974             * @param entryId2 the entry id2 to search with
1975             * @param type the type to search with
1976             * @param orderByComparator the comparator to order the set by
1977             * @return the first matching asset link
1978             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
1979             * @throws SystemException if a system exception occurred
1980             */
1981            public AssetLink findByE2_T_First(long entryId2, int type,
1982                    OrderByComparator orderByComparator)
1983                    throws NoSuchLinkException, SystemException {
1984                    List<AssetLink> list = findByE2_T(entryId2, type, 0, 1,
1985                                    orderByComparator);
1986    
1987                    if (list.isEmpty()) {
1988                            StringBundler msg = new StringBundler(6);
1989    
1990                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1991    
1992                            msg.append("entryId2=");
1993                            msg.append(entryId2);
1994    
1995                            msg.append(", type=");
1996                            msg.append(type);
1997    
1998                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1999    
2000                            throw new NoSuchLinkException(msg.toString());
2001                    }
2002                    else {
2003                            return list.get(0);
2004                    }
2005            }
2006    
2007            /**
2008             * Finds the last asset link in the ordered set where entryId2 = &#63; and type = &#63;.
2009             *
2010             * <p>
2011             * 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.
2012             * </p>
2013             *
2014             * @param entryId2 the entry id2 to search with
2015             * @param type the type to search with
2016             * @param orderByComparator the comparator to order the set by
2017             * @return the last matching asset link
2018             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
2019             * @throws SystemException if a system exception occurred
2020             */
2021            public AssetLink findByE2_T_Last(long entryId2, int type,
2022                    OrderByComparator orderByComparator)
2023                    throws NoSuchLinkException, SystemException {
2024                    int count = countByE2_T(entryId2, type);
2025    
2026                    List<AssetLink> list = findByE2_T(entryId2, type, count - 1, count,
2027                                    orderByComparator);
2028    
2029                    if (list.isEmpty()) {
2030                            StringBundler msg = new StringBundler(6);
2031    
2032                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2033    
2034                            msg.append("entryId2=");
2035                            msg.append(entryId2);
2036    
2037                            msg.append(", type=");
2038                            msg.append(type);
2039    
2040                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2041    
2042                            throw new NoSuchLinkException(msg.toString());
2043                    }
2044                    else {
2045                            return list.get(0);
2046                    }
2047            }
2048    
2049            /**
2050             * Finds the asset links before and after the current asset link in the ordered set where entryId2 = &#63; and type = &#63;.
2051             *
2052             * <p>
2053             * 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.
2054             * </p>
2055             *
2056             * @param linkId the primary key of the current asset link
2057             * @param entryId2 the entry id2 to search with
2058             * @param type the type to search with
2059             * @param orderByComparator the comparator to order the set by
2060             * @return the previous, current, and next asset link
2061             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
2062             * @throws SystemException if a system exception occurred
2063             */
2064            public AssetLink[] findByE2_T_PrevAndNext(long linkId, long entryId2,
2065                    int type, OrderByComparator orderByComparator)
2066                    throws NoSuchLinkException, SystemException {
2067                    AssetLink assetLink = findByPrimaryKey(linkId);
2068    
2069                    Session session = null;
2070    
2071                    try {
2072                            session = openSession();
2073    
2074                            AssetLink[] array = new AssetLinkImpl[3];
2075    
2076                            array[0] = getByE2_T_PrevAndNext(session, assetLink, entryId2,
2077                                            type, orderByComparator, true);
2078    
2079                            array[1] = assetLink;
2080    
2081                            array[2] = getByE2_T_PrevAndNext(session, assetLink, entryId2,
2082                                            type, orderByComparator, false);
2083    
2084                            return array;
2085                    }
2086                    catch (Exception e) {
2087                            throw processException(e);
2088                    }
2089                    finally {
2090                            closeSession(session);
2091                    }
2092            }
2093    
2094            protected AssetLink getByE2_T_PrevAndNext(Session session,
2095                    AssetLink assetLink, long entryId2, int type,
2096                    OrderByComparator orderByComparator, boolean previous) {
2097                    StringBundler query = null;
2098    
2099                    if (orderByComparator != null) {
2100                            query = new StringBundler(6 +
2101                                            (orderByComparator.getOrderByFields().length * 6));
2102                    }
2103                    else {
2104                            query = new StringBundler(3);
2105                    }
2106    
2107                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
2108    
2109                    query.append(_FINDER_COLUMN_E2_T_ENTRYID2_2);
2110    
2111                    query.append(_FINDER_COLUMN_E2_T_TYPE_2);
2112    
2113                    if (orderByComparator != null) {
2114                            String[] orderByFields = orderByComparator.getOrderByFields();
2115    
2116                            if (orderByFields.length > 0) {
2117                                    query.append(WHERE_AND);
2118                            }
2119    
2120                            for (int i = 0; i < orderByFields.length; i++) {
2121                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2122                                    query.append(orderByFields[i]);
2123    
2124                                    if ((i + 1) < orderByFields.length) {
2125                                            if (orderByComparator.isAscending() ^ previous) {
2126                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2127                                            }
2128                                            else {
2129                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2130                                            }
2131                                    }
2132                                    else {
2133                                            if (orderByComparator.isAscending() ^ previous) {
2134                                                    query.append(WHERE_GREATER_THAN);
2135                                            }
2136                                            else {
2137                                                    query.append(WHERE_LESSER_THAN);
2138                                            }
2139                                    }
2140                            }
2141    
2142                            query.append(ORDER_BY_CLAUSE);
2143    
2144                            for (int i = 0; i < orderByFields.length; i++) {
2145                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2146                                    query.append(orderByFields[i]);
2147    
2148                                    if ((i + 1) < orderByFields.length) {
2149                                            if (orderByComparator.isAscending() ^ previous) {
2150                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2151                                            }
2152                                            else {
2153                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2154                                            }
2155                                    }
2156                                    else {
2157                                            if (orderByComparator.isAscending() ^ previous) {
2158                                                    query.append(ORDER_BY_ASC);
2159                                            }
2160                                            else {
2161                                                    query.append(ORDER_BY_DESC);
2162                                            }
2163                                    }
2164                            }
2165                    }
2166    
2167                    else {
2168                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
2169                    }
2170    
2171                    String sql = query.toString();
2172    
2173                    Query q = session.createQuery(sql);
2174    
2175                    q.setFirstResult(0);
2176                    q.setMaxResults(2);
2177    
2178                    QueryPos qPos = QueryPos.getInstance(q);
2179    
2180                    qPos.add(entryId2);
2181    
2182                    qPos.add(type);
2183    
2184                    if (orderByComparator != null) {
2185                            Object[] values = orderByComparator.getOrderByValues(assetLink);
2186    
2187                            for (Object value : values) {
2188                                    qPos.add(value);
2189                            }
2190                    }
2191    
2192                    List<AssetLink> list = q.list();
2193    
2194                    if (list.size() == 2) {
2195                            return list.get(1);
2196                    }
2197                    else {
2198                            return null;
2199                    }
2200            }
2201    
2202            /**
2203             * Finds all the asset links where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2204             *
2205             * @param entryId1 the entry id1 to search with
2206             * @param entryId2 the entry id2 to search with
2207             * @param type the type to search with
2208             * @return the matching asset links
2209             * @throws SystemException if a system exception occurred
2210             */
2211            public List<AssetLink> findByE_E_T(long entryId1, long entryId2, int type)
2212                    throws SystemException {
2213                    return findByE_E_T(entryId1, entryId2, type, QueryUtil.ALL_POS,
2214                            QueryUtil.ALL_POS, null);
2215            }
2216    
2217            /**
2218             * Finds a range of all the asset links where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2219             *
2220             * <p>
2221             * 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.
2222             * </p>
2223             *
2224             * @param entryId1 the entry id1 to search with
2225             * @param entryId2 the entry id2 to search with
2226             * @param type the type to search with
2227             * @param start the lower bound of the range of asset links to return
2228             * @param end the upper bound of the range of asset links to return (not inclusive)
2229             * @return the range of matching asset links
2230             * @throws SystemException if a system exception occurred
2231             */
2232            public List<AssetLink> findByE_E_T(long entryId1, long entryId2, int type,
2233                    int start, int end) throws SystemException {
2234                    return findByE_E_T(entryId1, entryId2, type, start, end, null);
2235            }
2236    
2237            /**
2238             * Finds an ordered range of all the asset links where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2239             *
2240             * <p>
2241             * 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.
2242             * </p>
2243             *
2244             * @param entryId1 the entry id1 to search with
2245             * @param entryId2 the entry id2 to search with
2246             * @param type the type to search with
2247             * @param start the lower bound of the range of asset links to return
2248             * @param end the upper bound of the range of asset links to return (not inclusive)
2249             * @param orderByComparator the comparator to order the results by
2250             * @return the ordered range of matching asset links
2251             * @throws SystemException if a system exception occurred
2252             */
2253            public List<AssetLink> findByE_E_T(long entryId1, long entryId2, int type,
2254                    int start, int end, OrderByComparator orderByComparator)
2255                    throws SystemException {
2256                    Object[] finderArgs = new Object[] {
2257                                    entryId1, entryId2, type,
2258                                    
2259                                    String.valueOf(start), String.valueOf(end),
2260                                    String.valueOf(orderByComparator)
2261                            };
2262    
2263                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_E_E_T,
2264                                    finderArgs, this);
2265    
2266                    if (list == null) {
2267                            Session session = null;
2268    
2269                            try {
2270                                    session = openSession();
2271    
2272                                    StringBundler query = null;
2273    
2274                                    if (orderByComparator != null) {
2275                                            query = new StringBundler(5 +
2276                                                            (orderByComparator.getOrderByFields().length * 3));
2277                                    }
2278                                    else {
2279                                            query = new StringBundler(5);
2280                                    }
2281    
2282                                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
2283    
2284                                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID1_2);
2285    
2286                                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID2_2);
2287    
2288                                    query.append(_FINDER_COLUMN_E_E_T_TYPE_2);
2289    
2290                                    if (orderByComparator != null) {
2291                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2292                                                    orderByComparator);
2293                                    }
2294    
2295                                    else {
2296                                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
2297                                    }
2298    
2299                                    String sql = query.toString();
2300    
2301                                    Query q = session.createQuery(sql);
2302    
2303                                    QueryPos qPos = QueryPos.getInstance(q);
2304    
2305                                    qPos.add(entryId1);
2306    
2307                                    qPos.add(entryId2);
2308    
2309                                    qPos.add(type);
2310    
2311                                    list = (List<AssetLink>)QueryUtil.list(q, getDialect(), start,
2312                                                    end);
2313                            }
2314                            catch (Exception e) {
2315                                    throw processException(e);
2316                            }
2317                            finally {
2318                                    if (list == null) {
2319                                            list = new ArrayList<AssetLink>();
2320                                    }
2321    
2322                                    cacheResult(list);
2323    
2324                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_E_E_T,
2325                                            finderArgs, list);
2326    
2327                                    closeSession(session);
2328                            }
2329                    }
2330    
2331                    return list;
2332            }
2333    
2334            /**
2335             * Finds the first asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2336             *
2337             * <p>
2338             * 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.
2339             * </p>
2340             *
2341             * @param entryId1 the entry id1 to search with
2342             * @param entryId2 the entry id2 to search with
2343             * @param type the type to search with
2344             * @param orderByComparator the comparator to order the set by
2345             * @return the first matching asset link
2346             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
2347             * @throws SystemException if a system exception occurred
2348             */
2349            public AssetLink findByE_E_T_First(long entryId1, long entryId2, int type,
2350                    OrderByComparator orderByComparator)
2351                    throws NoSuchLinkException, SystemException {
2352                    List<AssetLink> list = findByE_E_T(entryId1, entryId2, type, 0, 1,
2353                                    orderByComparator);
2354    
2355                    if (list.isEmpty()) {
2356                            StringBundler msg = new StringBundler(8);
2357    
2358                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2359    
2360                            msg.append("entryId1=");
2361                            msg.append(entryId1);
2362    
2363                            msg.append(", entryId2=");
2364                            msg.append(entryId2);
2365    
2366                            msg.append(", type=");
2367                            msg.append(type);
2368    
2369                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2370    
2371                            throw new NoSuchLinkException(msg.toString());
2372                    }
2373                    else {
2374                            return list.get(0);
2375                    }
2376            }
2377    
2378            /**
2379             * Finds the last asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2380             *
2381             * <p>
2382             * 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.
2383             * </p>
2384             *
2385             * @param entryId1 the entry id1 to search with
2386             * @param entryId2 the entry id2 to search with
2387             * @param type the type to search with
2388             * @param orderByComparator the comparator to order the set by
2389             * @return the last matching asset link
2390             * @throws com.liferay.portlet.asset.NoSuchLinkException if a matching asset link could not be found
2391             * @throws SystemException if a system exception occurred
2392             */
2393            public AssetLink findByE_E_T_Last(long entryId1, long entryId2, int type,
2394                    OrderByComparator orderByComparator)
2395                    throws NoSuchLinkException, SystemException {
2396                    int count = countByE_E_T(entryId1, entryId2, type);
2397    
2398                    List<AssetLink> list = findByE_E_T(entryId1, entryId2, type, count - 1,
2399                                    count, orderByComparator);
2400    
2401                    if (list.isEmpty()) {
2402                            StringBundler msg = new StringBundler(8);
2403    
2404                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
2405    
2406                            msg.append("entryId1=");
2407                            msg.append(entryId1);
2408    
2409                            msg.append(", entryId2=");
2410                            msg.append(entryId2);
2411    
2412                            msg.append(", type=");
2413                            msg.append(type);
2414    
2415                            msg.append(StringPool.CLOSE_CURLY_BRACE);
2416    
2417                            throw new NoSuchLinkException(msg.toString());
2418                    }
2419                    else {
2420                            return list.get(0);
2421                    }
2422            }
2423    
2424            /**
2425             * Finds the asset links before and after the current asset link in the ordered set where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
2426             *
2427             * <p>
2428             * 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.
2429             * </p>
2430             *
2431             * @param linkId the primary key of the current asset link
2432             * @param entryId1 the entry id1 to search with
2433             * @param entryId2 the entry id2 to search with
2434             * @param type the type to search with
2435             * @param orderByComparator the comparator to order the set by
2436             * @return the previous, current, and next asset link
2437             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
2438             * @throws SystemException if a system exception occurred
2439             */
2440            public AssetLink[] findByE_E_T_PrevAndNext(long linkId, long entryId1,
2441                    long entryId2, int type, OrderByComparator orderByComparator)
2442                    throws NoSuchLinkException, SystemException {
2443                    AssetLink assetLink = findByPrimaryKey(linkId);
2444    
2445                    Session session = null;
2446    
2447                    try {
2448                            session = openSession();
2449    
2450                            AssetLink[] array = new AssetLinkImpl[3];
2451    
2452                            array[0] = getByE_E_T_PrevAndNext(session, assetLink, entryId1,
2453                                            entryId2, type, orderByComparator, true);
2454    
2455                            array[1] = assetLink;
2456    
2457                            array[2] = getByE_E_T_PrevAndNext(session, assetLink, entryId1,
2458                                            entryId2, type, orderByComparator, false);
2459    
2460                            return array;
2461                    }
2462                    catch (Exception e) {
2463                            throw processException(e);
2464                    }
2465                    finally {
2466                            closeSession(session);
2467                    }
2468            }
2469    
2470            protected AssetLink getByE_E_T_PrevAndNext(Session session,
2471                    AssetLink assetLink, long entryId1, long entryId2, int type,
2472                    OrderByComparator orderByComparator, boolean previous) {
2473                    StringBundler query = null;
2474    
2475                    if (orderByComparator != null) {
2476                            query = new StringBundler(6 +
2477                                            (orderByComparator.getOrderByFields().length * 6));
2478                    }
2479                    else {
2480                            query = new StringBundler(3);
2481                    }
2482    
2483                    query.append(_SQL_SELECT_ASSETLINK_WHERE);
2484    
2485                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID1_2);
2486    
2487                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID2_2);
2488    
2489                    query.append(_FINDER_COLUMN_E_E_T_TYPE_2);
2490    
2491                    if (orderByComparator != null) {
2492                            String[] orderByFields = orderByComparator.getOrderByFields();
2493    
2494                            if (orderByFields.length > 0) {
2495                                    query.append(WHERE_AND);
2496                            }
2497    
2498                            for (int i = 0; i < orderByFields.length; i++) {
2499                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2500                                    query.append(orderByFields[i]);
2501    
2502                                    if ((i + 1) < orderByFields.length) {
2503                                            if (orderByComparator.isAscending() ^ previous) {
2504                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
2505                                            }
2506                                            else {
2507                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
2508                                            }
2509                                    }
2510                                    else {
2511                                            if (orderByComparator.isAscending() ^ previous) {
2512                                                    query.append(WHERE_GREATER_THAN);
2513                                            }
2514                                            else {
2515                                                    query.append(WHERE_LESSER_THAN);
2516                                            }
2517                                    }
2518                            }
2519    
2520                            query.append(ORDER_BY_CLAUSE);
2521    
2522                            for (int i = 0; i < orderByFields.length; i++) {
2523                                    query.append(_ORDER_BY_ENTITY_ALIAS);
2524                                    query.append(orderByFields[i]);
2525    
2526                                    if ((i + 1) < orderByFields.length) {
2527                                            if (orderByComparator.isAscending() ^ previous) {
2528                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
2529                                            }
2530                                            else {
2531                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
2532                                            }
2533                                    }
2534                                    else {
2535                                            if (orderByComparator.isAscending() ^ previous) {
2536                                                    query.append(ORDER_BY_ASC);
2537                                            }
2538                                            else {
2539                                                    query.append(ORDER_BY_DESC);
2540                                            }
2541                                    }
2542                            }
2543                    }
2544    
2545                    else {
2546                            query.append(AssetLinkModelImpl.ORDER_BY_JPQL);
2547                    }
2548    
2549                    String sql = query.toString();
2550    
2551                    Query q = session.createQuery(sql);
2552    
2553                    q.setFirstResult(0);
2554                    q.setMaxResults(2);
2555    
2556                    QueryPos qPos = QueryPos.getInstance(q);
2557    
2558                    qPos.add(entryId1);
2559    
2560                    qPos.add(entryId2);
2561    
2562                    qPos.add(type);
2563    
2564                    if (orderByComparator != null) {
2565                            Object[] values = orderByComparator.getOrderByValues(assetLink);
2566    
2567                            for (Object value : values) {
2568                                    qPos.add(value);
2569                            }
2570                    }
2571    
2572                    List<AssetLink> list = q.list();
2573    
2574                    if (list.size() == 2) {
2575                            return list.get(1);
2576                    }
2577                    else {
2578                            return null;
2579                    }
2580            }
2581    
2582            /**
2583             * Finds all the asset links.
2584             *
2585             * @return the asset links
2586             * @throws SystemException if a system exception occurred
2587             */
2588            public List<AssetLink> findAll() throws SystemException {
2589                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
2590            }
2591    
2592            /**
2593             * Finds a range of all the asset links.
2594             *
2595             * <p>
2596             * 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.
2597             * </p>
2598             *
2599             * @param start the lower bound of the range of asset links to return
2600             * @param end the upper bound of the range of asset links to return (not inclusive)
2601             * @return the range of asset links
2602             * @throws SystemException if a system exception occurred
2603             */
2604            public List<AssetLink> findAll(int start, int end)
2605                    throws SystemException {
2606                    return findAll(start, end, null);
2607            }
2608    
2609            /**
2610             * Finds an ordered range of all the asset links.
2611             *
2612             * <p>
2613             * 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.
2614             * </p>
2615             *
2616             * @param start the lower bound of the range of asset links to return
2617             * @param end the upper bound of the range of asset links to return (not inclusive)
2618             * @param orderByComparator the comparator to order the results by
2619             * @return the ordered range of asset links
2620             * @throws SystemException if a system exception occurred
2621             */
2622            public List<AssetLink> findAll(int start, int end,
2623                    OrderByComparator orderByComparator) throws SystemException {
2624                    Object[] finderArgs = new Object[] {
2625                                    String.valueOf(start), String.valueOf(end),
2626                                    String.valueOf(orderByComparator)
2627                            };
2628    
2629                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
2630                                    finderArgs, this);
2631    
2632                    if (list == null) {
2633                            Session session = null;
2634    
2635                            try {
2636                                    session = openSession();
2637    
2638                                    StringBundler query = null;
2639                                    String sql = null;
2640    
2641                                    if (orderByComparator != null) {
2642                                            query = new StringBundler(2 +
2643                                                            (orderByComparator.getOrderByFields().length * 3));
2644    
2645                                            query.append(_SQL_SELECT_ASSETLINK);
2646    
2647                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
2648                                                    orderByComparator);
2649    
2650                                            sql = query.toString();
2651                                    }
2652                                    else {
2653                                            sql = _SQL_SELECT_ASSETLINK.concat(AssetLinkModelImpl.ORDER_BY_JPQL);
2654                                    }
2655    
2656                                    Query q = session.createQuery(sql);
2657    
2658                                    if (orderByComparator == null) {
2659                                            list = (List<AssetLink>)QueryUtil.list(q, getDialect(),
2660                                                            start, end, false);
2661    
2662                                            Collections.sort(list);
2663                                    }
2664                                    else {
2665                                            list = (List<AssetLink>)QueryUtil.list(q, getDialect(),
2666                                                            start, end);
2667                                    }
2668                            }
2669                            catch (Exception e) {
2670                                    throw processException(e);
2671                            }
2672                            finally {
2673                                    if (list == null) {
2674                                            list = new ArrayList<AssetLink>();
2675                                    }
2676    
2677                                    cacheResult(list);
2678    
2679                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
2680    
2681                                    closeSession(session);
2682                            }
2683                    }
2684    
2685                    return list;
2686            }
2687    
2688            /**
2689             * Removes all the asset links where entryId1 = &#63; from the database.
2690             *
2691             * @param entryId1 the entry id1 to search with
2692             * @throws SystemException if a system exception occurred
2693             */
2694            public void removeByE1(long entryId1) throws SystemException {
2695                    for (AssetLink assetLink : findByE1(entryId1)) {
2696                            remove(assetLink);
2697                    }
2698            }
2699    
2700            /**
2701             * Removes all the asset links where entryId2 = &#63; from the database.
2702             *
2703             * @param entryId2 the entry id2 to search with
2704             * @throws SystemException if a system exception occurred
2705             */
2706            public void removeByE2(long entryId2) throws SystemException {
2707                    for (AssetLink assetLink : findByE2(entryId2)) {
2708                            remove(assetLink);
2709                    }
2710            }
2711    
2712            /**
2713             * Removes all the asset links where entryId1 = &#63; and entryId2 = &#63; from the database.
2714             *
2715             * @param entryId1 the entry id1 to search with
2716             * @param entryId2 the entry id2 to search with
2717             * @throws SystemException if a system exception occurred
2718             */
2719            public void removeByE_E(long entryId1, long entryId2)
2720                    throws SystemException {
2721                    for (AssetLink assetLink : findByE_E(entryId1, entryId2)) {
2722                            remove(assetLink);
2723                    }
2724            }
2725    
2726            /**
2727             * Removes all the asset links where entryId1 = &#63; and type = &#63; from the database.
2728             *
2729             * @param entryId1 the entry id1 to search with
2730             * @param type the type to search with
2731             * @throws SystemException if a system exception occurred
2732             */
2733            public void removeByE1_T(long entryId1, int type) throws SystemException {
2734                    for (AssetLink assetLink : findByE1_T(entryId1, type)) {
2735                            remove(assetLink);
2736                    }
2737            }
2738    
2739            /**
2740             * Removes all the asset links where entryId2 = &#63; and type = &#63; from the database.
2741             *
2742             * @param entryId2 the entry id2 to search with
2743             * @param type the type to search with
2744             * @throws SystemException if a system exception occurred
2745             */
2746            public void removeByE2_T(long entryId2, int type) throws SystemException {
2747                    for (AssetLink assetLink : findByE2_T(entryId2, type)) {
2748                            remove(assetLink);
2749                    }
2750            }
2751    
2752            /**
2753             * Removes all the asset links where entryId1 = &#63; and entryId2 = &#63; and type = &#63; from the database.
2754             *
2755             * @param entryId1 the entry id1 to search with
2756             * @param entryId2 the entry id2 to search with
2757             * @param type the type to search with
2758             * @throws SystemException if a system exception occurred
2759             */
2760            public void removeByE_E_T(long entryId1, long entryId2, int type)
2761                    throws SystemException {
2762                    for (AssetLink assetLink : findByE_E_T(entryId1, entryId2, type)) {
2763                            remove(assetLink);
2764                    }
2765            }
2766    
2767            /**
2768             * Removes all the asset links from the database.
2769             *
2770             * @throws SystemException if a system exception occurred
2771             */
2772            public void removeAll() throws SystemException {
2773                    for (AssetLink assetLink : findAll()) {
2774                            remove(assetLink);
2775                    }
2776            }
2777    
2778            /**
2779             * Counts all the asset links where entryId1 = &#63;.
2780             *
2781             * @param entryId1 the entry id1 to search with
2782             * @return the number of matching asset links
2783             * @throws SystemException if a system exception occurred
2784             */
2785            public int countByE1(long entryId1) throws SystemException {
2786                    Object[] finderArgs = new Object[] { entryId1 };
2787    
2788                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E1,
2789                                    finderArgs, this);
2790    
2791                    if (count == null) {
2792                            Session session = null;
2793    
2794                            try {
2795                                    session = openSession();
2796    
2797                                    StringBundler query = new StringBundler(2);
2798    
2799                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
2800    
2801                                    query.append(_FINDER_COLUMN_E1_ENTRYID1_2);
2802    
2803                                    String sql = query.toString();
2804    
2805                                    Query q = session.createQuery(sql);
2806    
2807                                    QueryPos qPos = QueryPos.getInstance(q);
2808    
2809                                    qPos.add(entryId1);
2810    
2811                                    count = (Long)q.uniqueResult();
2812                            }
2813                            catch (Exception e) {
2814                                    throw processException(e);
2815                            }
2816                            finally {
2817                                    if (count == null) {
2818                                            count = Long.valueOf(0);
2819                                    }
2820    
2821                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E1, finderArgs,
2822                                            count);
2823    
2824                                    closeSession(session);
2825                            }
2826                    }
2827    
2828                    return count.intValue();
2829            }
2830    
2831            /**
2832             * Counts all the asset links where entryId2 = &#63;.
2833             *
2834             * @param entryId2 the entry id2 to search with
2835             * @return the number of matching asset links
2836             * @throws SystemException if a system exception occurred
2837             */
2838            public int countByE2(long entryId2) throws SystemException {
2839                    Object[] finderArgs = new Object[] { entryId2 };
2840    
2841                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E2,
2842                                    finderArgs, this);
2843    
2844                    if (count == null) {
2845                            Session session = null;
2846    
2847                            try {
2848                                    session = openSession();
2849    
2850                                    StringBundler query = new StringBundler(2);
2851    
2852                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
2853    
2854                                    query.append(_FINDER_COLUMN_E2_ENTRYID2_2);
2855    
2856                                    String sql = query.toString();
2857    
2858                                    Query q = session.createQuery(sql);
2859    
2860                                    QueryPos qPos = QueryPos.getInstance(q);
2861    
2862                                    qPos.add(entryId2);
2863    
2864                                    count = (Long)q.uniqueResult();
2865                            }
2866                            catch (Exception e) {
2867                                    throw processException(e);
2868                            }
2869                            finally {
2870                                    if (count == null) {
2871                                            count = Long.valueOf(0);
2872                                    }
2873    
2874                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E2, finderArgs,
2875                                            count);
2876    
2877                                    closeSession(session);
2878                            }
2879                    }
2880    
2881                    return count.intValue();
2882            }
2883    
2884            /**
2885             * Counts all the asset links where entryId1 = &#63; and entryId2 = &#63;.
2886             *
2887             * @param entryId1 the entry id1 to search with
2888             * @param entryId2 the entry id2 to search with
2889             * @return the number of matching asset links
2890             * @throws SystemException if a system exception occurred
2891             */
2892            public int countByE_E(long entryId1, long entryId2)
2893                    throws SystemException {
2894                    Object[] finderArgs = new Object[] { entryId1, entryId2 };
2895    
2896                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E_E,
2897                                    finderArgs, this);
2898    
2899                    if (count == null) {
2900                            Session session = null;
2901    
2902                            try {
2903                                    session = openSession();
2904    
2905                                    StringBundler query = new StringBundler(3);
2906    
2907                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
2908    
2909                                    query.append(_FINDER_COLUMN_E_E_ENTRYID1_2);
2910    
2911                                    query.append(_FINDER_COLUMN_E_E_ENTRYID2_2);
2912    
2913                                    String sql = query.toString();
2914    
2915                                    Query q = session.createQuery(sql);
2916    
2917                                    QueryPos qPos = QueryPos.getInstance(q);
2918    
2919                                    qPos.add(entryId1);
2920    
2921                                    qPos.add(entryId2);
2922    
2923                                    count = (Long)q.uniqueResult();
2924                            }
2925                            catch (Exception e) {
2926                                    throw processException(e);
2927                            }
2928                            finally {
2929                                    if (count == null) {
2930                                            count = Long.valueOf(0);
2931                                    }
2932    
2933                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_E, finderArgs,
2934                                            count);
2935    
2936                                    closeSession(session);
2937                            }
2938                    }
2939    
2940                    return count.intValue();
2941            }
2942    
2943            /**
2944             * Counts all the asset links where entryId1 = &#63; and type = &#63;.
2945             *
2946             * @param entryId1 the entry id1 to search with
2947             * @param type the type to search with
2948             * @return the number of matching asset links
2949             * @throws SystemException if a system exception occurred
2950             */
2951            public int countByE1_T(long entryId1, int type) throws SystemException {
2952                    Object[] finderArgs = new Object[] { entryId1, type };
2953    
2954                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E1_T,
2955                                    finderArgs, this);
2956    
2957                    if (count == null) {
2958                            Session session = null;
2959    
2960                            try {
2961                                    session = openSession();
2962    
2963                                    StringBundler query = new StringBundler(3);
2964    
2965                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
2966    
2967                                    query.append(_FINDER_COLUMN_E1_T_ENTRYID1_2);
2968    
2969                                    query.append(_FINDER_COLUMN_E1_T_TYPE_2);
2970    
2971                                    String sql = query.toString();
2972    
2973                                    Query q = session.createQuery(sql);
2974    
2975                                    QueryPos qPos = QueryPos.getInstance(q);
2976    
2977                                    qPos.add(entryId1);
2978    
2979                                    qPos.add(type);
2980    
2981                                    count = (Long)q.uniqueResult();
2982                            }
2983                            catch (Exception e) {
2984                                    throw processException(e);
2985                            }
2986                            finally {
2987                                    if (count == null) {
2988                                            count = Long.valueOf(0);
2989                                    }
2990    
2991                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E1_T,
2992                                            finderArgs, count);
2993    
2994                                    closeSession(session);
2995                            }
2996                    }
2997    
2998                    return count.intValue();
2999            }
3000    
3001            /**
3002             * Counts all the asset links where entryId2 = &#63; and type = &#63;.
3003             *
3004             * @param entryId2 the entry id2 to search with
3005             * @param type the type to search with
3006             * @return the number of matching asset links
3007             * @throws SystemException if a system exception occurred
3008             */
3009            public int countByE2_T(long entryId2, int type) throws SystemException {
3010                    Object[] finderArgs = new Object[] { entryId2, type };
3011    
3012                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E2_T,
3013                                    finderArgs, this);
3014    
3015                    if (count == null) {
3016                            Session session = null;
3017    
3018                            try {
3019                                    session = openSession();
3020    
3021                                    StringBundler query = new StringBundler(3);
3022    
3023                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
3024    
3025                                    query.append(_FINDER_COLUMN_E2_T_ENTRYID2_2);
3026    
3027                                    query.append(_FINDER_COLUMN_E2_T_TYPE_2);
3028    
3029                                    String sql = query.toString();
3030    
3031                                    Query q = session.createQuery(sql);
3032    
3033                                    QueryPos qPos = QueryPos.getInstance(q);
3034    
3035                                    qPos.add(entryId2);
3036    
3037                                    qPos.add(type);
3038    
3039                                    count = (Long)q.uniqueResult();
3040                            }
3041                            catch (Exception e) {
3042                                    throw processException(e);
3043                            }
3044                            finally {
3045                                    if (count == null) {
3046                                            count = Long.valueOf(0);
3047                                    }
3048    
3049                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E2_T,
3050                                            finderArgs, count);
3051    
3052                                    closeSession(session);
3053                            }
3054                    }
3055    
3056                    return count.intValue();
3057            }
3058    
3059            /**
3060             * Counts all the asset links where entryId1 = &#63; and entryId2 = &#63; and type = &#63;.
3061             *
3062             * @param entryId1 the entry id1 to search with
3063             * @param entryId2 the entry id2 to search with
3064             * @param type the type to search with
3065             * @return the number of matching asset links
3066             * @throws SystemException if a system exception occurred
3067             */
3068            public int countByE_E_T(long entryId1, long entryId2, int type)
3069                    throws SystemException {
3070                    Object[] finderArgs = new Object[] { entryId1, entryId2, type };
3071    
3072                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_E_E_T,
3073                                    finderArgs, this);
3074    
3075                    if (count == null) {
3076                            Session session = null;
3077    
3078                            try {
3079                                    session = openSession();
3080    
3081                                    StringBundler query = new StringBundler(4);
3082    
3083                                    query.append(_SQL_COUNT_ASSETLINK_WHERE);
3084    
3085                                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID1_2);
3086    
3087                                    query.append(_FINDER_COLUMN_E_E_T_ENTRYID2_2);
3088    
3089                                    query.append(_FINDER_COLUMN_E_E_T_TYPE_2);
3090    
3091                                    String sql = query.toString();
3092    
3093                                    Query q = session.createQuery(sql);
3094    
3095                                    QueryPos qPos = QueryPos.getInstance(q);
3096    
3097                                    qPos.add(entryId1);
3098    
3099                                    qPos.add(entryId2);
3100    
3101                                    qPos.add(type);
3102    
3103                                    count = (Long)q.uniqueResult();
3104                            }
3105                            catch (Exception e) {
3106                                    throw processException(e);
3107                            }
3108                            finally {
3109                                    if (count == null) {
3110                                            count = Long.valueOf(0);
3111                                    }
3112    
3113                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_E_T,
3114                                            finderArgs, count);
3115    
3116                                    closeSession(session);
3117                            }
3118                    }
3119    
3120                    return count.intValue();
3121            }
3122    
3123            /**
3124             * Counts all the asset links.
3125             *
3126             * @return the number of asset links
3127             * @throws SystemException if a system exception occurred
3128             */
3129            public int countAll() throws SystemException {
3130                    Object[] finderArgs = new Object[0];
3131    
3132                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3133                                    finderArgs, this);
3134    
3135                    if (count == null) {
3136                            Session session = null;
3137    
3138                            try {
3139                                    session = openSession();
3140    
3141                                    Query q = session.createQuery(_SQL_COUNT_ASSETLINK);
3142    
3143                                    count = (Long)q.uniqueResult();
3144                            }
3145                            catch (Exception e) {
3146                                    throw processException(e);
3147                            }
3148                            finally {
3149                                    if (count == null) {
3150                                            count = Long.valueOf(0);
3151                                    }
3152    
3153                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
3154                                            count);
3155    
3156                                    closeSession(session);
3157                            }
3158                    }
3159    
3160                    return count.intValue();
3161            }
3162    
3163            /**
3164             * Initializes the asset link persistence.
3165             */
3166            public void afterPropertiesSet() {
3167                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3168                                            com.liferay.portal.util.PropsUtil.get(
3169                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetLink")));
3170    
3171                    if (listenerClassNames.length > 0) {
3172                            try {
3173                                    List<ModelListener<AssetLink>> listenersList = new ArrayList<ModelListener<AssetLink>>();
3174    
3175                                    for (String listenerClassName : listenerClassNames) {
3176                                            listenersList.add((ModelListener<AssetLink>)InstanceFactory.newInstance(
3177                                                            listenerClassName));
3178                                    }
3179    
3180                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3181                            }
3182                            catch (Exception e) {
3183                                    _log.error(e);
3184                            }
3185                    }
3186            }
3187    
3188            @BeanReference(type = AssetCategoryPersistence.class)
3189            protected AssetCategoryPersistence assetCategoryPersistence;
3190            @BeanReference(type = AssetCategoryPropertyPersistence.class)
3191            protected AssetCategoryPropertyPersistence assetCategoryPropertyPersistence;
3192            @BeanReference(type = AssetEntryPersistence.class)
3193            protected AssetEntryPersistence assetEntryPersistence;
3194            @BeanReference(type = AssetLinkPersistence.class)
3195            protected AssetLinkPersistence assetLinkPersistence;
3196            @BeanReference(type = AssetTagPersistence.class)
3197            protected AssetTagPersistence assetTagPersistence;
3198            @BeanReference(type = AssetTagPropertyPersistence.class)
3199            protected AssetTagPropertyPersistence assetTagPropertyPersistence;
3200            @BeanReference(type = AssetTagStatsPersistence.class)
3201            protected AssetTagStatsPersistence assetTagStatsPersistence;
3202            @BeanReference(type = AssetVocabularyPersistence.class)
3203            protected AssetVocabularyPersistence assetVocabularyPersistence;
3204            @BeanReference(type = ResourcePersistence.class)
3205            protected ResourcePersistence resourcePersistence;
3206            @BeanReference(type = UserPersistence.class)
3207            protected UserPersistence userPersistence;
3208            private static final String _SQL_SELECT_ASSETLINK = "SELECT assetLink FROM AssetLink assetLink";
3209            private static final String _SQL_SELECT_ASSETLINK_WHERE = "SELECT assetLink FROM AssetLink assetLink WHERE ";
3210            private static final String _SQL_COUNT_ASSETLINK = "SELECT COUNT(assetLink) FROM AssetLink assetLink";
3211            private static final String _SQL_COUNT_ASSETLINK_WHERE = "SELECT COUNT(assetLink) FROM AssetLink assetLink WHERE ";
3212            private static final String _FINDER_COLUMN_E1_ENTRYID1_2 = "assetLink.entryId1 = ?";
3213            private static final String _FINDER_COLUMN_E2_ENTRYID2_2 = "assetLink.entryId2 = ?";
3214            private static final String _FINDER_COLUMN_E_E_ENTRYID1_2 = "assetLink.entryId1 = ? AND ";
3215            private static final String _FINDER_COLUMN_E_E_ENTRYID2_2 = "assetLink.entryId2 = ?";
3216            private static final String _FINDER_COLUMN_E1_T_ENTRYID1_2 = "assetLink.entryId1 = ? AND ";
3217            private static final String _FINDER_COLUMN_E1_T_TYPE_2 = "assetLink.type = ?";
3218            private static final String _FINDER_COLUMN_E2_T_ENTRYID2_2 = "assetLink.entryId2 = ? AND ";
3219            private static final String _FINDER_COLUMN_E2_T_TYPE_2 = "assetLink.type = ?";
3220            private static final String _FINDER_COLUMN_E_E_T_ENTRYID1_2 = "assetLink.entryId1 = ? AND ";
3221            private static final String _FINDER_COLUMN_E_E_T_ENTRYID2_2 = "assetLink.entryId2 = ? AND ";
3222            private static final String _FINDER_COLUMN_E_E_T_TYPE_2 = "assetLink.type = ?";
3223            private static final String _ORDER_BY_ENTITY_ALIAS = "assetLink.";
3224            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetLink exists with the primary key ";
3225            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetLink exists with the key {";
3226            private static Log _log = LogFactoryUtil.getLog(AssetLinkPersistenceImpl.class);
3227    }