001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
013     */
014    
015    package com.liferay.portlet.social.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.kernel.annotation.BeanReference;
019    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
020    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
021    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderPath;
023    import com.liferay.portal.kernel.dao.orm.Query;
024    import com.liferay.portal.kernel.dao.orm.QueryPos;
025    import com.liferay.portal.kernel.dao.orm.QueryUtil;
026    import com.liferay.portal.kernel.dao.orm.Session;
027    import com.liferay.portal.kernel.exception.SystemException;
028    import com.liferay.portal.kernel.log.Log;
029    import com.liferay.portal.kernel.log.LogFactoryUtil;
030    import com.liferay.portal.kernel.util.GetterUtil;
031    import com.liferay.portal.kernel.util.InstanceFactory;
032    import com.liferay.portal.kernel.util.OrderByComparator;
033    import com.liferay.portal.kernel.util.StringBundler;
034    import com.liferay.portal.kernel.util.StringPool;
035    import com.liferay.portal.kernel.util.StringUtil;
036    import com.liferay.portal.model.ModelListener;
037    import com.liferay.portal.service.persistence.BatchSessionUtil;
038    import com.liferay.portal.service.persistence.ResourcePersistence;
039    import com.liferay.portal.service.persistence.UserPersistence;
040    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
041    
042    import com.liferay.portlet.social.NoSuchEquityAssetEntryException;
043    import com.liferay.portlet.social.model.SocialEquityAssetEntry;
044    import com.liferay.portlet.social.model.impl.SocialEquityAssetEntryImpl;
045    import com.liferay.portlet.social.model.impl.SocialEquityAssetEntryModelImpl;
046    
047    import java.io.Serializable;
048    
049    import java.util.ArrayList;
050    import java.util.Collections;
051    import java.util.List;
052    
053    /**
054     * The persistence implementation for the social equity asset entry service.
055     *
056     * <p>
057     * Never modify or reference this class directly. Always use {@link SocialEquityAssetEntryUtil} to access the social equity asset entry persistence. Modify <code>service.xml</code> and rerun ServiceBuilder to regenerate this class.
058     * </p>
059     *
060     * <p>
061     * Caching information and settings can be found in <code>portal.properties</code>
062     * </p>
063     *
064     * @author Brian Wing Shun Chan
065     * @see SocialEquityAssetEntryPersistence
066     * @see SocialEquityAssetEntryUtil
067     * @generated
068     */
069    public class SocialEquityAssetEntryPersistenceImpl extends BasePersistenceImpl<SocialEquityAssetEntry>
070            implements SocialEquityAssetEntryPersistence {
071            public static final String FINDER_CLASS_NAME_ENTITY = SocialEquityAssetEntryImpl.class.getName();
072            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
073                    ".List";
074            public static final FinderPath FINDER_PATH_FETCH_BY_ASSETENTRYID = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
075                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
076                            FINDER_CLASS_NAME_ENTITY, "fetchByAssetEntryId",
077                            new String[] { Long.class.getName() });
078            public static final FinderPath FINDER_PATH_COUNT_BY_ASSETENTRYID = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
079                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
080                            FINDER_CLASS_NAME_LIST, "countByAssetEntryId",
081                            new String[] { Long.class.getName() });
082            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
083                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
084                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
085            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
086                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
087                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
088    
089            /**
090             * Caches the social equity asset entry in the entity cache if it is enabled.
091             *
092             * @param socialEquityAssetEntry the social equity asset entry to cache
093             */
094            public void cacheResult(SocialEquityAssetEntry socialEquityAssetEntry) {
095                    EntityCacheUtil.putResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
096                            SocialEquityAssetEntryImpl.class,
097                            socialEquityAssetEntry.getPrimaryKey(), socialEquityAssetEntry);
098    
099                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
100                            new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) },
101                            socialEquityAssetEntry);
102            }
103    
104            /**
105             * Caches the social equity asset entries in the entity cache if it is enabled.
106             *
107             * @param socialEquityAssetEntries the social equity asset entries to cache
108             */
109            public void cacheResult(
110                    List<SocialEquityAssetEntry> socialEquityAssetEntries) {
111                    for (SocialEquityAssetEntry socialEquityAssetEntry : socialEquityAssetEntries) {
112                            if (EntityCacheUtil.getResult(
113                                                    SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
114                                                    SocialEquityAssetEntryImpl.class,
115                                                    socialEquityAssetEntry.getPrimaryKey(), this) == null) {
116                                    cacheResult(socialEquityAssetEntry);
117                            }
118                    }
119            }
120    
121            /**
122             * Clears the cache for all social equity asset entries.
123             *
124             * <p>
125             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
126             * </p>
127             */
128            public void clearCache() {
129                    CacheRegistryUtil.clear(SocialEquityAssetEntryImpl.class.getName());
130                    EntityCacheUtil.clearCache(SocialEquityAssetEntryImpl.class.getName());
131                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
132                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
133            }
134    
135            /**
136             * Clears the cache for the social equity asset entry.
137             *
138             * <p>
139             * The {@link com.liferay.portal.kernel.dao.orm.EntityCache} and {@link com.liferay.portal.kernel.dao.orm.FinderCache} are both cleared by this method.
140             * </p>
141             */
142            public void clearCache(SocialEquityAssetEntry socialEquityAssetEntry) {
143                    EntityCacheUtil.removeResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
144                            SocialEquityAssetEntryImpl.class,
145                            socialEquityAssetEntry.getPrimaryKey());
146    
147                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
148                            new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) });
149            }
150    
151            /**
152             * Creates a new social equity asset entry with the primary key. Does not add the social equity asset entry to the database.
153             *
154             * @param equityAssetEntryId the primary key for the new social equity asset entry
155             * @return the new social equity asset entry
156             */
157            public SocialEquityAssetEntry create(long equityAssetEntryId) {
158                    SocialEquityAssetEntry socialEquityAssetEntry = new SocialEquityAssetEntryImpl();
159    
160                    socialEquityAssetEntry.setNew(true);
161                    socialEquityAssetEntry.setPrimaryKey(equityAssetEntryId);
162    
163                    return socialEquityAssetEntry;
164            }
165    
166            /**
167             * Removes the social equity asset entry with the primary key from the database. Also notifies the appropriate model listeners.
168             *
169             * @param primaryKey the primary key of the social equity asset entry to remove
170             * @return the social equity asset entry that was removed
171             * @throws com.liferay.portal.NoSuchModelException if a social equity asset entry with the primary key could not be found
172             * @throws SystemException if a system exception occurred
173             */
174            public SocialEquityAssetEntry remove(Serializable primaryKey)
175                    throws NoSuchModelException, SystemException {
176                    return remove(((Long)primaryKey).longValue());
177            }
178    
179            /**
180             * Removes the social equity asset entry with the primary key from the database. Also notifies the appropriate model listeners.
181             *
182             * @param equityAssetEntryId the primary key of the social equity asset entry to remove
183             * @return the social equity asset entry that was removed
184             * @throws com.liferay.portlet.social.NoSuchEquityAssetEntryException if a social equity asset entry with the primary key could not be found
185             * @throws SystemException if a system exception occurred
186             */
187            public SocialEquityAssetEntry remove(long equityAssetEntryId)
188                    throws NoSuchEquityAssetEntryException, SystemException {
189                    Session session = null;
190    
191                    try {
192                            session = openSession();
193    
194                            SocialEquityAssetEntry socialEquityAssetEntry = (SocialEquityAssetEntry)session.get(SocialEquityAssetEntryImpl.class,
195                                            new Long(equityAssetEntryId));
196    
197                            if (socialEquityAssetEntry == null) {
198                                    if (_log.isWarnEnabled()) {
199                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
200                                                    equityAssetEntryId);
201                                    }
202    
203                                    throw new NoSuchEquityAssetEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
204                                            equityAssetEntryId);
205                            }
206    
207                            return remove(socialEquityAssetEntry);
208                    }
209                    catch (NoSuchEquityAssetEntryException nsee) {
210                            throw nsee;
211                    }
212                    catch (Exception e) {
213                            throw processException(e);
214                    }
215                    finally {
216                            closeSession(session);
217                    }
218            }
219    
220            protected SocialEquityAssetEntry removeImpl(
221                    SocialEquityAssetEntry socialEquityAssetEntry)
222                    throws SystemException {
223                    socialEquityAssetEntry = toUnwrappedModel(socialEquityAssetEntry);
224    
225                    Session session = null;
226    
227                    try {
228                            session = openSession();
229    
230                            if (socialEquityAssetEntry.isCachedModel() ||
231                                            BatchSessionUtil.isEnabled()) {
232                                    Object staleObject = session.get(SocialEquityAssetEntryImpl.class,
233                                                    socialEquityAssetEntry.getPrimaryKeyObj());
234    
235                                    if (staleObject != null) {
236                                            session.evict(staleObject);
237                                    }
238                            }
239    
240                            session.delete(socialEquityAssetEntry);
241    
242                            session.flush();
243                    }
244                    catch (Exception e) {
245                            throw processException(e);
246                    }
247                    finally {
248                            closeSession(session);
249                    }
250    
251                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
252    
253                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
254    
255                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
256                            new Object[] {
257                                    new Long(socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())
258                            });
259    
260                    EntityCacheUtil.removeResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
261                            SocialEquityAssetEntryImpl.class,
262                            socialEquityAssetEntry.getPrimaryKey());
263    
264                    return socialEquityAssetEntry;
265            }
266    
267            public SocialEquityAssetEntry updateImpl(
268                    com.liferay.portlet.social.model.SocialEquityAssetEntry socialEquityAssetEntry,
269                    boolean merge) throws SystemException {
270                    socialEquityAssetEntry = toUnwrappedModel(socialEquityAssetEntry);
271    
272                    boolean isNew = socialEquityAssetEntry.isNew();
273    
274                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
275    
276                    Session session = null;
277    
278                    try {
279                            session = openSession();
280    
281                            BatchSessionUtil.update(session, socialEquityAssetEntry, merge);
282    
283                            socialEquityAssetEntry.setNew(false);
284                    }
285                    catch (Exception e) {
286                            throw processException(e);
287                    }
288                    finally {
289                            closeSession(session);
290                    }
291    
292                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
293    
294                    EntityCacheUtil.putResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
295                            SocialEquityAssetEntryImpl.class,
296                            socialEquityAssetEntry.getPrimaryKey(), socialEquityAssetEntry);
297    
298                    if (!isNew &&
299                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
300                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
301                                    new Object[] {
302                                            new Long(socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())
303                                    });
304                    }
305    
306                    if (isNew ||
307                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
308                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
309                                    new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) },
310                                    socialEquityAssetEntry);
311                    }
312    
313                    return socialEquityAssetEntry;
314            }
315    
316            protected SocialEquityAssetEntry toUnwrappedModel(
317                    SocialEquityAssetEntry socialEquityAssetEntry) {
318                    if (socialEquityAssetEntry instanceof SocialEquityAssetEntryImpl) {
319                            return socialEquityAssetEntry;
320                    }
321    
322                    SocialEquityAssetEntryImpl socialEquityAssetEntryImpl = new SocialEquityAssetEntryImpl();
323    
324                    socialEquityAssetEntryImpl.setNew(socialEquityAssetEntry.isNew());
325                    socialEquityAssetEntryImpl.setPrimaryKey(socialEquityAssetEntry.getPrimaryKey());
326    
327                    socialEquityAssetEntryImpl.setEquityAssetEntryId(socialEquityAssetEntry.getEquityAssetEntryId());
328                    socialEquityAssetEntryImpl.setGroupId(socialEquityAssetEntry.getGroupId());
329                    socialEquityAssetEntryImpl.setCompanyId(socialEquityAssetEntry.getCompanyId());
330                    socialEquityAssetEntryImpl.setUserId(socialEquityAssetEntry.getUserId());
331                    socialEquityAssetEntryImpl.setAssetEntryId(socialEquityAssetEntry.getAssetEntryId());
332                    socialEquityAssetEntryImpl.setInformationK(socialEquityAssetEntry.getInformationK());
333                    socialEquityAssetEntryImpl.setInformationB(socialEquityAssetEntry.getInformationB());
334    
335                    return socialEquityAssetEntryImpl;
336            }
337    
338            /**
339             * Finds the social equity asset entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
340             *
341             * @param primaryKey the primary key of the social equity asset entry to find
342             * @return the social equity asset entry
343             * @throws com.liferay.portal.NoSuchModelException if a social equity asset entry with the primary key could not be found
344             * @throws SystemException if a system exception occurred
345             */
346            public SocialEquityAssetEntry findByPrimaryKey(Serializable primaryKey)
347                    throws NoSuchModelException, SystemException {
348                    return findByPrimaryKey(((Long)primaryKey).longValue());
349            }
350    
351            /**
352             * Finds the social equity asset entry with the primary key or throws a {@link com.liferay.portlet.social.NoSuchEquityAssetEntryException} if it could not be found.
353             *
354             * @param equityAssetEntryId the primary key of the social equity asset entry to find
355             * @return the social equity asset entry
356             * @throws com.liferay.portlet.social.NoSuchEquityAssetEntryException if a social equity asset entry with the primary key could not be found
357             * @throws SystemException if a system exception occurred
358             */
359            public SocialEquityAssetEntry findByPrimaryKey(long equityAssetEntryId)
360                    throws NoSuchEquityAssetEntryException, SystemException {
361                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByPrimaryKey(equityAssetEntryId);
362    
363                    if (socialEquityAssetEntry == null) {
364                            if (_log.isWarnEnabled()) {
365                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
366                                            equityAssetEntryId);
367                            }
368    
369                            throw new NoSuchEquityAssetEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
370                                    equityAssetEntryId);
371                    }
372    
373                    return socialEquityAssetEntry;
374            }
375    
376            /**
377             * Finds the social equity asset entry with the primary key or returns <code>null</code> if it could not be found.
378             *
379             * @param primaryKey the primary key of the social equity asset entry to find
380             * @return the social equity asset entry, or <code>null</code> if a social equity asset entry with the primary key could not be found
381             * @throws SystemException if a system exception occurred
382             */
383            public SocialEquityAssetEntry fetchByPrimaryKey(Serializable primaryKey)
384                    throws SystemException {
385                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
386            }
387    
388            /**
389             * Finds the social equity asset entry with the primary key or returns <code>null</code> if it could not be found.
390             *
391             * @param equityAssetEntryId the primary key of the social equity asset entry to find
392             * @return the social equity asset entry, or <code>null</code> if a social equity asset entry with the primary key could not be found
393             * @throws SystemException if a system exception occurred
394             */
395            public SocialEquityAssetEntry fetchByPrimaryKey(long equityAssetEntryId)
396                    throws SystemException {
397                    SocialEquityAssetEntry socialEquityAssetEntry = (SocialEquityAssetEntry)EntityCacheUtil.getResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
398                                    SocialEquityAssetEntryImpl.class, equityAssetEntryId, this);
399    
400                    if (socialEquityAssetEntry == null) {
401                            Session session = null;
402    
403                            try {
404                                    session = openSession();
405    
406                                    socialEquityAssetEntry = (SocialEquityAssetEntry)session.get(SocialEquityAssetEntryImpl.class,
407                                                    new Long(equityAssetEntryId));
408                            }
409                            catch (Exception e) {
410                                    throw processException(e);
411                            }
412                            finally {
413                                    if (socialEquityAssetEntry != null) {
414                                            cacheResult(socialEquityAssetEntry);
415                                    }
416    
417                                    closeSession(session);
418                            }
419                    }
420    
421                    return socialEquityAssetEntry;
422            }
423    
424            /**
425             * Finds the social equity asset entry where assetEntryId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchEquityAssetEntryException} if it could not be found.
426             *
427             * @param assetEntryId the asset entry id to search with
428             * @return the matching social equity asset entry
429             * @throws com.liferay.portlet.social.NoSuchEquityAssetEntryException if a matching social equity asset entry could not be found
430             * @throws SystemException if a system exception occurred
431             */
432            public SocialEquityAssetEntry findByAssetEntryId(long assetEntryId)
433                    throws NoSuchEquityAssetEntryException, SystemException {
434                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByAssetEntryId(assetEntryId);
435    
436                    if (socialEquityAssetEntry == null) {
437                            StringBundler msg = new StringBundler(4);
438    
439                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
440    
441                            msg.append("assetEntryId=");
442                            msg.append(assetEntryId);
443    
444                            msg.append(StringPool.CLOSE_CURLY_BRACE);
445    
446                            if (_log.isWarnEnabled()) {
447                                    _log.warn(msg.toString());
448                            }
449    
450                            throw new NoSuchEquityAssetEntryException(msg.toString());
451                    }
452    
453                    return socialEquityAssetEntry;
454            }
455    
456            /**
457             * Finds the social equity asset entry where assetEntryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
458             *
459             * @param assetEntryId the asset entry id to search with
460             * @return the matching social equity asset entry, or <code>null</code> if a matching social equity asset entry could not be found
461             * @throws SystemException if a system exception occurred
462             */
463            public SocialEquityAssetEntry fetchByAssetEntryId(long assetEntryId)
464                    throws SystemException {
465                    return fetchByAssetEntryId(assetEntryId, true);
466            }
467    
468            /**
469             * Finds the social equity asset entry where assetEntryId = &#63; or returns <code>null</code> if it could not be found, optionally using the finder cache.
470             *
471             * @param assetEntryId the asset entry id to search with
472             * @return the matching social equity asset entry, or <code>null</code> if a matching social equity asset entry could not be found
473             * @throws SystemException if a system exception occurred
474             */
475            public SocialEquityAssetEntry fetchByAssetEntryId(long assetEntryId,
476                    boolean retrieveFromCache) throws SystemException {
477                    Object[] finderArgs = new Object[] { assetEntryId };
478    
479                    Object result = null;
480    
481                    if (retrieveFromCache) {
482                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
483                                            finderArgs, this);
484                    }
485    
486                    if (result == null) {
487                            Session session = null;
488    
489                            try {
490                                    session = openSession();
491    
492                                    StringBundler query = new StringBundler(2);
493    
494                                    query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE);
495    
496                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
497    
498                                    String sql = query.toString();
499    
500                                    Query q = session.createQuery(sql);
501    
502                                    QueryPos qPos = QueryPos.getInstance(q);
503    
504                                    qPos.add(assetEntryId);
505    
506                                    List<SocialEquityAssetEntry> list = q.list();
507    
508                                    result = list;
509    
510                                    SocialEquityAssetEntry socialEquityAssetEntry = null;
511    
512                                    if (list.isEmpty()) {
513                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
514                                                    finderArgs, list);
515                                    }
516                                    else {
517                                            socialEquityAssetEntry = list.get(0);
518    
519                                            cacheResult(socialEquityAssetEntry);
520    
521                                            if ((socialEquityAssetEntry.getAssetEntryId() != assetEntryId)) {
522                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
523                                                            finderArgs, socialEquityAssetEntry);
524                                            }
525                                    }
526    
527                                    return socialEquityAssetEntry;
528                            }
529                            catch (Exception e) {
530                                    throw processException(e);
531                            }
532                            finally {
533                                    if (result == null) {
534                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
535                                                    finderArgs, new ArrayList<SocialEquityAssetEntry>());
536                                    }
537    
538                                    closeSession(session);
539                            }
540                    }
541                    else {
542                            if (result instanceof List<?>) {
543                                    return null;
544                            }
545                            else {
546                                    return (SocialEquityAssetEntry)result;
547                            }
548                    }
549            }
550    
551            /**
552             * Finds all the social equity asset entries.
553             *
554             * @return the social equity asset entries
555             * @throws SystemException if a system exception occurred
556             */
557            public List<SocialEquityAssetEntry> findAll() throws SystemException {
558                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
559            }
560    
561            /**
562             * Finds a range of all the social equity asset entries.
563             *
564             * <p>
565             * 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.
566             * </p>
567             *
568             * @param start the lower bound of the range of social equity asset entries to return
569             * @param end the upper bound of the range of social equity asset entries to return (not inclusive)
570             * @return the range of social equity asset entries
571             * @throws SystemException if a system exception occurred
572             */
573            public List<SocialEquityAssetEntry> findAll(int start, int end)
574                    throws SystemException {
575                    return findAll(start, end, null);
576            }
577    
578            /**
579             * Finds an ordered range of all the social equity asset entries.
580             *
581             * <p>
582             * 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.
583             * </p>
584             *
585             * @param start the lower bound of the range of social equity asset entries to return
586             * @param end the upper bound of the range of social equity asset entries to return (not inclusive)
587             * @param orderByComparator the comparator to order the results by
588             * @return the ordered range of social equity asset entries
589             * @throws SystemException if a system exception occurred
590             */
591            public List<SocialEquityAssetEntry> findAll(int start, int end,
592                    OrderByComparator orderByComparator) throws SystemException {
593                    Object[] finderArgs = new Object[] {
594                                    String.valueOf(start), String.valueOf(end),
595                                    String.valueOf(orderByComparator)
596                            };
597    
598                    List<SocialEquityAssetEntry> list = (List<SocialEquityAssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
599                                    finderArgs, this);
600    
601                    if (list == null) {
602                            Session session = null;
603    
604                            try {
605                                    session = openSession();
606    
607                                    StringBundler query = null;
608                                    String sql = null;
609    
610                                    if (orderByComparator != null) {
611                                            query = new StringBundler(2 +
612                                                            (orderByComparator.getOrderByFields().length * 3));
613    
614                                            query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY);
615    
616                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
617                                                    orderByComparator);
618    
619                                            sql = query.toString();
620                                    }
621                                    else {
622                                            sql = _SQL_SELECT_SOCIALEQUITYASSETENTRY;
623                                    }
624    
625                                    Query q = session.createQuery(sql);
626    
627                                    if (orderByComparator == null) {
628                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
629                                                            getDialect(), start, end, false);
630    
631                                            Collections.sort(list);
632                                    }
633                                    else {
634                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
635                                                            getDialect(), start, end);
636                                    }
637                            }
638                            catch (Exception e) {
639                                    throw processException(e);
640                            }
641                            finally {
642                                    if (list == null) {
643                                            list = new ArrayList<SocialEquityAssetEntry>();
644                                    }
645    
646                                    cacheResult(list);
647    
648                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
649    
650                                    closeSession(session);
651                            }
652                    }
653    
654                    return list;
655            }
656    
657            /**
658             * Removes the social equity asset entry where assetEntryId = &#63; from the database.
659             *
660             * @param assetEntryId the asset entry id to search with
661             * @throws SystemException if a system exception occurred
662             */
663            public void removeByAssetEntryId(long assetEntryId)
664                    throws NoSuchEquityAssetEntryException, SystemException {
665                    SocialEquityAssetEntry socialEquityAssetEntry = findByAssetEntryId(assetEntryId);
666    
667                    remove(socialEquityAssetEntry);
668            }
669    
670            /**
671             * Removes all the social equity asset entries from the database.
672             *
673             * @throws SystemException if a system exception occurred
674             */
675            public void removeAll() throws SystemException {
676                    for (SocialEquityAssetEntry socialEquityAssetEntry : findAll()) {
677                            remove(socialEquityAssetEntry);
678                    }
679            }
680    
681            /**
682             * Counts all the social equity asset entries where assetEntryId = &#63;.
683             *
684             * @param assetEntryId the asset entry id to search with
685             * @return the number of matching social equity asset entries
686             * @throws SystemException if a system exception occurred
687             */
688            public int countByAssetEntryId(long assetEntryId) throws SystemException {
689                    Object[] finderArgs = new Object[] { assetEntryId };
690    
691                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
692                                    finderArgs, this);
693    
694                    if (count == null) {
695                            Session session = null;
696    
697                            try {
698                                    session = openSession();
699    
700                                    StringBundler query = new StringBundler(2);
701    
702                                    query.append(_SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE);
703    
704                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
705    
706                                    String sql = query.toString();
707    
708                                    Query q = session.createQuery(sql);
709    
710                                    QueryPos qPos = QueryPos.getInstance(q);
711    
712                                    qPos.add(assetEntryId);
713    
714                                    count = (Long)q.uniqueResult();
715                            }
716                            catch (Exception e) {
717                                    throw processException(e);
718                            }
719                            finally {
720                                    if (count == null) {
721                                            count = Long.valueOf(0);
722                                    }
723    
724                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
725                                            finderArgs, count);
726    
727                                    closeSession(session);
728                            }
729                    }
730    
731                    return count.intValue();
732            }
733    
734            /**
735             * Counts all the social equity asset entries.
736             *
737             * @return the number of social equity asset entries
738             * @throws SystemException if a system exception occurred
739             */
740            public int countAll() throws SystemException {
741                    Object[] finderArgs = new Object[0];
742    
743                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
744                                    finderArgs, this);
745    
746                    if (count == null) {
747                            Session session = null;
748    
749                            try {
750                                    session = openSession();
751    
752                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYASSETENTRY);
753    
754                                    count = (Long)q.uniqueResult();
755                            }
756                            catch (Exception e) {
757                                    throw processException(e);
758                            }
759                            finally {
760                                    if (count == null) {
761                                            count = Long.valueOf(0);
762                                    }
763    
764                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
765                                            count);
766    
767                                    closeSession(session);
768                            }
769                    }
770    
771                    return count.intValue();
772            }
773    
774            /**
775             * Initializes the social equity asset entry persistence.
776             */
777            public void afterPropertiesSet() {
778                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
779                                            com.liferay.portal.util.PropsUtil.get(
780                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquityAssetEntry")));
781    
782                    if (listenerClassNames.length > 0) {
783                            try {
784                                    List<ModelListener<SocialEquityAssetEntry>> listenersList = new ArrayList<ModelListener<SocialEquityAssetEntry>>();
785    
786                                    for (String listenerClassName : listenerClassNames) {
787                                            listenersList.add((ModelListener<SocialEquityAssetEntry>)InstanceFactory.newInstance(
788                                                            listenerClassName));
789                                    }
790    
791                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
792                            }
793                            catch (Exception e) {
794                                    _log.error(e);
795                            }
796                    }
797            }
798    
799            @BeanReference(type = SocialActivityPersistence.class)
800            protected SocialActivityPersistence socialActivityPersistence;
801            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
802            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
803            @BeanReference(type = SocialEquityHistoryPersistence.class)
804            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
805            @BeanReference(type = SocialEquityLogPersistence.class)
806            protected SocialEquityLogPersistence socialEquityLogPersistence;
807            @BeanReference(type = SocialEquitySettingPersistence.class)
808            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
809            @BeanReference(type = SocialEquityUserPersistence.class)
810            protected SocialEquityUserPersistence socialEquityUserPersistence;
811            @BeanReference(type = SocialRelationPersistence.class)
812            protected SocialRelationPersistence socialRelationPersistence;
813            @BeanReference(type = SocialRequestPersistence.class)
814            protected SocialRequestPersistence socialRequestPersistence;
815            @BeanReference(type = ResourcePersistence.class)
816            protected ResourcePersistence resourcePersistence;
817            @BeanReference(type = UserPersistence.class)
818            protected UserPersistence userPersistence;
819            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry";
820            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
821            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry";
822            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
823            private static final String _FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2 = "socialEquityAssetEntry.assetEntryId = ?";
824            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquityAssetEntry.";
825            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquityAssetEntry exists with the primary key ";
826            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquityAssetEntry exists with the key {";
827            private static Log _log = LogFactoryUtil.getLog(SocialEquityAssetEntryPersistenceImpl.class);
828    }