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