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