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