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.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchWorkflowDefinitionLinkException;
019    import com.liferay.portal.kernel.bean.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.kernel.util.Validator;
038    import com.liferay.portal.model.CacheModel;
039    import com.liferay.portal.model.ModelListener;
040    import com.liferay.portal.model.WorkflowDefinitionLink;
041    import com.liferay.portal.model.impl.WorkflowDefinitionLinkImpl;
042    import com.liferay.portal.model.impl.WorkflowDefinitionLinkModelImpl;
043    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
044    
045    import java.io.Serializable;
046    
047    import java.util.ArrayList;
048    import java.util.Collections;
049    import java.util.List;
050    
051    /**
052     * The persistence implementation for the workflow definition link service.
053     *
054     * <p>
055     * Caching information and settings can be found in <code>portal.properties</code>
056     * </p>
057     *
058     * @author Brian Wing Shun Chan
059     * @see WorkflowDefinitionLinkPersistence
060     * @see WorkflowDefinitionLinkUtil
061     * @generated
062     */
063    public class WorkflowDefinitionLinkPersistenceImpl extends BasePersistenceImpl<WorkflowDefinitionLink>
064            implements WorkflowDefinitionLinkPersistence {
065            /*
066             * NOTE FOR DEVELOPERS:
067             *
068             * Never modify or reference this class directly. Always use {@link WorkflowDefinitionLinkUtil} to access the workflow definition link persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
069             */
070            public static final String FINDER_CLASS_NAME_ENTITY = WorkflowDefinitionLinkImpl.class.getName();
071            public static final String FINDER_CLASS_NAME_LIST_WITH_PAGINATION = FINDER_CLASS_NAME_ENTITY +
072                    ".List1";
073            public static final String FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION = FINDER_CLASS_NAME_ENTITY +
074                    ".List2";
075            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID =
076                    new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
077                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
078                            WorkflowDefinitionLinkImpl.class,
079                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByCompanyId",
080                            new String[] {
081                                    Long.class.getName(),
082                                    
083                            "java.lang.Integer", "java.lang.Integer",
084                                    "com.liferay.portal.kernel.util.OrderByComparator"
085                            });
086            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID =
087                    new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
088                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
089                            WorkflowDefinitionLinkImpl.class,
090                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByCompanyId",
091                            new String[] { Long.class.getName() },
092                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK);
093            public static final FinderPath FINDER_PATH_COUNT_BY_COMPANYID = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
094                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
095                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByCompanyId",
096                            new String[] { Long.class.getName() });
097            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
098                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
099                            WorkflowDefinitionLinkImpl.class,
100                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findByC_W_W",
101                            new String[] {
102                                    Long.class.getName(), String.class.getName(),
103                                    Integer.class.getName(),
104                                    
105                            "java.lang.Integer", "java.lang.Integer",
106                                    "com.liferay.portal.kernel.util.OrderByComparator"
107                            });
108            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
109                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
110                            WorkflowDefinitionLinkImpl.class,
111                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findByC_W_W",
112                            new String[] {
113                                    Long.class.getName(), String.class.getName(),
114                                    Integer.class.getName()
115                            },
116                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK |
117                            WorkflowDefinitionLinkModelImpl.WORKFLOWDEFINITIONNAME_COLUMN_BITMASK |
118                            WorkflowDefinitionLinkModelImpl.WORKFLOWDEFINITIONVERSION_COLUMN_BITMASK);
119            public static final FinderPath FINDER_PATH_COUNT_BY_C_W_W = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
120                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
121                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByC_W_W",
122                            new String[] {
123                                    Long.class.getName(), String.class.getName(),
124                                    Integer.class.getName()
125                            });
126            public static final FinderPath FINDER_PATH_FETCH_BY_G_C_C_C_T = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
127                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
128                            WorkflowDefinitionLinkImpl.class, FINDER_CLASS_NAME_ENTITY,
129                            "fetchByG_C_C_C_T",
130                            new String[] {
131                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
132                                    Long.class.getName(), Long.class.getName()
133                            },
134                            WorkflowDefinitionLinkModelImpl.GROUPID_COLUMN_BITMASK |
135                            WorkflowDefinitionLinkModelImpl.COMPANYID_COLUMN_BITMASK |
136                            WorkflowDefinitionLinkModelImpl.CLASSNAMEID_COLUMN_BITMASK |
137                            WorkflowDefinitionLinkModelImpl.CLASSPK_COLUMN_BITMASK |
138                            WorkflowDefinitionLinkModelImpl.TYPEPK_COLUMN_BITMASK);
139            public static final FinderPath FINDER_PATH_COUNT_BY_G_C_C_C_T = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
140                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
141                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countByG_C_C_C_T",
142                            new String[] {
143                                    Long.class.getName(), Long.class.getName(), Long.class.getName(),
144                                    Long.class.getName(), Long.class.getName()
145                            });
146            public static final FinderPath FINDER_PATH_WITH_PAGINATION_FIND_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
147                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
148                            WorkflowDefinitionLinkImpl.class,
149                            FINDER_CLASS_NAME_LIST_WITH_PAGINATION, "findAll", new String[0]);
150            public static final FinderPath FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
151                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED,
152                            WorkflowDefinitionLinkImpl.class,
153                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "findAll", new String[0]);
154            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
155                            WorkflowDefinitionLinkModelImpl.FINDER_CACHE_ENABLED, Long.class,
156                            FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION, "countAll", new String[0]);
157    
158            /**
159             * Caches the workflow definition link in the entity cache if it is enabled.
160             *
161             * @param workflowDefinitionLink the workflow definition link
162             */
163            public void cacheResult(WorkflowDefinitionLink workflowDefinitionLink) {
164                    EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
165                            WorkflowDefinitionLinkImpl.class,
166                            workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
167    
168                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
169                            new Object[] {
170                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
171                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
172                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
173                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
174                                    Long.valueOf(workflowDefinitionLink.getTypePK())
175                            }, workflowDefinitionLink);
176    
177                    workflowDefinitionLink.resetOriginalValues();
178            }
179    
180            /**
181             * Caches the workflow definition links in the entity cache if it is enabled.
182             *
183             * @param workflowDefinitionLinks the workflow definition links
184             */
185            public void cacheResult(
186                    List<WorkflowDefinitionLink> workflowDefinitionLinks) {
187                    for (WorkflowDefinitionLink workflowDefinitionLink : workflowDefinitionLinks) {
188                            if (EntityCacheUtil.getResult(
189                                                    WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
190                                                    WorkflowDefinitionLinkImpl.class,
191                                                    workflowDefinitionLink.getPrimaryKey()) == null) {
192                                    cacheResult(workflowDefinitionLink);
193                            }
194                            else {
195                                    workflowDefinitionLink.resetOriginalValues();
196                            }
197                    }
198            }
199    
200            /**
201             * Clears the cache for all workflow definition links.
202             *
203             * <p>
204             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
205             * </p>
206             */
207            @Override
208            public void clearCache() {
209                    if (_HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE) {
210                            CacheRegistryUtil.clear(WorkflowDefinitionLinkImpl.class.getName());
211                    }
212    
213                    EntityCacheUtil.clearCache(WorkflowDefinitionLinkImpl.class.getName());
214    
215                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
216                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
217                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
218            }
219    
220            /**
221             * Clears the cache for the workflow definition link.
222             *
223             * <p>
224             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
225             * </p>
226             */
227            @Override
228            public void clearCache(WorkflowDefinitionLink workflowDefinitionLink) {
229                    EntityCacheUtil.removeResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
230                            WorkflowDefinitionLinkImpl.class,
231                            workflowDefinitionLink.getPrimaryKey());
232    
233                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
234                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
235    
236                    clearUniqueFindersCache(workflowDefinitionLink);
237            }
238    
239            @Override
240            public void clearCache(List<WorkflowDefinitionLink> workflowDefinitionLinks) {
241                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
242                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
243    
244                    for (WorkflowDefinitionLink workflowDefinitionLink : workflowDefinitionLinks) {
245                            EntityCacheUtil.removeResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
246                                    WorkflowDefinitionLinkImpl.class,
247                                    workflowDefinitionLink.getPrimaryKey());
248    
249                            clearUniqueFindersCache(workflowDefinitionLink);
250                    }
251            }
252    
253            protected void cacheUniqueFindersCache(
254                    WorkflowDefinitionLink workflowDefinitionLink) {
255                    if (workflowDefinitionLink.isNew()) {
256                            Object[] args = new Object[] {
257                                            Long.valueOf(workflowDefinitionLink.getGroupId()),
258                                            Long.valueOf(workflowDefinitionLink.getCompanyId()),
259                                            Long.valueOf(workflowDefinitionLink.getClassNameId()),
260                                            Long.valueOf(workflowDefinitionLink.getClassPK()),
261                                            Long.valueOf(workflowDefinitionLink.getTypePK())
262                                    };
263    
264                            FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C_T, args,
265                                    Long.valueOf(1));
266                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T, args,
267                                    workflowDefinitionLink);
268                    }
269                    else {
270                            WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
271    
272                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
273                                            FINDER_PATH_FETCH_BY_G_C_C_C_T.getColumnBitmask()) != 0) {
274                                    Object[] args = new Object[] {
275                                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
276                                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
277                                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
278                                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
279                                                    Long.valueOf(workflowDefinitionLink.getTypePK())
280                                            };
281    
282                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C_T, args,
283                                            Long.valueOf(1));
284                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T, args,
285                                            workflowDefinitionLink);
286                            }
287                    }
288            }
289    
290            protected void clearUniqueFindersCache(
291                    WorkflowDefinitionLink workflowDefinitionLink) {
292                    WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
293    
294                    Object[] args = new Object[] {
295                                    Long.valueOf(workflowDefinitionLink.getGroupId()),
296                                    Long.valueOf(workflowDefinitionLink.getCompanyId()),
297                                    Long.valueOf(workflowDefinitionLink.getClassNameId()),
298                                    Long.valueOf(workflowDefinitionLink.getClassPK()),
299                                    Long.valueOf(workflowDefinitionLink.getTypePK())
300                            };
301    
302                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C_T, args);
303                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T, args);
304    
305                    if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
306                                    FINDER_PATH_FETCH_BY_G_C_C_C_T.getColumnBitmask()) != 0) {
307                            args = new Object[] {
308                                            Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalGroupId()),
309                                            Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
310                                            Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalClassNameId()),
311                                            Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalClassPK()),
312                                            Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalTypePK())
313                                    };
314    
315                            FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_G_C_C_C_T, args);
316                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T, args);
317                    }
318            }
319    
320            /**
321             * Creates a new workflow definition link with the primary key. Does not add the workflow definition link to the database.
322             *
323             * @param workflowDefinitionLinkId the primary key for the new workflow definition link
324             * @return the new workflow definition link
325             */
326            public WorkflowDefinitionLink create(long workflowDefinitionLinkId) {
327                    WorkflowDefinitionLink workflowDefinitionLink = new WorkflowDefinitionLinkImpl();
328    
329                    workflowDefinitionLink.setNew(true);
330                    workflowDefinitionLink.setPrimaryKey(workflowDefinitionLinkId);
331    
332                    return workflowDefinitionLink;
333            }
334    
335            /**
336             * Removes the workflow definition link with the primary key from the database. Also notifies the appropriate model listeners.
337             *
338             * @param workflowDefinitionLinkId the primary key of the workflow definition link
339             * @return the workflow definition link that was removed
340             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
341             * @throws SystemException if a system exception occurred
342             */
343            public WorkflowDefinitionLink remove(long workflowDefinitionLinkId)
344                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
345                    return remove(Long.valueOf(workflowDefinitionLinkId));
346            }
347    
348            /**
349             * Removes the workflow definition link with the primary key from the database. Also notifies the appropriate model listeners.
350             *
351             * @param primaryKey the primary key of the workflow definition link
352             * @return the workflow definition link that was removed
353             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
354             * @throws SystemException if a system exception occurred
355             */
356            @Override
357            public WorkflowDefinitionLink remove(Serializable primaryKey)
358                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
359                    Session session = null;
360    
361                    try {
362                            session = openSession();
363    
364                            WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
365                                            primaryKey);
366    
367                            if (workflowDefinitionLink == null) {
368                                    if (_log.isWarnEnabled()) {
369                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + primaryKey);
370                                    }
371    
372                                    throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
373                                            primaryKey);
374                            }
375    
376                            return remove(workflowDefinitionLink);
377                    }
378                    catch (NoSuchWorkflowDefinitionLinkException nsee) {
379                            throw nsee;
380                    }
381                    catch (Exception e) {
382                            throw processException(e);
383                    }
384                    finally {
385                            closeSession(session);
386                    }
387            }
388    
389            @Override
390            protected WorkflowDefinitionLink removeImpl(
391                    WorkflowDefinitionLink workflowDefinitionLink)
392                    throws SystemException {
393                    workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
394    
395                    Session session = null;
396    
397                    try {
398                            session = openSession();
399    
400                            BatchSessionUtil.delete(session, workflowDefinitionLink);
401                    }
402                    catch (Exception e) {
403                            throw processException(e);
404                    }
405                    finally {
406                            closeSession(session);
407                    }
408    
409                    clearCache(workflowDefinitionLink);
410    
411                    return workflowDefinitionLink;
412            }
413    
414            @Override
415            public WorkflowDefinitionLink updateImpl(
416                    com.liferay.portal.model.WorkflowDefinitionLink workflowDefinitionLink,
417                    boolean merge) throws SystemException {
418                    workflowDefinitionLink = toUnwrappedModel(workflowDefinitionLink);
419    
420                    boolean isNew = workflowDefinitionLink.isNew();
421    
422                    WorkflowDefinitionLinkModelImpl workflowDefinitionLinkModelImpl = (WorkflowDefinitionLinkModelImpl)workflowDefinitionLink;
423    
424                    Session session = null;
425    
426                    try {
427                            session = openSession();
428    
429                            BatchSessionUtil.update(session, workflowDefinitionLink, merge);
430    
431                            workflowDefinitionLink.setNew(false);
432                    }
433                    catch (Exception e) {
434                            throw processException(e);
435                    }
436                    finally {
437                            closeSession(session);
438                    }
439    
440                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITH_PAGINATION);
441    
442                    if (isNew || !WorkflowDefinitionLinkModelImpl.COLUMN_BITMASK_ENABLED) {
443                            FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
444                    }
445    
446                    else {
447                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
448                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID.getColumnBitmask()) != 0) {
449                                    Object[] args = new Object[] {
450                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId())
451                                            };
452    
453                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
454                                            args);
455                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
456                                            args);
457    
458                                    args = new Object[] {
459                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getCompanyId())
460                                            };
461    
462                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_COMPANYID,
463                                            args);
464                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID,
465                                            args);
466                            }
467    
468                            if ((workflowDefinitionLinkModelImpl.getColumnBitmask() &
469                                            FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W.getColumnBitmask()) != 0) {
470                                    Object[] args = new Object[] {
471                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getOriginalCompanyId()),
472                                                    
473                                                    workflowDefinitionLinkModelImpl.getOriginalWorkflowDefinitionName(),
474                                                    Integer.valueOf(workflowDefinitionLinkModelImpl.getOriginalWorkflowDefinitionVersion())
475                                            };
476    
477                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_W_W, args);
478                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W,
479                                            args);
480    
481                                    args = new Object[] {
482                                                    Long.valueOf(workflowDefinitionLinkModelImpl.getCompanyId()),
483                                                    
484                                                    workflowDefinitionLinkModelImpl.getWorkflowDefinitionName(),
485                                                    Integer.valueOf(workflowDefinitionLinkModelImpl.getWorkflowDefinitionVersion())
486                                            };
487    
488                                    FinderCacheUtil.removeResult(FINDER_PATH_COUNT_BY_C_W_W, args);
489                                    FinderCacheUtil.removeResult(FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W,
490                                            args);
491                            }
492                    }
493    
494                    EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
495                            WorkflowDefinitionLinkImpl.class,
496                            workflowDefinitionLink.getPrimaryKey(), workflowDefinitionLink);
497    
498                    clearUniqueFindersCache(workflowDefinitionLink);
499                    cacheUniqueFindersCache(workflowDefinitionLink);
500    
501                    return workflowDefinitionLink;
502            }
503    
504            protected WorkflowDefinitionLink toUnwrappedModel(
505                    WorkflowDefinitionLink workflowDefinitionLink) {
506                    if (workflowDefinitionLink instanceof WorkflowDefinitionLinkImpl) {
507                            return workflowDefinitionLink;
508                    }
509    
510                    WorkflowDefinitionLinkImpl workflowDefinitionLinkImpl = new WorkflowDefinitionLinkImpl();
511    
512                    workflowDefinitionLinkImpl.setNew(workflowDefinitionLink.isNew());
513                    workflowDefinitionLinkImpl.setPrimaryKey(workflowDefinitionLink.getPrimaryKey());
514    
515                    workflowDefinitionLinkImpl.setWorkflowDefinitionLinkId(workflowDefinitionLink.getWorkflowDefinitionLinkId());
516                    workflowDefinitionLinkImpl.setGroupId(workflowDefinitionLink.getGroupId());
517                    workflowDefinitionLinkImpl.setCompanyId(workflowDefinitionLink.getCompanyId());
518                    workflowDefinitionLinkImpl.setUserId(workflowDefinitionLink.getUserId());
519                    workflowDefinitionLinkImpl.setUserName(workflowDefinitionLink.getUserName());
520                    workflowDefinitionLinkImpl.setCreateDate(workflowDefinitionLink.getCreateDate());
521                    workflowDefinitionLinkImpl.setModifiedDate(workflowDefinitionLink.getModifiedDate());
522                    workflowDefinitionLinkImpl.setClassNameId(workflowDefinitionLink.getClassNameId());
523                    workflowDefinitionLinkImpl.setClassPK(workflowDefinitionLink.getClassPK());
524                    workflowDefinitionLinkImpl.setTypePK(workflowDefinitionLink.getTypePK());
525                    workflowDefinitionLinkImpl.setWorkflowDefinitionName(workflowDefinitionLink.getWorkflowDefinitionName());
526                    workflowDefinitionLinkImpl.setWorkflowDefinitionVersion(workflowDefinitionLink.getWorkflowDefinitionVersion());
527    
528                    return workflowDefinitionLinkImpl;
529            }
530    
531            /**
532             * Returns the workflow definition link with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
533             *
534             * @param primaryKey the primary key of the workflow definition link
535             * @return the workflow definition link
536             * @throws com.liferay.portal.NoSuchModelException if a workflow definition link with the primary key could not be found
537             * @throws SystemException if a system exception occurred
538             */
539            @Override
540            public WorkflowDefinitionLink findByPrimaryKey(Serializable primaryKey)
541                    throws NoSuchModelException, SystemException {
542                    return findByPrimaryKey(((Long)primaryKey).longValue());
543            }
544    
545            /**
546             * Returns the workflow definition link with the primary key or throws a {@link com.liferay.portal.NoSuchWorkflowDefinitionLinkException} if it could not be found.
547             *
548             * @param workflowDefinitionLinkId the primary key of the workflow definition link
549             * @return the workflow definition link
550             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
551             * @throws SystemException if a system exception occurred
552             */
553            public WorkflowDefinitionLink findByPrimaryKey(
554                    long workflowDefinitionLinkId)
555                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
556                    WorkflowDefinitionLink workflowDefinitionLink = fetchByPrimaryKey(workflowDefinitionLinkId);
557    
558                    if (workflowDefinitionLink == null) {
559                            if (_log.isWarnEnabled()) {
560                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
561                                            workflowDefinitionLinkId);
562                            }
563    
564                            throw new NoSuchWorkflowDefinitionLinkException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
565                                    workflowDefinitionLinkId);
566                    }
567    
568                    return workflowDefinitionLink;
569            }
570    
571            /**
572             * Returns the workflow definition link with the primary key or returns <code>null</code> if it could not be found.
573             *
574             * @param primaryKey the primary key of the workflow definition link
575             * @return the workflow definition link, or <code>null</code> if a workflow definition link with the primary key could not be found
576             * @throws SystemException if a system exception occurred
577             */
578            @Override
579            public WorkflowDefinitionLink fetchByPrimaryKey(Serializable primaryKey)
580                    throws SystemException {
581                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
582            }
583    
584            /**
585             * Returns the workflow definition link with the primary key or returns <code>null</code> if it could not be found.
586             *
587             * @param workflowDefinitionLinkId the primary key of the workflow definition link
588             * @return the workflow definition link, or <code>null</code> if a workflow definition link with the primary key could not be found
589             * @throws SystemException if a system exception occurred
590             */
591            public WorkflowDefinitionLink fetchByPrimaryKey(
592                    long workflowDefinitionLinkId) throws SystemException {
593                    WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)EntityCacheUtil.getResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
594                                    WorkflowDefinitionLinkImpl.class, workflowDefinitionLinkId);
595    
596                    if (workflowDefinitionLink == _nullWorkflowDefinitionLink) {
597                            return null;
598                    }
599    
600                    if (workflowDefinitionLink == null) {
601                            Session session = null;
602    
603                            boolean hasException = false;
604    
605                            try {
606                                    session = openSession();
607    
608                                    workflowDefinitionLink = (WorkflowDefinitionLink)session.get(WorkflowDefinitionLinkImpl.class,
609                                                    Long.valueOf(workflowDefinitionLinkId));
610                            }
611                            catch (Exception e) {
612                                    hasException = true;
613    
614                                    throw processException(e);
615                            }
616                            finally {
617                                    if (workflowDefinitionLink != null) {
618                                            cacheResult(workflowDefinitionLink);
619                                    }
620                                    else if (!hasException) {
621                                            EntityCacheUtil.putResult(WorkflowDefinitionLinkModelImpl.ENTITY_CACHE_ENABLED,
622                                                    WorkflowDefinitionLinkImpl.class,
623                                                    workflowDefinitionLinkId, _nullWorkflowDefinitionLink);
624                                    }
625    
626                                    closeSession(session);
627                            }
628                    }
629    
630                    return workflowDefinitionLink;
631            }
632    
633            /**
634             * Returns all the workflow definition links where companyId = &#63;.
635             *
636             * @param companyId the company ID
637             * @return the matching workflow definition links
638             * @throws SystemException if a system exception occurred
639             */
640            public List<WorkflowDefinitionLink> findByCompanyId(long companyId)
641                    throws SystemException {
642                    return findByCompanyId(companyId, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
643                            null);
644            }
645    
646            /**
647             * Returns a range of all the workflow definition links where companyId = &#63;.
648             *
649             * <p>
650             * 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.
651             * </p>
652             *
653             * @param companyId the company ID
654             * @param start the lower bound of the range of workflow definition links
655             * @param end the upper bound of the range of workflow definition links (not inclusive)
656             * @return the range of matching workflow definition links
657             * @throws SystemException if a system exception occurred
658             */
659            public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
660                    int start, int end) throws SystemException {
661                    return findByCompanyId(companyId, start, end, null);
662            }
663    
664            /**
665             * Returns an ordered range of all the workflow definition links where companyId = &#63;.
666             *
667             * <p>
668             * 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.
669             * </p>
670             *
671             * @param companyId the company ID
672             * @param start the lower bound of the range of workflow definition links
673             * @param end the upper bound of the range of workflow definition links (not inclusive)
674             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
675             * @return the ordered range of matching workflow definition links
676             * @throws SystemException if a system exception occurred
677             */
678            public List<WorkflowDefinitionLink> findByCompanyId(long companyId,
679                    int start, int end, OrderByComparator orderByComparator)
680                    throws SystemException {
681                    FinderPath finderPath = null;
682                    Object[] finderArgs = null;
683    
684                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
685                                    (orderByComparator == null)) {
686                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_COMPANYID;
687                            finderArgs = new Object[] { companyId };
688                    }
689                    else {
690                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_COMPANYID;
691                            finderArgs = new Object[] { companyId, start, end, orderByComparator };
692                    }
693    
694                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
695                                    finderArgs, this);
696    
697                    if ((list != null) && !list.isEmpty()) {
698                            for (WorkflowDefinitionLink workflowDefinitionLink : list) {
699                                    if ((companyId != workflowDefinitionLink.getCompanyId())) {
700                                            list = null;
701    
702                                            break;
703                                    }
704                            }
705                    }
706    
707                    if (list == null) {
708                            StringBundler query = null;
709    
710                            if (orderByComparator != null) {
711                                    query = new StringBundler(3 +
712                                                    (orderByComparator.getOrderByFields().length * 3));
713                            }
714                            else {
715                                    query = new StringBundler(3);
716                            }
717    
718                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
719    
720                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
721    
722                            if (orderByComparator != null) {
723                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
724                                            orderByComparator);
725                            }
726    
727                            else {
728                                    query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
729                            }
730    
731                            String sql = query.toString();
732    
733                            Session session = null;
734    
735                            try {
736                                    session = openSession();
737    
738                                    Query q = session.createQuery(sql);
739    
740                                    QueryPos qPos = QueryPos.getInstance(q);
741    
742                                    qPos.add(companyId);
743    
744                                    list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
745                                                    getDialect(), start, end);
746                            }
747                            catch (Exception e) {
748                                    throw processException(e);
749                            }
750                            finally {
751                                    if (list == null) {
752                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
753                                    }
754                                    else {
755                                            cacheResult(list);
756    
757                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
758                                    }
759    
760                                    closeSession(session);
761                            }
762                    }
763    
764                    return list;
765            }
766    
767            /**
768             * Returns the first workflow definition link in the ordered set where companyId = &#63;.
769             *
770             * @param companyId the company ID
771             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
772             * @return the first matching workflow definition link
773             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
774             * @throws SystemException if a system exception occurred
775             */
776            public WorkflowDefinitionLink findByCompanyId_First(long companyId,
777                    OrderByComparator orderByComparator)
778                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
779                    WorkflowDefinitionLink workflowDefinitionLink = fetchByCompanyId_First(companyId,
780                                    orderByComparator);
781    
782                    if (workflowDefinitionLink != null) {
783                            return workflowDefinitionLink;
784                    }
785    
786                    StringBundler msg = new StringBundler(4);
787    
788                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
789    
790                    msg.append("companyId=");
791                    msg.append(companyId);
792    
793                    msg.append(StringPool.CLOSE_CURLY_BRACE);
794    
795                    throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
796            }
797    
798            /**
799             * Returns the first workflow definition link in the ordered set where companyId = &#63;.
800             *
801             * @param companyId the company ID
802             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
803             * @return the first matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
804             * @throws SystemException if a system exception occurred
805             */
806            public WorkflowDefinitionLink fetchByCompanyId_First(long companyId,
807                    OrderByComparator orderByComparator) throws SystemException {
808                    List<WorkflowDefinitionLink> list = findByCompanyId(companyId, 0, 1,
809                                    orderByComparator);
810    
811                    if (!list.isEmpty()) {
812                            return list.get(0);
813                    }
814    
815                    return null;
816            }
817    
818            /**
819             * Returns the last workflow definition link in the ordered set where companyId = &#63;.
820             *
821             * @param companyId the company ID
822             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
823             * @return the last matching workflow definition link
824             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
825             * @throws SystemException if a system exception occurred
826             */
827            public WorkflowDefinitionLink findByCompanyId_Last(long companyId,
828                    OrderByComparator orderByComparator)
829                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
830                    WorkflowDefinitionLink workflowDefinitionLink = fetchByCompanyId_Last(companyId,
831                                    orderByComparator);
832    
833                    if (workflowDefinitionLink != null) {
834                            return workflowDefinitionLink;
835                    }
836    
837                    StringBundler msg = new StringBundler(4);
838    
839                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
840    
841                    msg.append("companyId=");
842                    msg.append(companyId);
843    
844                    msg.append(StringPool.CLOSE_CURLY_BRACE);
845    
846                    throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
847            }
848    
849            /**
850             * Returns the last workflow definition link in the ordered set where companyId = &#63;.
851             *
852             * @param companyId the company ID
853             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
854             * @return the last matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
855             * @throws SystemException if a system exception occurred
856             */
857            public WorkflowDefinitionLink fetchByCompanyId_Last(long companyId,
858                    OrderByComparator orderByComparator) throws SystemException {
859                    int count = countByCompanyId(companyId);
860    
861                    List<WorkflowDefinitionLink> list = findByCompanyId(companyId,
862                                    count - 1, count, orderByComparator);
863    
864                    if (!list.isEmpty()) {
865                            return list.get(0);
866                    }
867    
868                    return null;
869            }
870    
871            /**
872             * Returns the workflow definition links before and after the current workflow definition link in the ordered set where companyId = &#63;.
873             *
874             * @param workflowDefinitionLinkId the primary key of the current workflow definition link
875             * @param companyId the company ID
876             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
877             * @return the previous, current, and next workflow definition link
878             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
879             * @throws SystemException if a system exception occurred
880             */
881            public WorkflowDefinitionLink[] findByCompanyId_PrevAndNext(
882                    long workflowDefinitionLinkId, long companyId,
883                    OrderByComparator orderByComparator)
884                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
885                    WorkflowDefinitionLink workflowDefinitionLink = findByPrimaryKey(workflowDefinitionLinkId);
886    
887                    Session session = null;
888    
889                    try {
890                            session = openSession();
891    
892                            WorkflowDefinitionLink[] array = new WorkflowDefinitionLinkImpl[3];
893    
894                            array[0] = getByCompanyId_PrevAndNext(session,
895                                            workflowDefinitionLink, companyId, orderByComparator, true);
896    
897                            array[1] = workflowDefinitionLink;
898    
899                            array[2] = getByCompanyId_PrevAndNext(session,
900                                            workflowDefinitionLink, companyId, orderByComparator, false);
901    
902                            return array;
903                    }
904                    catch (Exception e) {
905                            throw processException(e);
906                    }
907                    finally {
908                            closeSession(session);
909                    }
910            }
911    
912            protected WorkflowDefinitionLink getByCompanyId_PrevAndNext(
913                    Session session, WorkflowDefinitionLink workflowDefinitionLink,
914                    long companyId, OrderByComparator orderByComparator, boolean previous) {
915                    StringBundler query = null;
916    
917                    if (orderByComparator != null) {
918                            query = new StringBundler(6 +
919                                            (orderByComparator.getOrderByFields().length * 6));
920                    }
921                    else {
922                            query = new StringBundler(3);
923                    }
924    
925                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
926    
927                    query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
928    
929                    if (orderByComparator != null) {
930                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
931    
932                            if (orderByConditionFields.length > 0) {
933                                    query.append(WHERE_AND);
934                            }
935    
936                            for (int i = 0; i < orderByConditionFields.length; i++) {
937                                    query.append(_ORDER_BY_ENTITY_ALIAS);
938                                    query.append(orderByConditionFields[i]);
939    
940                                    if ((i + 1) < orderByConditionFields.length) {
941                                            if (orderByComparator.isAscending() ^ previous) {
942                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
943                                            }
944                                            else {
945                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
946                                            }
947                                    }
948                                    else {
949                                            if (orderByComparator.isAscending() ^ previous) {
950                                                    query.append(WHERE_GREATER_THAN);
951                                            }
952                                            else {
953                                                    query.append(WHERE_LESSER_THAN);
954                                            }
955                                    }
956                            }
957    
958                            query.append(ORDER_BY_CLAUSE);
959    
960                            String[] orderByFields = orderByComparator.getOrderByFields();
961    
962                            for (int i = 0; i < orderByFields.length; i++) {
963                                    query.append(_ORDER_BY_ENTITY_ALIAS);
964                                    query.append(orderByFields[i]);
965    
966                                    if ((i + 1) < orderByFields.length) {
967                                            if (orderByComparator.isAscending() ^ previous) {
968                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
969                                            }
970                                            else {
971                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
972                                            }
973                                    }
974                                    else {
975                                            if (orderByComparator.isAscending() ^ previous) {
976                                                    query.append(ORDER_BY_ASC);
977                                            }
978                                            else {
979                                                    query.append(ORDER_BY_DESC);
980                                            }
981                                    }
982                            }
983                    }
984    
985                    else {
986                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
987                    }
988    
989                    String sql = query.toString();
990    
991                    Query q = session.createQuery(sql);
992    
993                    q.setFirstResult(0);
994                    q.setMaxResults(2);
995    
996                    QueryPos qPos = QueryPos.getInstance(q);
997    
998                    qPos.add(companyId);
999    
1000                    if (orderByComparator != null) {
1001                            Object[] values = orderByComparator.getOrderByConditionValues(workflowDefinitionLink);
1002    
1003                            for (Object value : values) {
1004                                    qPos.add(value);
1005                            }
1006                    }
1007    
1008                    List<WorkflowDefinitionLink> list = q.list();
1009    
1010                    if (list.size() == 2) {
1011                            return list.get(1);
1012                    }
1013                    else {
1014                            return null;
1015                    }
1016            }
1017    
1018            /**
1019             * Returns all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1020             *
1021             * @param companyId the company ID
1022             * @param workflowDefinitionName the workflow definition name
1023             * @param workflowDefinitionVersion the workflow definition version
1024             * @return the matching workflow definition links
1025             * @throws SystemException if a system exception occurred
1026             */
1027            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
1028                    String workflowDefinitionName, int workflowDefinitionVersion)
1029                    throws SystemException {
1030                    return findByC_W_W(companyId, workflowDefinitionName,
1031                            workflowDefinitionVersion, QueryUtil.ALL_POS, QueryUtil.ALL_POS,
1032                            null);
1033            }
1034    
1035            /**
1036             * Returns a range of all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1037             *
1038             * <p>
1039             * 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.
1040             * </p>
1041             *
1042             * @param companyId the company ID
1043             * @param workflowDefinitionName the workflow definition name
1044             * @param workflowDefinitionVersion the workflow definition version
1045             * @param start the lower bound of the range of workflow definition links
1046             * @param end the upper bound of the range of workflow definition links (not inclusive)
1047             * @return the range of matching workflow definition links
1048             * @throws SystemException if a system exception occurred
1049             */
1050            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
1051                    String workflowDefinitionName, int workflowDefinitionVersion,
1052                    int start, int end) throws SystemException {
1053                    return findByC_W_W(companyId, workflowDefinitionName,
1054                            workflowDefinitionVersion, start, end, null);
1055            }
1056    
1057            /**
1058             * Returns an ordered range of all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1059             *
1060             * <p>
1061             * 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.
1062             * </p>
1063             *
1064             * @param companyId the company ID
1065             * @param workflowDefinitionName the workflow definition name
1066             * @param workflowDefinitionVersion the workflow definition version
1067             * @param start the lower bound of the range of workflow definition links
1068             * @param end the upper bound of the range of workflow definition links (not inclusive)
1069             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1070             * @return the ordered range of matching workflow definition links
1071             * @throws SystemException if a system exception occurred
1072             */
1073            public List<WorkflowDefinitionLink> findByC_W_W(long companyId,
1074                    String workflowDefinitionName, int workflowDefinitionVersion,
1075                    int start, int end, OrderByComparator orderByComparator)
1076                    throws SystemException {
1077                    FinderPath finderPath = null;
1078                    Object[] finderArgs = null;
1079    
1080                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1081                                    (orderByComparator == null)) {
1082                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_BY_C_W_W;
1083                            finderArgs = new Object[] {
1084                                            companyId, workflowDefinitionName, workflowDefinitionVersion
1085                                    };
1086                    }
1087                    else {
1088                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_BY_C_W_W;
1089                            finderArgs = new Object[] {
1090                                            companyId, workflowDefinitionName, workflowDefinitionVersion,
1091                                            
1092                                            start, end, orderByComparator
1093                                    };
1094                    }
1095    
1096                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
1097                                    finderArgs, this);
1098    
1099                    if ((list != null) && !list.isEmpty()) {
1100                            for (WorkflowDefinitionLink workflowDefinitionLink : list) {
1101                                    if ((companyId != workflowDefinitionLink.getCompanyId()) ||
1102                                                    !Validator.equals(workflowDefinitionName,
1103                                                            workflowDefinitionLink.getWorkflowDefinitionName()) ||
1104                                                    (workflowDefinitionVersion != workflowDefinitionLink.getWorkflowDefinitionVersion())) {
1105                                            list = null;
1106    
1107                                            break;
1108                                    }
1109                            }
1110                    }
1111    
1112                    if (list == null) {
1113                            StringBundler query = null;
1114    
1115                            if (orderByComparator != null) {
1116                                    query = new StringBundler(5 +
1117                                                    (orderByComparator.getOrderByFields().length * 3));
1118                            }
1119                            else {
1120                                    query = new StringBundler(5);
1121                            }
1122    
1123                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1124    
1125                            query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1126    
1127                            if (workflowDefinitionName == null) {
1128                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1129                            }
1130                            else {
1131                                    if (workflowDefinitionName.equals(StringPool.BLANK)) {
1132                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1133                                    }
1134                                    else {
1135                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1136                                    }
1137                            }
1138    
1139                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1140    
1141                            if (orderByComparator != null) {
1142                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1143                                            orderByComparator);
1144                            }
1145    
1146                            else {
1147                                    query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1148                            }
1149    
1150                            String sql = query.toString();
1151    
1152                            Session session = null;
1153    
1154                            try {
1155                                    session = openSession();
1156    
1157                                    Query q = session.createQuery(sql);
1158    
1159                                    QueryPos qPos = QueryPos.getInstance(q);
1160    
1161                                    qPos.add(companyId);
1162    
1163                                    if (workflowDefinitionName != null) {
1164                                            qPos.add(workflowDefinitionName);
1165                                    }
1166    
1167                                    qPos.add(workflowDefinitionVersion);
1168    
1169                                    list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1170                                                    getDialect(), start, end);
1171                            }
1172                            catch (Exception e) {
1173                                    throw processException(e);
1174                            }
1175                            finally {
1176                                    if (list == null) {
1177                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1178                                    }
1179                                    else {
1180                                            cacheResult(list);
1181    
1182                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1183                                    }
1184    
1185                                    closeSession(session);
1186                            }
1187                    }
1188    
1189                    return list;
1190            }
1191    
1192            /**
1193             * Returns the first workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1194             *
1195             * @param companyId the company ID
1196             * @param workflowDefinitionName the workflow definition name
1197             * @param workflowDefinitionVersion the workflow definition version
1198             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1199             * @return the first matching workflow definition link
1200             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1201             * @throws SystemException if a system exception occurred
1202             */
1203            public WorkflowDefinitionLink findByC_W_W_First(long companyId,
1204                    String workflowDefinitionName, int workflowDefinitionVersion,
1205                    OrderByComparator orderByComparator)
1206                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1207                    WorkflowDefinitionLink workflowDefinitionLink = fetchByC_W_W_First(companyId,
1208                                    workflowDefinitionName, workflowDefinitionVersion,
1209                                    orderByComparator);
1210    
1211                    if (workflowDefinitionLink != null) {
1212                            return workflowDefinitionLink;
1213                    }
1214    
1215                    StringBundler msg = new StringBundler(8);
1216    
1217                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1218    
1219                    msg.append("companyId=");
1220                    msg.append(companyId);
1221    
1222                    msg.append(", workflowDefinitionName=");
1223                    msg.append(workflowDefinitionName);
1224    
1225                    msg.append(", workflowDefinitionVersion=");
1226                    msg.append(workflowDefinitionVersion);
1227    
1228                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1229    
1230                    throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1231            }
1232    
1233            /**
1234             * Returns the first workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1235             *
1236             * @param companyId the company ID
1237             * @param workflowDefinitionName the workflow definition name
1238             * @param workflowDefinitionVersion the workflow definition version
1239             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1240             * @return the first matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1241             * @throws SystemException if a system exception occurred
1242             */
1243            public WorkflowDefinitionLink fetchByC_W_W_First(long companyId,
1244                    String workflowDefinitionName, int workflowDefinitionVersion,
1245                    OrderByComparator orderByComparator) throws SystemException {
1246                    List<WorkflowDefinitionLink> list = findByC_W_W(companyId,
1247                                    workflowDefinitionName, workflowDefinitionVersion, 0, 1,
1248                                    orderByComparator);
1249    
1250                    if (!list.isEmpty()) {
1251                            return list.get(0);
1252                    }
1253    
1254                    return null;
1255            }
1256    
1257            /**
1258             * Returns the last workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1259             *
1260             * @param companyId the company ID
1261             * @param workflowDefinitionName the workflow definition name
1262             * @param workflowDefinitionVersion the workflow definition version
1263             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1264             * @return the last matching workflow definition link
1265             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1266             * @throws SystemException if a system exception occurred
1267             */
1268            public WorkflowDefinitionLink findByC_W_W_Last(long companyId,
1269                    String workflowDefinitionName, int workflowDefinitionVersion,
1270                    OrderByComparator orderByComparator)
1271                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1272                    WorkflowDefinitionLink workflowDefinitionLink = fetchByC_W_W_Last(companyId,
1273                                    workflowDefinitionName, workflowDefinitionVersion,
1274                                    orderByComparator);
1275    
1276                    if (workflowDefinitionLink != null) {
1277                            return workflowDefinitionLink;
1278                    }
1279    
1280                    StringBundler msg = new StringBundler(8);
1281    
1282                    msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1283    
1284                    msg.append("companyId=");
1285                    msg.append(companyId);
1286    
1287                    msg.append(", workflowDefinitionName=");
1288                    msg.append(workflowDefinitionName);
1289    
1290                    msg.append(", workflowDefinitionVersion=");
1291                    msg.append(workflowDefinitionVersion);
1292    
1293                    msg.append(StringPool.CLOSE_CURLY_BRACE);
1294    
1295                    throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1296            }
1297    
1298            /**
1299             * Returns the last workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1300             *
1301             * @param companyId the company ID
1302             * @param workflowDefinitionName the workflow definition name
1303             * @param workflowDefinitionVersion the workflow definition version
1304             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1305             * @return the last matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1306             * @throws SystemException if a system exception occurred
1307             */
1308            public WorkflowDefinitionLink fetchByC_W_W_Last(long companyId,
1309                    String workflowDefinitionName, int workflowDefinitionVersion,
1310                    OrderByComparator orderByComparator) throws SystemException {
1311                    int count = countByC_W_W(companyId, workflowDefinitionName,
1312                                    workflowDefinitionVersion);
1313    
1314                    List<WorkflowDefinitionLink> list = findByC_W_W(companyId,
1315                                    workflowDefinitionName, workflowDefinitionVersion, count - 1,
1316                                    count, orderByComparator);
1317    
1318                    if (!list.isEmpty()) {
1319                            return list.get(0);
1320                    }
1321    
1322                    return null;
1323            }
1324    
1325            /**
1326             * Returns the workflow definition links before and after the current workflow definition link in the ordered set where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1327             *
1328             * @param workflowDefinitionLinkId the primary key of the current workflow definition link
1329             * @param companyId the company ID
1330             * @param workflowDefinitionName the workflow definition name
1331             * @param workflowDefinitionVersion the workflow definition version
1332             * @param orderByComparator the comparator to order the set by (optionally <code>null</code>)
1333             * @return the previous, current, and next workflow definition link
1334             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a workflow definition link with the primary key could not be found
1335             * @throws SystemException if a system exception occurred
1336             */
1337            public WorkflowDefinitionLink[] findByC_W_W_PrevAndNext(
1338                    long workflowDefinitionLinkId, long companyId,
1339                    String workflowDefinitionName, int workflowDefinitionVersion,
1340                    OrderByComparator orderByComparator)
1341                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1342                    WorkflowDefinitionLink workflowDefinitionLink = findByPrimaryKey(workflowDefinitionLinkId);
1343    
1344                    Session session = null;
1345    
1346                    try {
1347                            session = openSession();
1348    
1349                            WorkflowDefinitionLink[] array = new WorkflowDefinitionLinkImpl[3];
1350    
1351                            array[0] = getByC_W_W_PrevAndNext(session, workflowDefinitionLink,
1352                                            companyId, workflowDefinitionName,
1353                                            workflowDefinitionVersion, orderByComparator, true);
1354    
1355                            array[1] = workflowDefinitionLink;
1356    
1357                            array[2] = getByC_W_W_PrevAndNext(session, workflowDefinitionLink,
1358                                            companyId, workflowDefinitionName,
1359                                            workflowDefinitionVersion, orderByComparator, false);
1360    
1361                            return array;
1362                    }
1363                    catch (Exception e) {
1364                            throw processException(e);
1365                    }
1366                    finally {
1367                            closeSession(session);
1368                    }
1369            }
1370    
1371            protected WorkflowDefinitionLink getByC_W_W_PrevAndNext(Session session,
1372                    WorkflowDefinitionLink workflowDefinitionLink, long companyId,
1373                    String workflowDefinitionName, int workflowDefinitionVersion,
1374                    OrderByComparator orderByComparator, boolean previous) {
1375                    StringBundler query = null;
1376    
1377                    if (orderByComparator != null) {
1378                            query = new StringBundler(6 +
1379                                            (orderByComparator.getOrderByFields().length * 6));
1380                    }
1381                    else {
1382                            query = new StringBundler(3);
1383                    }
1384    
1385                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1386    
1387                    query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1388    
1389                    if (workflowDefinitionName == null) {
1390                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1391                    }
1392                    else {
1393                            if (workflowDefinitionName.equals(StringPool.BLANK)) {
1394                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1395                            }
1396                            else {
1397                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1398                            }
1399                    }
1400    
1401                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1402    
1403                    if (orderByComparator != null) {
1404                            String[] orderByConditionFields = orderByComparator.getOrderByConditionFields();
1405    
1406                            if (orderByConditionFields.length > 0) {
1407                                    query.append(WHERE_AND);
1408                            }
1409    
1410                            for (int i = 0; i < orderByConditionFields.length; i++) {
1411                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1412                                    query.append(orderByConditionFields[i]);
1413    
1414                                    if ((i + 1) < orderByConditionFields.length) {
1415                                            if (orderByComparator.isAscending() ^ previous) {
1416                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
1417                                            }
1418                                            else {
1419                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
1420                                            }
1421                                    }
1422                                    else {
1423                                            if (orderByComparator.isAscending() ^ previous) {
1424                                                    query.append(WHERE_GREATER_THAN);
1425                                            }
1426                                            else {
1427                                                    query.append(WHERE_LESSER_THAN);
1428                                            }
1429                                    }
1430                            }
1431    
1432                            query.append(ORDER_BY_CLAUSE);
1433    
1434                            String[] orderByFields = orderByComparator.getOrderByFields();
1435    
1436                            for (int i = 0; i < orderByFields.length; i++) {
1437                                    query.append(_ORDER_BY_ENTITY_ALIAS);
1438                                    query.append(orderByFields[i]);
1439    
1440                                    if ((i + 1) < orderByFields.length) {
1441                                            if (orderByComparator.isAscending() ^ previous) {
1442                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
1443                                            }
1444                                            else {
1445                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
1446                                            }
1447                                    }
1448                                    else {
1449                                            if (orderByComparator.isAscending() ^ previous) {
1450                                                    query.append(ORDER_BY_ASC);
1451                                            }
1452                                            else {
1453                                                    query.append(ORDER_BY_DESC);
1454                                            }
1455                                    }
1456                            }
1457                    }
1458    
1459                    else {
1460                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1461                    }
1462    
1463                    String sql = query.toString();
1464    
1465                    Query q = session.createQuery(sql);
1466    
1467                    q.setFirstResult(0);
1468                    q.setMaxResults(2);
1469    
1470                    QueryPos qPos = QueryPos.getInstance(q);
1471    
1472                    qPos.add(companyId);
1473    
1474                    if (workflowDefinitionName != null) {
1475                            qPos.add(workflowDefinitionName);
1476                    }
1477    
1478                    qPos.add(workflowDefinitionVersion);
1479    
1480                    if (orderByComparator != null) {
1481                            Object[] values = orderByComparator.getOrderByConditionValues(workflowDefinitionLink);
1482    
1483                            for (Object value : values) {
1484                                    qPos.add(value);
1485                            }
1486                    }
1487    
1488                    List<WorkflowDefinitionLink> list = q.list();
1489    
1490                    if (list.size() == 2) {
1491                            return list.get(1);
1492                    }
1493                    else {
1494                            return null;
1495                    }
1496            }
1497    
1498            /**
1499             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or throws a {@link com.liferay.portal.NoSuchWorkflowDefinitionLinkException} if it could not be found.
1500             *
1501             * @param groupId the group ID
1502             * @param companyId the company ID
1503             * @param classNameId the class name ID
1504             * @param classPK the class p k
1505             * @param typePK the type p k
1506             * @return the matching workflow definition link
1507             * @throws com.liferay.portal.NoSuchWorkflowDefinitionLinkException if a matching workflow definition link could not be found
1508             * @throws SystemException if a system exception occurred
1509             */
1510            public WorkflowDefinitionLink findByG_C_C_C_T(long groupId, long companyId,
1511                    long classNameId, long classPK, long typePK)
1512                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1513                    WorkflowDefinitionLink workflowDefinitionLink = fetchByG_C_C_C_T(groupId,
1514                                    companyId, classNameId, classPK, typePK);
1515    
1516                    if (workflowDefinitionLink == null) {
1517                            StringBundler msg = new StringBundler(12);
1518    
1519                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
1520    
1521                            msg.append("groupId=");
1522                            msg.append(groupId);
1523    
1524                            msg.append(", companyId=");
1525                            msg.append(companyId);
1526    
1527                            msg.append(", classNameId=");
1528                            msg.append(classNameId);
1529    
1530                            msg.append(", classPK=");
1531                            msg.append(classPK);
1532    
1533                            msg.append(", typePK=");
1534                            msg.append(typePK);
1535    
1536                            msg.append(StringPool.CLOSE_CURLY_BRACE);
1537    
1538                            if (_log.isWarnEnabled()) {
1539                                    _log.warn(msg.toString());
1540                            }
1541    
1542                            throw new NoSuchWorkflowDefinitionLinkException(msg.toString());
1543                    }
1544    
1545                    return workflowDefinitionLink;
1546            }
1547    
1548            /**
1549             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
1550             *
1551             * @param groupId the group ID
1552             * @param companyId the company ID
1553             * @param classNameId the class name ID
1554             * @param classPK the class p k
1555             * @param typePK the type p k
1556             * @return the matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1557             * @throws SystemException if a system exception occurred
1558             */
1559            public WorkflowDefinitionLink fetchByG_C_C_C_T(long groupId,
1560                    long companyId, long classNameId, long classPK, long typePK)
1561                    throws SystemException {
1562                    return fetchByG_C_C_C_T(groupId, companyId, classNameId, classPK,
1563                            typePK, true);
1564            }
1565    
1566            /**
1567             * Returns the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
1568             *
1569             * @param groupId the group ID
1570             * @param companyId the company ID
1571             * @param classNameId the class name ID
1572             * @param classPK the class p k
1573             * @param typePK the type p k
1574             * @param retrieveFromCache whether to use the finder cache
1575             * @return the matching workflow definition link, or <code>null</code> if a matching workflow definition link could not be found
1576             * @throws SystemException if a system exception occurred
1577             */
1578            public WorkflowDefinitionLink fetchByG_C_C_C_T(long groupId,
1579                    long companyId, long classNameId, long classPK, long typePK,
1580                    boolean retrieveFromCache) throws SystemException {
1581                    Object[] finderArgs = new Object[] {
1582                                    groupId, companyId, classNameId, classPK, typePK
1583                            };
1584    
1585                    Object result = null;
1586    
1587                    if (retrieveFromCache) {
1588                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1589                                            finderArgs, this);
1590                    }
1591    
1592                    if (result instanceof WorkflowDefinitionLink) {
1593                            WorkflowDefinitionLink workflowDefinitionLink = (WorkflowDefinitionLink)result;
1594    
1595                            if ((groupId != workflowDefinitionLink.getGroupId()) ||
1596                                            (companyId != workflowDefinitionLink.getCompanyId()) ||
1597                                            (classNameId != workflowDefinitionLink.getClassNameId()) ||
1598                                            (classPK != workflowDefinitionLink.getClassPK()) ||
1599                                            (typePK != workflowDefinitionLink.getTypePK())) {
1600                                    result = null;
1601                            }
1602                    }
1603    
1604                    if (result == null) {
1605                            StringBundler query = new StringBundler(7);
1606    
1607                            query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE);
1608    
1609                            query.append(_FINDER_COLUMN_G_C_C_C_T_GROUPID_2);
1610    
1611                            query.append(_FINDER_COLUMN_G_C_C_C_T_COMPANYID_2);
1612    
1613                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2);
1614    
1615                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSPK_2);
1616    
1617                            query.append(_FINDER_COLUMN_G_C_C_C_T_TYPEPK_2);
1618    
1619                            query.append(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1620    
1621                            String sql = query.toString();
1622    
1623                            Session session = null;
1624    
1625                            try {
1626                                    session = openSession();
1627    
1628                                    Query q = session.createQuery(sql);
1629    
1630                                    QueryPos qPos = QueryPos.getInstance(q);
1631    
1632                                    qPos.add(groupId);
1633    
1634                                    qPos.add(companyId);
1635    
1636                                    qPos.add(classNameId);
1637    
1638                                    qPos.add(classPK);
1639    
1640                                    qPos.add(typePK);
1641    
1642                                    List<WorkflowDefinitionLink> list = q.list();
1643    
1644                                    result = list;
1645    
1646                                    WorkflowDefinitionLink workflowDefinitionLink = null;
1647    
1648                                    if (list.isEmpty()) {
1649                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1650                                                    finderArgs, list);
1651                                    }
1652                                    else {
1653                                            workflowDefinitionLink = list.get(0);
1654    
1655                                            cacheResult(workflowDefinitionLink);
1656    
1657                                            if ((workflowDefinitionLink.getGroupId() != groupId) ||
1658                                                            (workflowDefinitionLink.getCompanyId() != companyId) ||
1659                                                            (workflowDefinitionLink.getClassNameId() != classNameId) ||
1660                                                            (workflowDefinitionLink.getClassPK() != classPK) ||
1661                                                            (workflowDefinitionLink.getTypePK() != typePK)) {
1662                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1663                                                            finderArgs, workflowDefinitionLink);
1664                                            }
1665                                    }
1666    
1667                                    return workflowDefinitionLink;
1668                            }
1669                            catch (Exception e) {
1670                                    throw processException(e);
1671                            }
1672                            finally {
1673                                    if (result == null) {
1674                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_G_C_C_C_T,
1675                                                    finderArgs);
1676                                    }
1677    
1678                                    closeSession(session);
1679                            }
1680                    }
1681                    else {
1682                            if (result instanceof List<?>) {
1683                                    return null;
1684                            }
1685                            else {
1686                                    return (WorkflowDefinitionLink)result;
1687                            }
1688                    }
1689            }
1690    
1691            /**
1692             * Returns all the workflow definition links.
1693             *
1694             * @return the workflow definition links
1695             * @throws SystemException if a system exception occurred
1696             */
1697            public List<WorkflowDefinitionLink> findAll() throws SystemException {
1698                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1699            }
1700    
1701            /**
1702             * Returns a range of all the workflow definition links.
1703             *
1704             * <p>
1705             * 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.
1706             * </p>
1707             *
1708             * @param start the lower bound of the range of workflow definition links
1709             * @param end the upper bound of the range of workflow definition links (not inclusive)
1710             * @return the range of workflow definition links
1711             * @throws SystemException if a system exception occurred
1712             */
1713            public List<WorkflowDefinitionLink> findAll(int start, int end)
1714                    throws SystemException {
1715                    return findAll(start, end, null);
1716            }
1717    
1718            /**
1719             * Returns an ordered range of all the workflow definition links.
1720             *
1721             * <p>
1722             * 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.
1723             * </p>
1724             *
1725             * @param start the lower bound of the range of workflow definition links
1726             * @param end the upper bound of the range of workflow definition links (not inclusive)
1727             * @param orderByComparator the comparator to order the results by (optionally <code>null</code>)
1728             * @return the ordered range of workflow definition links
1729             * @throws SystemException if a system exception occurred
1730             */
1731            public List<WorkflowDefinitionLink> findAll(int start, int end,
1732                    OrderByComparator orderByComparator) throws SystemException {
1733                    FinderPath finderPath = null;
1734                    Object[] finderArgs = new Object[] { start, end, orderByComparator };
1735    
1736                    if ((start == QueryUtil.ALL_POS) && (end == QueryUtil.ALL_POS) &&
1737                                    (orderByComparator == null)) {
1738                            finderPath = FINDER_PATH_WITHOUT_PAGINATION_FIND_ALL;
1739                            finderArgs = FINDER_ARGS_EMPTY;
1740                    }
1741                    else {
1742                            finderPath = FINDER_PATH_WITH_PAGINATION_FIND_ALL;
1743                            finderArgs = new Object[] { start, end, orderByComparator };
1744                    }
1745    
1746                    List<WorkflowDefinitionLink> list = (List<WorkflowDefinitionLink>)FinderCacheUtil.getResult(finderPath,
1747                                    finderArgs, this);
1748    
1749                    if (list == null) {
1750                            StringBundler query = null;
1751                            String sql = null;
1752    
1753                            if (orderByComparator != null) {
1754                                    query = new StringBundler(2 +
1755                                                    (orderByComparator.getOrderByFields().length * 3));
1756    
1757                                    query.append(_SQL_SELECT_WORKFLOWDEFINITIONLINK);
1758    
1759                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
1760                                            orderByComparator);
1761    
1762                                    sql = query.toString();
1763                            }
1764                            else {
1765                                    sql = _SQL_SELECT_WORKFLOWDEFINITIONLINK.concat(WorkflowDefinitionLinkModelImpl.ORDER_BY_JPQL);
1766                            }
1767    
1768                            Session session = null;
1769    
1770                            try {
1771                                    session = openSession();
1772    
1773                                    Query q = session.createQuery(sql);
1774    
1775                                    if (orderByComparator == null) {
1776                                            list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1777                                                            getDialect(), start, end, false);
1778    
1779                                            Collections.sort(list);
1780                                    }
1781                                    else {
1782                                            list = (List<WorkflowDefinitionLink>)QueryUtil.list(q,
1783                                                            getDialect(), start, end);
1784                                    }
1785                            }
1786                            catch (Exception e) {
1787                                    throw processException(e);
1788                            }
1789                            finally {
1790                                    if (list == null) {
1791                                            FinderCacheUtil.removeResult(finderPath, finderArgs);
1792                                    }
1793                                    else {
1794                                            cacheResult(list);
1795    
1796                                            FinderCacheUtil.putResult(finderPath, finderArgs, list);
1797                                    }
1798    
1799                                    closeSession(session);
1800                            }
1801                    }
1802    
1803                    return list;
1804            }
1805    
1806            /**
1807             * Removes all the workflow definition links where companyId = &#63; from the database.
1808             *
1809             * @param companyId the company ID
1810             * @throws SystemException if a system exception occurred
1811             */
1812            public void removeByCompanyId(long companyId) throws SystemException {
1813                    for (WorkflowDefinitionLink workflowDefinitionLink : findByCompanyId(
1814                                    companyId)) {
1815                            remove(workflowDefinitionLink);
1816                    }
1817            }
1818    
1819            /**
1820             * Removes all the workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63; from the database.
1821             *
1822             * @param companyId the company ID
1823             * @param workflowDefinitionName the workflow definition name
1824             * @param workflowDefinitionVersion the workflow definition version
1825             * @throws SystemException if a system exception occurred
1826             */
1827            public void removeByC_W_W(long companyId, String workflowDefinitionName,
1828                    int workflowDefinitionVersion) throws SystemException {
1829                    for (WorkflowDefinitionLink workflowDefinitionLink : findByC_W_W(
1830                                    companyId, workflowDefinitionName, workflowDefinitionVersion)) {
1831                            remove(workflowDefinitionLink);
1832                    }
1833            }
1834    
1835            /**
1836             * Removes the workflow definition link where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63; from the database.
1837             *
1838             * @param groupId the group ID
1839             * @param companyId the company ID
1840             * @param classNameId the class name ID
1841             * @param classPK the class p k
1842             * @param typePK the type p k
1843             * @return the workflow definition link that was removed
1844             * @throws SystemException if a system exception occurred
1845             */
1846            public WorkflowDefinitionLink removeByG_C_C_C_T(long groupId,
1847                    long companyId, long classNameId, long classPK, long typePK)
1848                    throws NoSuchWorkflowDefinitionLinkException, SystemException {
1849                    WorkflowDefinitionLink workflowDefinitionLink = findByG_C_C_C_T(groupId,
1850                                    companyId, classNameId, classPK, typePK);
1851    
1852                    return remove(workflowDefinitionLink);
1853            }
1854    
1855            /**
1856             * Removes all the workflow definition links from the database.
1857             *
1858             * @throws SystemException if a system exception occurred
1859             */
1860            public void removeAll() throws SystemException {
1861                    for (WorkflowDefinitionLink workflowDefinitionLink : findAll()) {
1862                            remove(workflowDefinitionLink);
1863                    }
1864            }
1865    
1866            /**
1867             * Returns the number of workflow definition links where companyId = &#63;.
1868             *
1869             * @param companyId the company ID
1870             * @return the number of matching workflow definition links
1871             * @throws SystemException if a system exception occurred
1872             */
1873            public int countByCompanyId(long companyId) throws SystemException {
1874                    Object[] finderArgs = new Object[] { companyId };
1875    
1876                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_COMPANYID,
1877                                    finderArgs, this);
1878    
1879                    if (count == null) {
1880                            StringBundler query = new StringBundler(2);
1881    
1882                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
1883    
1884                            query.append(_FINDER_COLUMN_COMPANYID_COMPANYID_2);
1885    
1886                            String sql = query.toString();
1887    
1888                            Session session = null;
1889    
1890                            try {
1891                                    session = openSession();
1892    
1893                                    Query q = session.createQuery(sql);
1894    
1895                                    QueryPos qPos = QueryPos.getInstance(q);
1896    
1897                                    qPos.add(companyId);
1898    
1899                                    count = (Long)q.uniqueResult();
1900                            }
1901                            catch (Exception e) {
1902                                    throw processException(e);
1903                            }
1904                            finally {
1905                                    if (count == null) {
1906                                            count = Long.valueOf(0);
1907                                    }
1908    
1909                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_COMPANYID,
1910                                            finderArgs, count);
1911    
1912                                    closeSession(session);
1913                            }
1914                    }
1915    
1916                    return count.intValue();
1917            }
1918    
1919            /**
1920             * Returns the number of workflow definition links where companyId = &#63; and workflowDefinitionName = &#63; and workflowDefinitionVersion = &#63;.
1921             *
1922             * @param companyId the company ID
1923             * @param workflowDefinitionName the workflow definition name
1924             * @param workflowDefinitionVersion the workflow definition version
1925             * @return the number of matching workflow definition links
1926             * @throws SystemException if a system exception occurred
1927             */
1928            public int countByC_W_W(long companyId, String workflowDefinitionName,
1929                    int workflowDefinitionVersion) throws SystemException {
1930                    Object[] finderArgs = new Object[] {
1931                                    companyId, workflowDefinitionName, workflowDefinitionVersion
1932                            };
1933    
1934                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_C_W_W,
1935                                    finderArgs, this);
1936    
1937                    if (count == null) {
1938                            StringBundler query = new StringBundler(4);
1939    
1940                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
1941    
1942                            query.append(_FINDER_COLUMN_C_W_W_COMPANYID_2);
1943    
1944                            if (workflowDefinitionName == null) {
1945                                    query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1);
1946                            }
1947                            else {
1948                                    if (workflowDefinitionName.equals(StringPool.BLANK)) {
1949                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3);
1950                                    }
1951                                    else {
1952                                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2);
1953                                    }
1954                            }
1955    
1956                            query.append(_FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2);
1957    
1958                            String sql = query.toString();
1959    
1960                            Session session = null;
1961    
1962                            try {
1963                                    session = openSession();
1964    
1965                                    Query q = session.createQuery(sql);
1966    
1967                                    QueryPos qPos = QueryPos.getInstance(q);
1968    
1969                                    qPos.add(companyId);
1970    
1971                                    if (workflowDefinitionName != null) {
1972                                            qPos.add(workflowDefinitionName);
1973                                    }
1974    
1975                                    qPos.add(workflowDefinitionVersion);
1976    
1977                                    count = (Long)q.uniqueResult();
1978                            }
1979                            catch (Exception e) {
1980                                    throw processException(e);
1981                            }
1982                            finally {
1983                                    if (count == null) {
1984                                            count = Long.valueOf(0);
1985                                    }
1986    
1987                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_C_W_W,
1988                                            finderArgs, count);
1989    
1990                                    closeSession(session);
1991                            }
1992                    }
1993    
1994                    return count.intValue();
1995            }
1996    
1997            /**
1998             * Returns the number of workflow definition links where groupId = &#63; and companyId = &#63; and classNameId = &#63; and classPK = &#63; and typePK = &#63;.
1999             *
2000             * @param groupId the group ID
2001             * @param companyId the company ID
2002             * @param classNameId the class name ID
2003             * @param classPK the class p k
2004             * @param typePK the type p k
2005             * @return the number of matching workflow definition links
2006             * @throws SystemException if a system exception occurred
2007             */
2008            public int countByG_C_C_C_T(long groupId, long companyId, long classNameId,
2009                    long classPK, long typePK) throws SystemException {
2010                    Object[] finderArgs = new Object[] {
2011                                    groupId, companyId, classNameId, classPK, typePK
2012                            };
2013    
2014                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_G_C_C_C_T,
2015                                    finderArgs, this);
2016    
2017                    if (count == null) {
2018                            StringBundler query = new StringBundler(6);
2019    
2020                            query.append(_SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE);
2021    
2022                            query.append(_FINDER_COLUMN_G_C_C_C_T_GROUPID_2);
2023    
2024                            query.append(_FINDER_COLUMN_G_C_C_C_T_COMPANYID_2);
2025    
2026                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2);
2027    
2028                            query.append(_FINDER_COLUMN_G_C_C_C_T_CLASSPK_2);
2029    
2030                            query.append(_FINDER_COLUMN_G_C_C_C_T_TYPEPK_2);
2031    
2032                            String sql = query.toString();
2033    
2034                            Session session = null;
2035    
2036                            try {
2037                                    session = openSession();
2038    
2039                                    Query q = session.createQuery(sql);
2040    
2041                                    QueryPos qPos = QueryPos.getInstance(q);
2042    
2043                                    qPos.add(groupId);
2044    
2045                                    qPos.add(companyId);
2046    
2047                                    qPos.add(classNameId);
2048    
2049                                    qPos.add(classPK);
2050    
2051                                    qPos.add(typePK);
2052    
2053                                    count = (Long)q.uniqueResult();
2054                            }
2055                            catch (Exception e) {
2056                                    throw processException(e);
2057                            }
2058                            finally {
2059                                    if (count == null) {
2060                                            count = Long.valueOf(0);
2061                                    }
2062    
2063                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_G_C_C_C_T,
2064                                            finderArgs, count);
2065    
2066                                    closeSession(session);
2067                            }
2068                    }
2069    
2070                    return count.intValue();
2071            }
2072    
2073            /**
2074             * Returns the number of workflow definition links.
2075             *
2076             * @return the number of workflow definition links
2077             * @throws SystemException if a system exception occurred
2078             */
2079            public int countAll() throws SystemException {
2080                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
2081                                    FINDER_ARGS_EMPTY, this);
2082    
2083                    if (count == null) {
2084                            Session session = null;
2085    
2086                            try {
2087                                    session = openSession();
2088    
2089                                    Query q = session.createQuery(_SQL_COUNT_WORKFLOWDEFINITIONLINK);
2090    
2091                                    count = (Long)q.uniqueResult();
2092                            }
2093                            catch (Exception e) {
2094                                    throw processException(e);
2095                            }
2096                            finally {
2097                                    if (count == null) {
2098                                            count = Long.valueOf(0);
2099                                    }
2100    
2101                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL,
2102                                            FINDER_ARGS_EMPTY, count);
2103    
2104                                    closeSession(session);
2105                            }
2106                    }
2107    
2108                    return count.intValue();
2109            }
2110    
2111            /**
2112             * Initializes the workflow definition link persistence.
2113             */
2114            public void afterPropertiesSet() {
2115                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
2116                                            com.liferay.portal.util.PropsUtil.get(
2117                                                    "value.object.listener.com.liferay.portal.model.WorkflowDefinitionLink")));
2118    
2119                    if (listenerClassNames.length > 0) {
2120                            try {
2121                                    List<ModelListener<WorkflowDefinitionLink>> listenersList = new ArrayList<ModelListener<WorkflowDefinitionLink>>();
2122    
2123                                    for (String listenerClassName : listenerClassNames) {
2124                                            Class<?> clazz = getClass();
2125    
2126                                            listenersList.add((ModelListener<WorkflowDefinitionLink>)InstanceFactory.newInstance(
2127                                                            clazz.getClassLoader(), listenerClassName));
2128                                    }
2129    
2130                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
2131                            }
2132                            catch (Exception e) {
2133                                    _log.error(e);
2134                            }
2135                    }
2136            }
2137    
2138            public void destroy() {
2139                    EntityCacheUtil.removeCache(WorkflowDefinitionLinkImpl.class.getName());
2140                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
2141                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST_WITHOUT_PAGINATION);
2142            }
2143    
2144            @BeanReference(type = AccountPersistence.class)
2145            protected AccountPersistence accountPersistence;
2146            @BeanReference(type = AddressPersistence.class)
2147            protected AddressPersistence addressPersistence;
2148            @BeanReference(type = BrowserTrackerPersistence.class)
2149            protected BrowserTrackerPersistence browserTrackerPersistence;
2150            @BeanReference(type = ClassNamePersistence.class)
2151            protected ClassNamePersistence classNamePersistence;
2152            @BeanReference(type = ClusterGroupPersistence.class)
2153            protected ClusterGroupPersistence clusterGroupPersistence;
2154            @BeanReference(type = CompanyPersistence.class)
2155            protected CompanyPersistence companyPersistence;
2156            @BeanReference(type = ContactPersistence.class)
2157            protected ContactPersistence contactPersistence;
2158            @BeanReference(type = CountryPersistence.class)
2159            protected CountryPersistence countryPersistence;
2160            @BeanReference(type = EmailAddressPersistence.class)
2161            protected EmailAddressPersistence emailAddressPersistence;
2162            @BeanReference(type = GroupPersistence.class)
2163            protected GroupPersistence groupPersistence;
2164            @BeanReference(type = ImagePersistence.class)
2165            protected ImagePersistence imagePersistence;
2166            @BeanReference(type = LayoutPersistence.class)
2167            protected LayoutPersistence layoutPersistence;
2168            @BeanReference(type = LayoutBranchPersistence.class)
2169            protected LayoutBranchPersistence layoutBranchPersistence;
2170            @BeanReference(type = LayoutPrototypePersistence.class)
2171            protected LayoutPrototypePersistence layoutPrototypePersistence;
2172            @BeanReference(type = LayoutRevisionPersistence.class)
2173            protected LayoutRevisionPersistence layoutRevisionPersistence;
2174            @BeanReference(type = LayoutSetPersistence.class)
2175            protected LayoutSetPersistence layoutSetPersistence;
2176            @BeanReference(type = LayoutSetBranchPersistence.class)
2177            protected LayoutSetBranchPersistence layoutSetBranchPersistence;
2178            @BeanReference(type = LayoutSetPrototypePersistence.class)
2179            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
2180            @BeanReference(type = ListTypePersistence.class)
2181            protected ListTypePersistence listTypePersistence;
2182            @BeanReference(type = LockPersistence.class)
2183            protected LockPersistence lockPersistence;
2184            @BeanReference(type = MembershipRequestPersistence.class)
2185            protected MembershipRequestPersistence membershipRequestPersistence;
2186            @BeanReference(type = OrganizationPersistence.class)
2187            protected OrganizationPersistence organizationPersistence;
2188            @BeanReference(type = OrgGroupPermissionPersistence.class)
2189            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
2190            @BeanReference(type = OrgGroupRolePersistence.class)
2191            protected OrgGroupRolePersistence orgGroupRolePersistence;
2192            @BeanReference(type = OrgLaborPersistence.class)
2193            protected OrgLaborPersistence orgLaborPersistence;
2194            @BeanReference(type = PasswordPolicyPersistence.class)
2195            protected PasswordPolicyPersistence passwordPolicyPersistence;
2196            @BeanReference(type = PasswordPolicyRelPersistence.class)
2197            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
2198            @BeanReference(type = PasswordTrackerPersistence.class)
2199            protected PasswordTrackerPersistence passwordTrackerPersistence;
2200            @BeanReference(type = PermissionPersistence.class)
2201            protected PermissionPersistence permissionPersistence;
2202            @BeanReference(type = PhonePersistence.class)
2203            protected PhonePersistence phonePersistence;
2204            @BeanReference(type = PluginSettingPersistence.class)
2205            protected PluginSettingPersistence pluginSettingPersistence;
2206            @BeanReference(type = PortalPreferencesPersistence.class)
2207            protected PortalPreferencesPersistence portalPreferencesPersistence;
2208            @BeanReference(type = PortletPersistence.class)
2209            protected PortletPersistence portletPersistence;
2210            @BeanReference(type = PortletItemPersistence.class)
2211            protected PortletItemPersistence portletItemPersistence;
2212            @BeanReference(type = PortletPreferencesPersistence.class)
2213            protected PortletPreferencesPersistence portletPreferencesPersistence;
2214            @BeanReference(type = RegionPersistence.class)
2215            protected RegionPersistence regionPersistence;
2216            @BeanReference(type = ReleasePersistence.class)
2217            protected ReleasePersistence releasePersistence;
2218            @BeanReference(type = RepositoryPersistence.class)
2219            protected RepositoryPersistence repositoryPersistence;
2220            @BeanReference(type = RepositoryEntryPersistence.class)
2221            protected RepositoryEntryPersistence repositoryEntryPersistence;
2222            @BeanReference(type = ResourcePersistence.class)
2223            protected ResourcePersistence resourcePersistence;
2224            @BeanReference(type = ResourceActionPersistence.class)
2225            protected ResourceActionPersistence resourceActionPersistence;
2226            @BeanReference(type = ResourceBlockPersistence.class)
2227            protected ResourceBlockPersistence resourceBlockPersistence;
2228            @BeanReference(type = ResourceBlockPermissionPersistence.class)
2229            protected ResourceBlockPermissionPersistence resourceBlockPermissionPersistence;
2230            @BeanReference(type = ResourceCodePersistence.class)
2231            protected ResourceCodePersistence resourceCodePersistence;
2232            @BeanReference(type = ResourcePermissionPersistence.class)
2233            protected ResourcePermissionPersistence resourcePermissionPersistence;
2234            @BeanReference(type = ResourceTypePermissionPersistence.class)
2235            protected ResourceTypePermissionPersistence resourceTypePermissionPersistence;
2236            @BeanReference(type = RolePersistence.class)
2237            protected RolePersistence rolePersistence;
2238            @BeanReference(type = ServiceComponentPersistence.class)
2239            protected ServiceComponentPersistence serviceComponentPersistence;
2240            @BeanReference(type = ShardPersistence.class)
2241            protected ShardPersistence shardPersistence;
2242            @BeanReference(type = SubscriptionPersistence.class)
2243            protected SubscriptionPersistence subscriptionPersistence;
2244            @BeanReference(type = TeamPersistence.class)
2245            protected TeamPersistence teamPersistence;
2246            @BeanReference(type = TicketPersistence.class)
2247            protected TicketPersistence ticketPersistence;
2248            @BeanReference(type = UserPersistence.class)
2249            protected UserPersistence userPersistence;
2250            @BeanReference(type = UserGroupPersistence.class)
2251            protected UserGroupPersistence userGroupPersistence;
2252            @BeanReference(type = UserGroupGroupRolePersistence.class)
2253            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
2254            @BeanReference(type = UserGroupRolePersistence.class)
2255            protected UserGroupRolePersistence userGroupRolePersistence;
2256            @BeanReference(type = UserIdMapperPersistence.class)
2257            protected UserIdMapperPersistence userIdMapperPersistence;
2258            @BeanReference(type = UserNotificationEventPersistence.class)
2259            protected UserNotificationEventPersistence userNotificationEventPersistence;
2260            @BeanReference(type = UserTrackerPersistence.class)
2261            protected UserTrackerPersistence userTrackerPersistence;
2262            @BeanReference(type = UserTrackerPathPersistence.class)
2263            protected UserTrackerPathPersistence userTrackerPathPersistence;
2264            @BeanReference(type = VirtualHostPersistence.class)
2265            protected VirtualHostPersistence virtualHostPersistence;
2266            @BeanReference(type = WebDAVPropsPersistence.class)
2267            protected WebDAVPropsPersistence webDAVPropsPersistence;
2268            @BeanReference(type = WebsitePersistence.class)
2269            protected WebsitePersistence websitePersistence;
2270            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
2271            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
2272            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
2273            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
2274            private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink";
2275            private static final String _SQL_SELECT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT workflowDefinitionLink FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
2276            private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink";
2277            private static final String _SQL_COUNT_WORKFLOWDEFINITIONLINK_WHERE = "SELECT COUNT(workflowDefinitionLink) FROM WorkflowDefinitionLink workflowDefinitionLink WHERE ";
2278            private static final String _FINDER_COLUMN_COMPANYID_COMPANYID_2 = "workflowDefinitionLink.companyId = ?";
2279            private static final String _FINDER_COLUMN_C_W_W_COMPANYID_2 = "workflowDefinitionLink.companyId = ? AND ";
2280            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_1 = "workflowDefinitionLink.workflowDefinitionName IS NULL AND ";
2281            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_2 = "workflowDefinitionLink.workflowDefinitionName = ? AND ";
2282            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONNAME_3 = "(workflowDefinitionLink.workflowDefinitionName IS NULL OR workflowDefinitionLink.workflowDefinitionName = ?) AND ";
2283            private static final String _FINDER_COLUMN_C_W_W_WORKFLOWDEFINITIONVERSION_2 =
2284                    "workflowDefinitionLink.workflowDefinitionVersion = ?";
2285            private static final String _FINDER_COLUMN_G_C_C_C_T_GROUPID_2 = "workflowDefinitionLink.groupId = ? AND ";
2286            private static final String _FINDER_COLUMN_G_C_C_C_T_COMPANYID_2 = "workflowDefinitionLink.companyId = ? AND ";
2287            private static final String _FINDER_COLUMN_G_C_C_C_T_CLASSNAMEID_2 = "workflowDefinitionLink.classNameId = ? AND ";
2288            private static final String _FINDER_COLUMN_G_C_C_C_T_CLASSPK_2 = "workflowDefinitionLink.classPK = ? AND ";
2289            private static final String _FINDER_COLUMN_G_C_C_C_T_TYPEPK_2 = "workflowDefinitionLink.typePK = ?";
2290            private static final String _ORDER_BY_ENTITY_ALIAS = "workflowDefinitionLink.";
2291            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No WorkflowDefinitionLink exists with the primary key ";
2292            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No WorkflowDefinitionLink exists with the key {";
2293            private static final boolean _HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE = com.liferay.portal.util.PropsValues.HIBERNATE_CACHE_USE_SECOND_LEVEL_CACHE;
2294            private static Log _log = LogFactoryUtil.getLog(WorkflowDefinitionLinkPersistenceImpl.class);
2295            private static WorkflowDefinitionLink _nullWorkflowDefinitionLink = new WorkflowDefinitionLinkImpl() {
2296                            @Override
2297                            public Object clone() {
2298                                    return this;
2299                            }
2300    
2301                            @Override
2302                            public CacheModel<WorkflowDefinitionLink> toCacheModel() {
2303                                    return _nullWorkflowDefinitionLinkCacheModel;
2304                            }
2305                    };
2306    
2307            private static CacheModel<WorkflowDefinitionLink> _nullWorkflowDefinitionLinkCacheModel =
2308                    new CacheModel<WorkflowDefinitionLink>() {
2309                            public WorkflowDefinitionLink toEntityModel() {
2310                                    return _nullWorkflowDefinitionLink;
2311                            }
2312                    };
2313    }