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