001    /**
002     * Copyright (c) 2000-2011 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                            BatchSessionUtil.delete(session, socialEquityAssetEntry);
231                    }
232                    catch (Exception e) {
233                            throw processException(e);
234                    }
235                    finally {
236                            closeSession(session);
237                    }
238    
239                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
240    
241                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
242    
243                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
244                            new Object[] {
245                                    new Long(socialEquityAssetEntryModelImpl.getAssetEntryId())
246                            });
247    
248                    EntityCacheUtil.removeResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
249                            SocialEquityAssetEntryImpl.class,
250                            socialEquityAssetEntry.getPrimaryKey());
251    
252                    return socialEquityAssetEntry;
253            }
254    
255            public SocialEquityAssetEntry updateImpl(
256                    com.liferay.portlet.social.model.SocialEquityAssetEntry socialEquityAssetEntry,
257                    boolean merge) throws SystemException {
258                    socialEquityAssetEntry = toUnwrappedModel(socialEquityAssetEntry);
259    
260                    boolean isNew = socialEquityAssetEntry.isNew();
261    
262                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
263    
264                    Session session = null;
265    
266                    try {
267                            session = openSession();
268    
269                            BatchSessionUtil.update(session, socialEquityAssetEntry, merge);
270    
271                            socialEquityAssetEntry.setNew(false);
272                    }
273                    catch (Exception e) {
274                            throw processException(e);
275                    }
276                    finally {
277                            closeSession(session);
278                    }
279    
280                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
281    
282                    EntityCacheUtil.putResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
283                            SocialEquityAssetEntryImpl.class,
284                            socialEquityAssetEntry.getPrimaryKey(), socialEquityAssetEntry);
285    
286                    if (!isNew &&
287                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
288                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
289                                    new Object[] {
290                                            new Long(socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())
291                                    });
292                    }
293    
294                    if (isNew ||
295                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
296                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
297                                    new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) },
298                                    socialEquityAssetEntry);
299                    }
300    
301                    return socialEquityAssetEntry;
302            }
303    
304            protected SocialEquityAssetEntry toUnwrappedModel(
305                    SocialEquityAssetEntry socialEquityAssetEntry) {
306                    if (socialEquityAssetEntry instanceof SocialEquityAssetEntryImpl) {
307                            return socialEquityAssetEntry;
308                    }
309    
310                    SocialEquityAssetEntryImpl socialEquityAssetEntryImpl = new SocialEquityAssetEntryImpl();
311    
312                    socialEquityAssetEntryImpl.setNew(socialEquityAssetEntry.isNew());
313                    socialEquityAssetEntryImpl.setPrimaryKey(socialEquityAssetEntry.getPrimaryKey());
314    
315                    socialEquityAssetEntryImpl.setEquityAssetEntryId(socialEquityAssetEntry.getEquityAssetEntryId());
316                    socialEquityAssetEntryImpl.setGroupId(socialEquityAssetEntry.getGroupId());
317                    socialEquityAssetEntryImpl.setCompanyId(socialEquityAssetEntry.getCompanyId());
318                    socialEquityAssetEntryImpl.setUserId(socialEquityAssetEntry.getUserId());
319                    socialEquityAssetEntryImpl.setAssetEntryId(socialEquityAssetEntry.getAssetEntryId());
320                    socialEquityAssetEntryImpl.setInformationK(socialEquityAssetEntry.getInformationK());
321                    socialEquityAssetEntryImpl.setInformationB(socialEquityAssetEntry.getInformationB());
322    
323                    return socialEquityAssetEntryImpl;
324            }
325    
326            /**
327             * Finds the social equity asset entry with the primary key or throws a {@link com.liferay.portal.NoSuchModelException} if it could not be found.
328             *
329             * @param primaryKey the primary key of the social equity asset entry to find
330             * @return the social equity asset entry
331             * @throws com.liferay.portal.NoSuchModelException if a social equity asset entry with the primary key could not be found
332             * @throws SystemException if a system exception occurred
333             */
334            public SocialEquityAssetEntry findByPrimaryKey(Serializable primaryKey)
335                    throws NoSuchModelException, SystemException {
336                    return findByPrimaryKey(((Long)primaryKey).longValue());
337            }
338    
339            /**
340             * 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.
341             *
342             * @param equityAssetEntryId the primary key of the social equity asset entry to find
343             * @return the social equity asset entry
344             * @throws com.liferay.portlet.social.NoSuchEquityAssetEntryException if a social equity asset entry with the primary key could not be found
345             * @throws SystemException if a system exception occurred
346             */
347            public SocialEquityAssetEntry findByPrimaryKey(long equityAssetEntryId)
348                    throws NoSuchEquityAssetEntryException, SystemException {
349                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByPrimaryKey(equityAssetEntryId);
350    
351                    if (socialEquityAssetEntry == null) {
352                            if (_log.isWarnEnabled()) {
353                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
354                                            equityAssetEntryId);
355                            }
356    
357                            throw new NoSuchEquityAssetEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
358                                    equityAssetEntryId);
359                    }
360    
361                    return socialEquityAssetEntry;
362            }
363    
364            /**
365             * Finds the social equity asset entry with the primary key or returns <code>null</code> if it could not be found.
366             *
367             * @param primaryKey the primary key of the social equity asset entry to find
368             * @return the social equity asset entry, or <code>null</code> if a social equity asset entry with the primary key could not be found
369             * @throws SystemException if a system exception occurred
370             */
371            public SocialEquityAssetEntry fetchByPrimaryKey(Serializable primaryKey)
372                    throws SystemException {
373                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
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 equityAssetEntryId 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(long equityAssetEntryId)
384                    throws SystemException {
385                    SocialEquityAssetEntry socialEquityAssetEntry = (SocialEquityAssetEntry)EntityCacheUtil.getResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
386                                    SocialEquityAssetEntryImpl.class, equityAssetEntryId, this);
387    
388                    if (socialEquityAssetEntry == null) {
389                            Session session = null;
390    
391                            try {
392                                    session = openSession();
393    
394                                    socialEquityAssetEntry = (SocialEquityAssetEntry)session.get(SocialEquityAssetEntryImpl.class,
395                                                    new Long(equityAssetEntryId));
396                            }
397                            catch (Exception e) {
398                                    throw processException(e);
399                            }
400                            finally {
401                                    if (socialEquityAssetEntry != null) {
402                                            cacheResult(socialEquityAssetEntry);
403                                    }
404    
405                                    closeSession(session);
406                            }
407                    }
408    
409                    return socialEquityAssetEntry;
410            }
411    
412            /**
413             * Finds the social equity asset entry where assetEntryId = &#63; or throws a {@link com.liferay.portlet.social.NoSuchEquityAssetEntryException} if it could not be found.
414             *
415             * @param assetEntryId the asset entry id to search with
416             * @return the matching social equity asset entry
417             * @throws com.liferay.portlet.social.NoSuchEquityAssetEntryException if a matching social equity asset entry could not be found
418             * @throws SystemException if a system exception occurred
419             */
420            public SocialEquityAssetEntry findByAssetEntryId(long assetEntryId)
421                    throws NoSuchEquityAssetEntryException, SystemException {
422                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByAssetEntryId(assetEntryId);
423    
424                    if (socialEquityAssetEntry == null) {
425                            StringBundler msg = new StringBundler(4);
426    
427                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
428    
429                            msg.append("assetEntryId=");
430                            msg.append(assetEntryId);
431    
432                            msg.append(StringPool.CLOSE_CURLY_BRACE);
433    
434                            if (_log.isWarnEnabled()) {
435                                    _log.warn(msg.toString());
436                            }
437    
438                            throw new NoSuchEquityAssetEntryException(msg.toString());
439                    }
440    
441                    return socialEquityAssetEntry;
442            }
443    
444            /**
445             * Finds the social equity asset entry where assetEntryId = &#63; or returns <code>null</code> if it could not be found. Uses the finder cache.
446             *
447             * @param assetEntryId the asset entry id to search with
448             * @return the matching social equity asset entry, or <code>null</code> if a matching social equity asset entry could not be found
449             * @throws SystemException if a system exception occurred
450             */
451            public SocialEquityAssetEntry fetchByAssetEntryId(long assetEntryId)
452                    throws SystemException {
453                    return fetchByAssetEntryId(assetEntryId, true);
454            }
455    
456            /**
457             * 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.
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                    boolean retrieveFromCache) throws SystemException {
465                    Object[] finderArgs = new Object[] { assetEntryId };
466    
467                    Object result = null;
468    
469                    if (retrieveFromCache) {
470                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
471                                            finderArgs, this);
472                    }
473    
474                    if (result == null) {
475                            StringBundler query = new StringBundler(2);
476    
477                            query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE);
478    
479                            query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
480    
481                            String sql = query.toString();
482    
483                            Session session = null;
484    
485                            try {
486                                    session = openSession();
487    
488                                    Query q = session.createQuery(sql);
489    
490                                    QueryPos qPos = QueryPos.getInstance(q);
491    
492                                    qPos.add(assetEntryId);
493    
494                                    List<SocialEquityAssetEntry> list = q.list();
495    
496                                    result = list;
497    
498                                    SocialEquityAssetEntry socialEquityAssetEntry = null;
499    
500                                    if (list.isEmpty()) {
501                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
502                                                    finderArgs, list);
503                                    }
504                                    else {
505                                            socialEquityAssetEntry = list.get(0);
506    
507                                            cacheResult(socialEquityAssetEntry);
508    
509                                            if ((socialEquityAssetEntry.getAssetEntryId() != assetEntryId)) {
510                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
511                                                            finderArgs, socialEquityAssetEntry);
512                                            }
513                                    }
514    
515                                    return socialEquityAssetEntry;
516                            }
517                            catch (Exception e) {
518                                    throw processException(e);
519                            }
520                            finally {
521                                    if (result == null) {
522                                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
523                                                    finderArgs);
524                                    }
525    
526                                    closeSession(session);
527                            }
528                    }
529                    else {
530                            if (result instanceof List<?>) {
531                                    return null;
532                            }
533                            else {
534                                    return (SocialEquityAssetEntry)result;
535                            }
536                    }
537            }
538    
539            /**
540             * Finds all the social equity asset entries.
541             *
542             * @return the social equity asset entries
543             * @throws SystemException if a system exception occurred
544             */
545            public List<SocialEquityAssetEntry> findAll() throws SystemException {
546                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
547            }
548    
549            /**
550             * Finds a range of all the social equity asset entries.
551             *
552             * <p>
553             * 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.
554             * </p>
555             *
556             * @param start the lower bound of the range of social equity asset entries to return
557             * @param end the upper bound of the range of social equity asset entries to return (not inclusive)
558             * @return the range of social equity asset entries
559             * @throws SystemException if a system exception occurred
560             */
561            public List<SocialEquityAssetEntry> findAll(int start, int end)
562                    throws SystemException {
563                    return findAll(start, end, null);
564            }
565    
566            /**
567             * Finds an ordered range of all the social equity asset entries.
568             *
569             * <p>
570             * 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.
571             * </p>
572             *
573             * @param start the lower bound of the range of social equity asset entries to return
574             * @param end the upper bound of the range of social equity asset entries to return (not inclusive)
575             * @param orderByComparator the comparator to order the results by
576             * @return the ordered range of social equity asset entries
577             * @throws SystemException if a system exception occurred
578             */
579            public List<SocialEquityAssetEntry> findAll(int start, int end,
580                    OrderByComparator orderByComparator) throws SystemException {
581                    Object[] finderArgs = new Object[] {
582                                    String.valueOf(start), String.valueOf(end),
583                                    String.valueOf(orderByComparator)
584                            };
585    
586                    List<SocialEquityAssetEntry> list = (List<SocialEquityAssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
587                                    finderArgs, this);
588    
589                    if (list == null) {
590                            StringBundler query = null;
591                            String sql = null;
592    
593                            if (orderByComparator != null) {
594                                    query = new StringBundler(2 +
595                                                    (orderByComparator.getOrderByFields().length * 3));
596    
597                                    query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY);
598    
599                                    appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
600                                            orderByComparator);
601    
602                                    sql = query.toString();
603                            }
604                            else {
605                                    sql = _SQL_SELECT_SOCIALEQUITYASSETENTRY;
606                            }
607    
608                            Session session = null;
609    
610                            try {
611                                    session = openSession();
612    
613                                    Query q = session.createQuery(sql);
614    
615                                    if (orderByComparator == null) {
616                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
617                                                            getDialect(), start, end, false);
618    
619                                            Collections.sort(list);
620                                    }
621                                    else {
622                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
623                                                            getDialect(), start, end);
624                                    }
625                            }
626                            catch (Exception e) {
627                                    throw processException(e);
628                            }
629                            finally {
630                                    if (list == null) {
631                                            FinderCacheUtil.removeResult(FINDER_PATH_FIND_ALL,
632                                                    finderArgs);
633                                    }
634                                    else {
635                                            cacheResult(list);
636    
637                                            FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs,
638                                                    list);
639                                    }
640    
641                                    closeSession(session);
642                            }
643                    }
644    
645                    return list;
646            }
647    
648            /**
649             * Removes the social equity asset entry where assetEntryId = &#63; from the database.
650             *
651             * @param assetEntryId the asset entry id to search with
652             * @throws SystemException if a system exception occurred
653             */
654            public void removeByAssetEntryId(long assetEntryId)
655                    throws NoSuchEquityAssetEntryException, SystemException {
656                    SocialEquityAssetEntry socialEquityAssetEntry = findByAssetEntryId(assetEntryId);
657    
658                    remove(socialEquityAssetEntry);
659            }
660    
661            /**
662             * Removes all the social equity asset entries from the database.
663             *
664             * @throws SystemException if a system exception occurred
665             */
666            public void removeAll() throws SystemException {
667                    for (SocialEquityAssetEntry socialEquityAssetEntry : findAll()) {
668                            remove(socialEquityAssetEntry);
669                    }
670            }
671    
672            /**
673             * Counts all the social equity asset entries where assetEntryId = &#63;.
674             *
675             * @param assetEntryId the asset entry id to search with
676             * @return the number of matching social equity asset entries
677             * @throws SystemException if a system exception occurred
678             */
679            public int countByAssetEntryId(long assetEntryId) throws SystemException {
680                    Object[] finderArgs = new Object[] { assetEntryId };
681    
682                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
683                                    finderArgs, this);
684    
685                    if (count == null) {
686                            StringBundler query = new StringBundler(2);
687    
688                            query.append(_SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE);
689    
690                            query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
691    
692                            String sql = query.toString();
693    
694                            Session session = null;
695    
696                            try {
697                                    session = openSession();
698    
699                                    Query q = session.createQuery(sql);
700    
701                                    QueryPos qPos = QueryPos.getInstance(q);
702    
703                                    qPos.add(assetEntryId);
704    
705                                    count = (Long)q.uniqueResult();
706                            }
707                            catch (Exception e) {
708                                    throw processException(e);
709                            }
710                            finally {
711                                    if (count == null) {
712                                            count = Long.valueOf(0);
713                                    }
714    
715                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
716                                            finderArgs, count);
717    
718                                    closeSession(session);
719                            }
720                    }
721    
722                    return count.intValue();
723            }
724    
725            /**
726             * Counts all the social equity asset entries.
727             *
728             * @return the number of social equity asset entries
729             * @throws SystemException if a system exception occurred
730             */
731            public int countAll() throws SystemException {
732                    Object[] finderArgs = new Object[0];
733    
734                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
735                                    finderArgs, this);
736    
737                    if (count == null) {
738                            Session session = null;
739    
740                            try {
741                                    session = openSession();
742    
743                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYASSETENTRY);
744    
745                                    count = (Long)q.uniqueResult();
746                            }
747                            catch (Exception e) {
748                                    throw processException(e);
749                            }
750                            finally {
751                                    if (count == null) {
752                                            count = Long.valueOf(0);
753                                    }
754    
755                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
756                                            count);
757    
758                                    closeSession(session);
759                            }
760                    }
761    
762                    return count.intValue();
763            }
764    
765            /**
766             * Initializes the social equity asset entry persistence.
767             */
768            public void afterPropertiesSet() {
769                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
770                                            com.liferay.portal.util.PropsUtil.get(
771                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquityAssetEntry")));
772    
773                    if (listenerClassNames.length > 0) {
774                            try {
775                                    List<ModelListener<SocialEquityAssetEntry>> listenersList = new ArrayList<ModelListener<SocialEquityAssetEntry>>();
776    
777                                    for (String listenerClassName : listenerClassNames) {
778                                            listenersList.add((ModelListener<SocialEquityAssetEntry>)InstanceFactory.newInstance(
779                                                            listenerClassName));
780                                    }
781    
782                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
783                            }
784                            catch (Exception e) {
785                                    _log.error(e);
786                            }
787                    }
788            }
789    
790            public void destroy() {
791                    EntityCacheUtil.removeCache(SocialEquityAssetEntryImpl.class.getName());
792                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
793                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
794            }
795    
796            @BeanReference(type = SocialActivityPersistence.class)
797            protected SocialActivityPersistence socialActivityPersistence;
798            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
799            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
800            @BeanReference(type = SocialEquityGroupSettingPersistence.class)
801            protected SocialEquityGroupSettingPersistence socialEquityGroupSettingPersistence;
802            @BeanReference(type = SocialEquityHistoryPersistence.class)
803            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
804            @BeanReference(type = SocialEquityLogPersistence.class)
805            protected SocialEquityLogPersistence socialEquityLogPersistence;
806            @BeanReference(type = SocialEquitySettingPersistence.class)
807            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
808            @BeanReference(type = SocialEquityUserPersistence.class)
809            protected SocialEquityUserPersistence socialEquityUserPersistence;
810            @BeanReference(type = SocialRelationPersistence.class)
811            protected SocialRelationPersistence socialRelationPersistence;
812            @BeanReference(type = SocialRequestPersistence.class)
813            protected SocialRequestPersistence socialRequestPersistence;
814            @BeanReference(type = ResourcePersistence.class)
815            protected ResourcePersistence resourcePersistence;
816            @BeanReference(type = UserPersistence.class)
817            protected UserPersistence userPersistence;
818            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry";
819            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
820            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry";
821            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
822            private static final String _FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2 = "socialEquityAssetEntry.assetEntryId = ?";
823            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquityAssetEntry.";
824            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquityAssetEntry exists with the primary key ";
825            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquityAssetEntry exists with the key {";
826            private static Log _log = LogFactoryUtil.getLog(SocialEquityAssetEntryPersistenceImpl.class);
827    }