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            public AssetLinkPersistenceImpl() {
2895                    setModelClass(AssetLink.class);
2896            }
2897    
2898            /**
2899             * Caches the asset link in the entity cache if it is enabled.
2900             *
2901             * @param assetLink the asset link
2902             */
2903            @Override
2904            public void cacheResult(AssetLink assetLink) {
2905                    EntityCacheUtil.putResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
2906                            AssetLinkImpl.class, assetLink.getPrimaryKey(), assetLink);
2907    
2908                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_E_T,
2909                            new Object[] {
2910                                    assetLink.getEntryId1(), assetLink.getEntryId2(),
2911                                    assetLink.getType()
2912                            }, assetLink);
2913    
2914                    assetLink.resetOriginalValues();
2915            }
2916    
2917            /**
2918             * Caches the asset links in the entity cache if it is enabled.
2919             *
2920             * @param assetLinks the asset links
2921             */
2922            @Override
2923            public void cacheResult(List<AssetLink> assetLinks) {
2924                    for (AssetLink assetLink : assetLinks) {
2925                            if (EntityCacheUtil.getResult(
2926                                                    AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
2927                                                    AssetLinkImpl.class, assetLink.getPrimaryKey()) == null) {
2928                                    cacheResult(assetLink);
2929                            }
2930                            else {
2931                                    assetLink.resetOriginalValues();
2932                            }
2933                    }
2934            }
2935    
2936            /**
2937             * Clears the cache for all asset links.
2938             *
2939             * <p>
2940             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2941             * </p>
2942             */
2943            @Override
2944            public void clearCache() {
2945                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
2946                            CacheRegistryUtil.clear(AssetLinkImpl.class.getName());
2947                    }
2948    
2949                    EntityCacheUtil.clearCache(AssetLinkImpl.class.getName());
2950    
2951                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
2952                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2953                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2954            }
2955    
2956            /**
2957             * Clears the cache for the asset link.
2958             *
2959             * <p>
2960             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
2961             * </p>
2962             */
2963            @Override
2964            public void clearCache(AssetLink assetLink) {
2965                    EntityCacheUtil.removeResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
2966                            AssetLinkImpl.class, assetLink.getPrimaryKey());
2967    
2968                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2969                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2970    
2971                    clearUniqueFindersCache(assetLink);
2972            }
2973    
2974            @Override
2975            public void clearCache(List<AssetLink> assetLinks) {
2976                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
2977                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2978    
2979                    for (AssetLink assetLink : assetLinks) {
2980                            EntityCacheUtil.removeResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
2981                                    AssetLinkImpl.class, assetLink.getPrimaryKey());
2982    
2983                            clearUniqueFindersCache(assetLink);
2984                    }
2985            }
2986    
2987            protected void cacheUniqueFindersCache(AssetLink assetLink) {
2988                    if (assetLink.isNew()) {
2989                            Object[] args = new Object[] {
2990                                            assetLink.getEntryId1(), assetLink.getEntryId2(),
2991                                            assetLink.getType()
2992                                    };
2993    
2994                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_E_T, args,
2995                                    Long.valueOf(1));
2996                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_E_T, args,
2997                                    assetLink);
2998                    }
2999                    else {
3000                            AssetLinkModelImpl assetLinkModelImpl = (AssetLinkModelImpl)assetLink;
3001    
3002                            if ((assetLinkModelImpl.getColumnBitmask() &
3003                                            FINDER_PATH_FETCH_BY_E_E_T.getColumnBitmask()) != 0) {
3004                                    Object[] args = new Object[] {
3005                                                    assetLink.getEntryId1(), assetLink.getEntryId2(),
3006                                                    assetLink.getType()
3007                                            };
3008    
3009                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_E_E_T, args,
3010                                            Long.valueOf(1));
3011                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_E_E_T, args,
3012                                            assetLink);
3013                            }
3014                    }
3015            }
3016    
3017            protected void clearUniqueFindersCache(AssetLink assetLink) {
3018                    AssetLinkModelImpl assetLinkModelImpl = (AssetLinkModelImpl)assetLink;
3019    
3020                    Object[] args = new Object[] {
3021                                    assetLink.getEntryId1(), assetLink.getEntryId2(),
3022                                    assetLink.getType()
3023                            };
3024    
3025                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E_E_T, args);
3026                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_E_T, args);
3027    
3028                    if ((assetLinkModelImpl.getColumnBitmask() &
3029                                    FINDER_PATH_FETCH_BY_E_E_T.getColumnBitmask()) != 0) {
3030                            args = new Object[] {
3031                                            assetLinkModelImpl.getOriginalEntryId1(),
3032                                            assetLinkModelImpl.getOriginalEntryId2(),
3033                                            assetLinkModelImpl.getOriginalType()
3034                                    };
3035    
3036                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E_E_T, args);
3037                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_E_E_T, args);
3038                    }
3039            }
3040    
3041            /**
3042             * Creates a new asset link with the primary key. Does not add the asset link to the database.
3043             *
3044             * @param linkId the primary key for the new asset link
3045             * @return the new asset link
3046             */
3047            @Override
3048            public AssetLink create(long linkId) {
3049                    AssetLink assetLink = new AssetLinkImpl();
3050    
3051                    assetLink.setNew(true);
3052                    assetLink.setPrimaryKey(linkId);
3053    
3054                    return assetLink;
3055            }
3056    
3057            /**
3058             * Removes the asset link with the primary key from the database. Also notifies the appropriate model listeners.
3059             *
3060             * @param linkId the primary key of the asset link
3061             * @return the asset link that was removed
3062             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
3063             * @throws SystemException if a system exception occurred
3064             */
3065            @Override
3066            public AssetLink remove(long linkId)
3067                    throws NoSuchLinkException, SystemException {
3068                    return remove((Serializable)linkId);
3069            }
3070    
3071            /**
3072             * Removes the asset link with the primary key from the database. Also notifies the appropriate model listeners.
3073             *
3074             * @param primaryKey the primary key of the asset link
3075             * @return the asset link that was removed
3076             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
3077             * @throws SystemException if a system exception occurred
3078             */
3079            @Override
3080            public AssetLink remove(Serializable primaryKey)
3081                    throws NoSuchLinkException, SystemException {
3082                    Session session = null;
3083    
3084                    try {
3085                            session = openSession();
3086    
3087                            AssetLink assetLink = (AssetLink)session.get(AssetLinkImpl.class,
3088                                            primaryKey);
3089    
3090                            if (assetLink == null) {
3091                                    if (_log.isWarnEnabled()) {
3092                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3093                                    }
3094    
3095                                    throw new NoSuchLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3096                                            primaryKey);
3097                            }
3098    
3099                            return remove(assetLink);
3100                    }
3101                    catch (NoSuchLinkException nsee) {
3102                            throw nsee;
3103                    }
3104                    catch (Exception e) {
3105                            throw processException(e);
3106                    }
3107                    finally {
3108                            closeSession(session);
3109                    }
3110            }
3111    
3112            @Override
3113            protected AssetLink removeImpl(AssetLink assetLink)
3114                    throws SystemException {
3115                    assetLink = toUnwrappedModel(assetLink);
3116    
3117                    Session session = null;
3118    
3119                    try {
3120                            session = openSession();
3121    
3122                            if (!session.contains(assetLink)) {
3123                                    assetLink = (AssetLink)session.get(AssetLinkImpl.class,
3124                                                    assetLink.getPrimaryKeyObj());
3125                            }
3126    
3127                            if (assetLink != null) {
3128                                    session.delete(assetLink);
3129                            }
3130                    }
3131                    catch (Exception e) {
3132                            throw processException(e);
3133                    }
3134                    finally {
3135                            closeSession(session);
3136                    }
3137    
3138                    if (assetLink != null) {
3139                            clearCache(assetLink);
3140                    }
3141    
3142                    return assetLink;
3143            }
3144    
3145            @Override
3146            public AssetLink updateImpl(
3147                    com.liferay.portlet.asset.model.AssetLink assetLink)
3148                    throws SystemException {
3149                    assetLink = toUnwrappedModel(assetLink);
3150    
3151                    boolean isNew = assetLink.isNew();
3152    
3153                    AssetLinkModelImpl assetLinkModelImpl = (AssetLinkModelImpl)assetLink;
3154    
3155                    Session session = null;
3156    
3157                    try {
3158                            session = openSession();
3159    
3160                            if (assetLink.isNew()) {
3161                                    session.save(assetLink);
3162    
3163                                    assetLink.setNew(false);
3164                            }
3165                            else {
3166                                    session.merge(assetLink);
3167                            }
3168                    }
3169                    catch (Exception e) {
3170                            throw processException(e);
3171                    }
3172                    finally {
3173                            closeSession(session);
3174                    }
3175    
3176                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3177    
3178                    if (isNew || !AssetLinkModelImpl.COLUMN_BITMASK_ENABLED) {
3179                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3180                    }
3181    
3182                    else {
3183                            if ((assetLinkModelImpl.getColumnBitmask() &
3184                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1.getColumnBitmask()) != 0) {
3185                                    Object[] args = new Object[] {
3186                                                    assetLinkModelImpl.getOriginalEntryId1()
3187                                            };
3188    
3189                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E1, args);
3190                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1,
3191                                            args);
3192    
3193                                    args = new Object[] { assetLinkModelImpl.getEntryId1() };
3194    
3195                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E1, args);
3196                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1,
3197                                            args);
3198                            }
3199    
3200                            if ((assetLinkModelImpl.getColumnBitmask() &
3201                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2.getColumnBitmask()) != 0) {
3202                                    Object[] args = new Object[] {
3203                                                    assetLinkModelImpl.getOriginalEntryId2()
3204                                            };
3205    
3206                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E2, args);
3207                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2,
3208                                            args);
3209    
3210                                    args = new Object[] { assetLinkModelImpl.getEntryId2() };
3211    
3212                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E2, args);
3213                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2,
3214                                            args);
3215                            }
3216    
3217                            if ((assetLinkModelImpl.getColumnBitmask() &
3218                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E_E.getColumnBitmask()) != 0) {
3219                                    Object[] args = new Object[] {
3220                                                    assetLinkModelImpl.getOriginalEntryId1(),
3221                                                    assetLinkModelImpl.getOriginalEntryId2()
3222                                            };
3223    
3224                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E_E, args);
3225                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E_E,
3226                                            args);
3227    
3228                                    args = new Object[] {
3229                                                    assetLinkModelImpl.getEntryId1(),
3230                                                    assetLinkModelImpl.getEntryId2()
3231                                            };
3232    
3233                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E_E, args);
3234                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E_E,
3235                                            args);
3236                            }
3237    
3238                            if ((assetLinkModelImpl.getColumnBitmask() &
3239                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1_T.getColumnBitmask()) != 0) {
3240                                    Object[] args = new Object[] {
3241                                                    assetLinkModelImpl.getOriginalEntryId1(),
3242                                                    assetLinkModelImpl.getOriginalType()
3243                                            };
3244    
3245                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E1_T, args);
3246                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1_T,
3247                                            args);
3248    
3249                                    args = new Object[] {
3250                                                    assetLinkModelImpl.getEntryId1(),
3251                                                    assetLinkModelImpl.getType()
3252                                            };
3253    
3254                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E1_T, args);
3255                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E1_T,
3256                                            args);
3257                            }
3258    
3259                            if ((assetLinkModelImpl.getColumnBitmask() &
3260                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2_T.getColumnBitmask()) != 0) {
3261                                    Object[] args = new Object[] {
3262                                                    assetLinkModelImpl.getOriginalEntryId2(),
3263                                                    assetLinkModelImpl.getOriginalType()
3264                                            };
3265    
3266                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E2_T, args);
3267                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2_T,
3268                                            args);
3269    
3270                                    args = new Object[] {
3271                                                    assetLinkModelImpl.getEntryId2(),
3272                                                    assetLinkModelImpl.getType()
3273                                            };
3274    
3275                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_E2_T, args);
3276                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_E2_T,
3277                                            args);
3278                            }
3279                    }
3280    
3281                    EntityCacheUtil.putResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
3282                            AssetLinkImpl.class, assetLink.getPrimaryKey(), assetLink);
3283    
3284                    clearUniqueFindersCache(assetLink);
3285                    cacheUniqueFindersCache(assetLink);
3286    
3287                    return assetLink;
3288            }
3289    
3290            protected AssetLink toUnwrappedModel(AssetLink assetLink) {
3291                    if (assetLink instanceof AssetLinkImpl) {
3292                            return assetLink;
3293                    }
3294    
3295                    AssetLinkImpl assetLinkImpl = new AssetLinkImpl();
3296    
3297                    assetLinkImpl.setNew(assetLink.isNew());
3298                    assetLinkImpl.setPrimaryKey(assetLink.getPrimaryKey());
3299    
3300                    assetLinkImpl.setLinkId(assetLink.getLinkId());
3301                    assetLinkImpl.setCompanyId(assetLink.getCompanyId());
3302                    assetLinkImpl.setUserId(assetLink.getUserId());
3303                    assetLinkImpl.setUserName(assetLink.getUserName());
3304                    assetLinkImpl.setCreateDate(assetLink.getCreateDate());
3305                    assetLinkImpl.setEntryId1(assetLink.getEntryId1());
3306                    assetLinkImpl.setEntryId2(assetLink.getEntryId2());
3307                    assetLinkImpl.setType(assetLink.getType());
3308                    assetLinkImpl.setWeight(assetLink.getWeight());
3309    
3310                    return assetLinkImpl;
3311            }
3312    
3313            /**
3314             * Returns the asset link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
3315             *
3316             * @param primaryKey the primary key of the asset link
3317             * @return the asset link
3318             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
3319             * @throws SystemException if a system exception occurred
3320             */
3321            @Override
3322            public AssetLink findByPrimaryKey(Serializable primaryKey)
3323                    throws NoSuchLinkException, SystemException {
3324                    AssetLink assetLink = fetchByPrimaryKey(primaryKey);
3325    
3326                    if (assetLink == null) {
3327                            if (_log.isWarnEnabled()) {
3328                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
3329                            }
3330    
3331                            throw new NoSuchLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
3332                                    primaryKey);
3333                    }
3334    
3335                    return assetLink;
3336            }
3337    
3338            /**
3339             * Returns the asset link with the primary key or throws a {@link com.liferay.portlet.asset.NoSuchLinkException} if it could not be found.
3340             *
3341             * @param linkId the primary key of the asset link
3342             * @return the asset link
3343             * @throws com.liferay.portlet.asset.NoSuchLinkException if a asset link with the primary key could not be found
3344             * @throws SystemException if a system exception occurred
3345             */
3346            @Override
3347            public AssetLink findByPrimaryKey(long linkId)
3348                    throws NoSuchLinkException, SystemException {
3349                    return findByPrimaryKey((Serializable)linkId);
3350            }
3351    
3352            /**
3353             * Returns the asset link with the primary key or returns <code>null</code> if it could not be found.
3354             *
3355             * @param primaryKey the primary key of the asset link
3356             * @return the asset link, or <code>null</code> if a asset link with the primary key could not be found
3357             * @throws SystemException if a system exception occurred
3358             */
3359            @Override
3360            public AssetLink fetchByPrimaryKey(Serializable primaryKey)
3361                    throws SystemException {
3362                    AssetLink assetLink = (AssetLink)EntityCacheUtil.getResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
3363                                    AssetLinkImpl.class, primaryKey);
3364    
3365                    if (assetLink == _nullAssetLink) {
3366                            return null;
3367                    }
3368    
3369                    if (assetLink == null) {
3370                            Session session = null;
3371    
3372                            try {
3373                                    session = openSession();
3374    
3375                                    assetLink = (AssetLink)session.get(AssetLinkImpl.class,
3376                                                    primaryKey);
3377    
3378                                    if (assetLink != null) {
3379                                            cacheResult(assetLink);
3380                                    }
3381                                    else {
3382                                            EntityCacheUtil.putResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
3383                                                    AssetLinkImpl.class, primaryKey, _nullAssetLink);
3384                                    }
3385                            }
3386                            catch (Exception e) {
3387                                    EntityCacheUtil.removeResult(AssetLinkModelImpl.ENTITY_CACHE_ENABLED,
3388                                            AssetLinkImpl.class, primaryKey);
3389    
3390                                    throw processException(e);
3391                            }
3392                            finally {
3393                                    closeSession(session);
3394                            }
3395                    }
3396    
3397                    return assetLink;
3398            }
3399    
3400            /**
3401             * Returns the asset link with the primary key or returns <code>null</code> if it could not be found.
3402             *
3403             * @param linkId the primary key of the asset link
3404             * @return the asset link, or <code>null</code> if a asset link with the primary key could not be found
3405             * @throws SystemException if a system exception occurred
3406             */
3407            @Override
3408            public AssetLink fetchByPrimaryKey(long linkId) throws SystemException {
3409                    return fetchByPrimaryKey((Serializable)linkId);
3410            }
3411    
3412            /**
3413             * Returns all the asset links.
3414             *
3415             * @return the asset links
3416             * @throws SystemException if a system exception occurred
3417             */
3418            @Override
3419            public List<AssetLink> findAll() throws SystemException {
3420                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
3421            }
3422    
3423            /**
3424             * Returns a range of all the asset links.
3425             *
3426             * <p>
3427             * 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.
3428             * </p>
3429             *
3430             * @param start the lower bound of the range of asset links
3431             * @param end the upper bound of the range of asset links (not inclusive)
3432             * @return the range of asset links
3433             * @throws SystemException if a system exception occurred
3434             */
3435            @Override
3436            public List<AssetLink> findAll(int start, int end)
3437                    throws SystemException {
3438                    return findAll(start, end, null);
3439            }
3440    
3441            /**
3442             * Returns an ordered range of all the asset links.
3443             *
3444             * <p>
3445             * 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.
3446             * </p>
3447             *
3448             * @param start the lower bound of the range of asset links
3449             * @param end the upper bound of the range of asset links (not inclusive)
3450             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
3451             * @return the ordered range of asset links
3452             * @throws SystemException if a system exception occurred
3453             */
3454            @Override
3455            public List<AssetLink> findAll(int start, int end,
3456                    OrderByComparator orderByComparator) throws SystemException {
3457                    boolean pagination = true;
3458                    FinderPath finderPath = null;
3459                    Object[] finderArgs = null;
3460    
3461                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
3462                                    (orderByComparator == null)) {
3463                            pagination = false;
3464                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
3465                            finderArgs = FINDER_ARGS_EMPTY;
3466                    }
3467                    else {
3468                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
3469                            finderArgs = new Object[] { start, end, orderByComparator };
3470                    }
3471    
3472                    List<AssetLink> list = (List<AssetLink>)FinderCacheUtil.getResult(finderPath,
3473                                    finderArgs, this);
3474    
3475                    if (list == null) {
3476                            StringBundler query = null;
3477                            String sql = null;
3478    
3479                            if (orderByComparator != null) {
3480                                    query = new StringBundler(2 +
3481                                                    (orderByComparator.getOrderByFields().length * 3));
3482    
3483                                    query.append(_SQL_SELECT_ASSETLINK);
3484    
3485                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
3486                                            orderByComparator);
3487    
3488                                    sql = query.toString();
3489                            }
3490                            else {
3491                                    sql = _SQL_SELECT_ASSETLINK;
3492    
3493                                    if (pagination) {
3494                                            sql = sql.concat(AssetLinkModelImpl.ORDER_BY_JPQL);
3495                                    }
3496                            }
3497    
3498                            Session session = null;
3499    
3500                            try {
3501                                    session = openSession();
3502    
3503                                    Query q = session.createQuery(sql);
3504    
3505                                    if (!pagination) {
3506                                            list = (List<AssetLink>)QueryUtil.list(q, getDialect(),
3507                                                            start, end, false);
3508    
3509                                            Collections.sort(list);
3510    
3511                                            list = new UnmodifiableList<AssetLink>(list);
3512                                    }
3513                                    else {
3514                                            list = (List<AssetLink>)QueryUtil.list(q, getDialect(),
3515                                                            start, end);
3516                                    }
3517    
3518                                    cacheResult(list);
3519    
3520                                    FinderCacheUtil.putResult(finderPath, finderArgs, list);
3521                            }
3522                            catch (Exception e) {
3523                                    FinderCacheUtil.removeResult(finderPath, finderArgs);
3524    
3525                                    throw processException(e);
3526                            }
3527                            finally {
3528                                    closeSession(session);
3529                            }
3530                    }
3531    
3532                    return list;
3533            }
3534    
3535            /**
3536             * Removes all the asset links from the database.
3537             *
3538             * @throws SystemException if a system exception occurred
3539             */
3540            @Override
3541            public void removeAll() throws SystemException {
3542                    for (AssetLink assetLink : findAll()) {
3543                            remove(assetLink);
3544                    }
3545            }
3546    
3547            /**
3548             * Returns the number of asset links.
3549             *
3550             * @return the number of asset links
3551             * @throws SystemException if a system exception occurred
3552             */
3553            @Override
3554            public int countAll() throws SystemException {
3555                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
3556                                    FINDER_ARGS_EMPTY, this);
3557    
3558                    if (count == null) {
3559                            Session session = null;
3560    
3561                            try {
3562                                    session = openSession();
3563    
3564                                    Query q = session.createQuery(_SQL_COUNT_ASSETLINK);
3565    
3566                                    count = (Long)q.uniqueResult();
3567    
3568                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
3569                                            FINDER_ARGS_EMPTY, count);
3570                            }
3571                            catch (Exception e) {
3572                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_ALL,
3573                                            FINDER_ARGS_EMPTY);
3574    
3575                                    throw processException(e);
3576                            }
3577                            finally {
3578                                    closeSession(session);
3579                            }
3580                    }
3581    
3582                    return count.intValue();
3583            }
3584    
3585            @Override
3586            protected Set<String> getBadColumnNames() {
3587                    return _badColumnNames;
3588            }
3589    
3590            /**
3591             * Initializes the asset link persistence.
3592             */
3593            public void afterPropertiesSet() {
3594                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
3595                                            com.liferay.portal.util.PropsUtil.get(
3596                                                    "value.object.listener.com.liferay.portlet.asset.model.AssetLink")));
3597    
3598                    if (listenerClassNames.length > 0) {
3599                            try {
3600                                    List<ModelListener<AssetLink>> listenersList = new ArrayList<ModelListener<AssetLink>>();
3601    
3602                                    for (String listenerClassName : listenerClassNames) {
3603                                            listenersList.add((ModelListener<AssetLink>)InstanceFactory.newInstance(
3604                                                            getClassLoader(), listenerClassName));
3605                                    }
3606    
3607                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
3608                            }
3609                            catch (Exception e) {
3610                                    _log.error(e);
3611                            }
3612                    }
3613            }
3614    
3615            public void destroy() {
3616                    EntityCacheUtil.removeCache(AssetLinkImpl.class.getName());
3617                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
3618                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
3619                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
3620            }
3621    
3622            private static final String _SQL_SELECT_ASSETLINK = "SELECT assetLink FROM AssetLink assetLink";
3623            private static final String _SQL_SELECT_ASSETLINK_WHERE = "SELECT assetLink FROM AssetLink assetLink WHERE ";
3624            private static final String _SQL_COUNT_ASSETLINK = "SELECT COUNT(assetLink) FROM AssetLink assetLink";
3625            private static final String _SQL_COUNT_ASSETLINK_WHERE = "SELECT COUNT(assetLink) FROM AssetLink assetLink WHERE ";
3626            private static final String _ORDER_BY_ENTITY_ALIAS = "assetLink.";
3627            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No AssetLink exists with the primary key ";
3628            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No AssetLink exists with the key {";
3629            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
3630            private static Log _log = LogFactoryUtil.getLog(AssetLinkPersistenceImpl.class);
3631            private static Set<String> _badColumnNames = SetUtil.fromArray(new String[] {
3632                                    "type"
3633                            });
3634            private static AssetLink _nullAssetLink = new AssetLinkImpl() {
3635                            @Override
3636                            public Object clone() {
3637                                    return this;
3638                            }
3639    
3640                            @Override
3641                            public CacheModel<AssetLink> toCacheModel() {
3642                                    return _nullAssetLinkCacheModel;
3643                            }
3644                    };
3645    
3646            private static CacheModel<AssetLink> _nullAssetLinkCacheModel = new CacheModel<AssetLink>() {
3647                            @Override
3648                            public AssetLink toEntityModel() {
3649                                    return _nullAssetLink;
3650                            }
3651                    };
3652    }