001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
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.getOriginalAssetEntryId())
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                            Session session = null;
476    
477                            try {
478                                    session = openSession();
479    
480                                    StringBundler query = new StringBundler(2);
481    
482                                    query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE);
483    
484                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
485    
486                                    String sql = query.toString();
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.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
523                                                    finderArgs, new ArrayList<SocialEquityAssetEntry>());
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                            Session session = null;
591    
592                            try {
593                                    session = openSession();
594    
595                                    StringBundler query = null;
596                                    String sql = null;
597    
598                                    if (orderByComparator != null) {
599                                            query = new StringBundler(2 +
600                                                            (orderByComparator.getOrderByFields().length * 3));
601    
602                                            query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY);
603    
604                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
605                                                    orderByComparator);
606    
607                                            sql = query.toString();
608                                    }
609                                    else {
610                                            sql = _SQL_SELECT_SOCIALEQUITYASSETENTRY;
611                                    }
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                                            list = new ArrayList<SocialEquityAssetEntry>();
632                                    }
633    
634                                    cacheResult(list);
635    
636                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
637    
638                                    closeSession(session);
639                            }
640                    }
641    
642                    return list;
643            }
644    
645            /**
646             * Removes the social equity asset entry where assetEntryId = &#63; from the database.
647             *
648             * @param assetEntryId the asset entry id to search with
649             * @throws SystemException if a system exception occurred
650             */
651            public void removeByAssetEntryId(long assetEntryId)
652                    throws NoSuchEquityAssetEntryException, SystemException {
653                    SocialEquityAssetEntry socialEquityAssetEntry = findByAssetEntryId(assetEntryId);
654    
655                    remove(socialEquityAssetEntry);
656            }
657    
658            /**
659             * Removes all the social equity asset entries from the database.
660             *
661             * @throws SystemException if a system exception occurred
662             */
663            public void removeAll() throws SystemException {
664                    for (SocialEquityAssetEntry socialEquityAssetEntry : findAll()) {
665                            remove(socialEquityAssetEntry);
666                    }
667            }
668    
669            /**
670             * Counts all the social equity asset entries where assetEntryId = &#63;.
671             *
672             * @param assetEntryId the asset entry id to search with
673             * @return the number of matching social equity asset entries
674             * @throws SystemException if a system exception occurred
675             */
676            public int countByAssetEntryId(long assetEntryId) throws SystemException {
677                    Object[] finderArgs = new Object[] { assetEntryId };
678    
679                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
680                                    finderArgs, this);
681    
682                    if (count == null) {
683                            Session session = null;
684    
685                            try {
686                                    session = openSession();
687    
688                                    StringBundler query = new StringBundler(2);
689    
690                                    query.append(_SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE);
691    
692                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
693    
694                                    String sql = query.toString();
695    
696                                    Query q = session.createQuery(sql);
697    
698                                    QueryPos qPos = QueryPos.getInstance(q);
699    
700                                    qPos.add(assetEntryId);
701    
702                                    count = (Long)q.uniqueResult();
703                            }
704                            catch (Exception e) {
705                                    throw processException(e);
706                            }
707                            finally {
708                                    if (count == null) {
709                                            count = Long.valueOf(0);
710                                    }
711    
712                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
713                                            finderArgs, count);
714    
715                                    closeSession(session);
716                            }
717                    }
718    
719                    return count.intValue();
720            }
721    
722            /**
723             * Counts all the social equity asset entries.
724             *
725             * @return the number of social equity asset entries
726             * @throws SystemException if a system exception occurred
727             */
728            public int countAll() throws SystemException {
729                    Object[] finderArgs = new Object[0];
730    
731                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
732                                    finderArgs, this);
733    
734                    if (count == null) {
735                            Session session = null;
736    
737                            try {
738                                    session = openSession();
739    
740                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYASSETENTRY);
741    
742                                    count = (Long)q.uniqueResult();
743                            }
744                            catch (Exception e) {
745                                    throw processException(e);
746                            }
747                            finally {
748                                    if (count == null) {
749                                            count = Long.valueOf(0);
750                                    }
751    
752                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
753                                            count);
754    
755                                    closeSession(session);
756                            }
757                    }
758    
759                    return count.intValue();
760            }
761    
762            /**
763             * Initializes the social equity asset entry persistence.
764             */
765            public void afterPropertiesSet() {
766                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
767                                            com.liferay.portal.util.PropsUtil.get(
768                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquityAssetEntry")));
769    
770                    if (listenerClassNames.length > 0) {
771                            try {
772                                    List<ModelListener<SocialEquityAssetEntry>> listenersList = new ArrayList<ModelListener<SocialEquityAssetEntry>>();
773    
774                                    for (String listenerClassName : listenerClassNames) {
775                                            listenersList.add((ModelListener<SocialEquityAssetEntry>)InstanceFactory.newInstance(
776                                                            listenerClassName));
777                                    }
778    
779                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
780                            }
781                            catch (Exception e) {
782                                    _log.error(e);
783                            }
784                    }
785            }
786    
787            public void destroy() {
788                    EntityCacheUtil.removeCache(SocialEquityAssetEntryImpl.class.getName());
789                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_ENTITY);
790                    FinderCacheUtil.removeCache(FINDER_CLASS_NAME_LIST);
791            }
792    
793            @BeanReference(type = SocialActivityPersistence.class)
794            protected SocialActivityPersistence socialActivityPersistence;
795            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
796            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
797            @BeanReference(type = SocialEquityGroupSettingPersistence.class)
798            protected SocialEquityGroupSettingPersistence socialEquityGroupSettingPersistence;
799            @BeanReference(type = SocialEquityHistoryPersistence.class)
800            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
801            @BeanReference(type = SocialEquityLogPersistence.class)
802            protected SocialEquityLogPersistence socialEquityLogPersistence;
803            @BeanReference(type = SocialEquitySettingPersistence.class)
804            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
805            @BeanReference(type = SocialEquityUserPersistence.class)
806            protected SocialEquityUserPersistence socialEquityUserPersistence;
807            @BeanReference(type = SocialRelationPersistence.class)
808            protected SocialRelationPersistence socialRelationPersistence;
809            @BeanReference(type = SocialRequestPersistence.class)
810            protected SocialRequestPersistence socialRequestPersistence;
811            @BeanReference(type = ResourcePersistence.class)
812            protected ResourcePersistence resourcePersistence;
813            @BeanReference(type = UserPersistence.class)
814            protected UserPersistence userPersistence;
815            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry";
816            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
817            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry";
818            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
819            private static final String _FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2 = "socialEquityAssetEntry.assetEntryId = ?";
820            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquityAssetEntry.";
821            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquityAssetEntry exists with the primary key ";
822            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquityAssetEntry exists with the key {";
823            private static Log _log = LogFactoryUtil.getLog(SocialEquityAssetEntryPersistenceImpl.class);
824    }