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