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     * @author    Brian Wing Shun Chan
055     * @see       SocialEquityAssetEntryPersistence
056     * @see       SocialEquityAssetEntryUtil
057     * @generated
058     */
059    public class SocialEquityAssetEntryPersistenceImpl extends BasePersistenceImpl<SocialEquityAssetEntry>
060            implements SocialEquityAssetEntryPersistence {
061            public static final String FINDER_CLASS_NAME_ENTITY = SocialEquityAssetEntryImpl.class.getName();
062            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
063                    ".List";
064            public static final FinderPath FINDER_PATH_FETCH_BY_ASSETENTRYID = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
065                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
066                            FINDER_CLASS_NAME_ENTITY, "fetchByAssetEntryId",
067                            new String[] { Long.class.getName() });
068            public static final FinderPath FINDER_PATH_COUNT_BY_ASSETENTRYID = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
069                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
070                            FINDER_CLASS_NAME_LIST, "countByAssetEntryId",
071                            new String[] { Long.class.getName() });
072            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
073                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
074                            FINDER_CLASS_NAME_LIST, "findAll", new String[0]);
075            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
076                            SocialEquityAssetEntryModelImpl.FINDER_CACHE_ENABLED,
077                            FINDER_CLASS_NAME_LIST, "countAll", new String[0]);
078    
079            public void cacheResult(SocialEquityAssetEntry socialEquityAssetEntry) {
080                    EntityCacheUtil.putResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
081                            SocialEquityAssetEntryImpl.class,
082                            socialEquityAssetEntry.getPrimaryKey(), socialEquityAssetEntry);
083    
084                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
085                            new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) },
086                            socialEquityAssetEntry);
087            }
088    
089            public void cacheResult(
090                    List<SocialEquityAssetEntry> socialEquityAssetEntries) {
091                    for (SocialEquityAssetEntry socialEquityAssetEntry : socialEquityAssetEntries) {
092                            if (EntityCacheUtil.getResult(
093                                                    SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
094                                                    SocialEquityAssetEntryImpl.class,
095                                                    socialEquityAssetEntry.getPrimaryKey(), this) == null) {
096                                    cacheResult(socialEquityAssetEntry);
097                            }
098                    }
099            }
100    
101            public void clearCache() {
102                    CacheRegistryUtil.clear(SocialEquityAssetEntryImpl.class.getName());
103                    EntityCacheUtil.clearCache(SocialEquityAssetEntryImpl.class.getName());
104                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
105                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
106            }
107    
108            public void clearCache(SocialEquityAssetEntry socialEquityAssetEntry) {
109                    EntityCacheUtil.removeResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
110                            SocialEquityAssetEntryImpl.class,
111                            socialEquityAssetEntry.getPrimaryKey());
112    
113                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
114                            new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) });
115            }
116    
117            public SocialEquityAssetEntry create(long equityAssetEntryId) {
118                    SocialEquityAssetEntry socialEquityAssetEntry = new SocialEquityAssetEntryImpl();
119    
120                    socialEquityAssetEntry.setNew(true);
121                    socialEquityAssetEntry.setPrimaryKey(equityAssetEntryId);
122    
123                    return socialEquityAssetEntry;
124            }
125    
126            public SocialEquityAssetEntry remove(Serializable primaryKey)
127                    throws NoSuchModelException, SystemException {
128                    return remove(((Long)primaryKey).longValue());
129            }
130    
131            public SocialEquityAssetEntry remove(long equityAssetEntryId)
132                    throws NoSuchEquityAssetEntryException, SystemException {
133                    Session session = null;
134    
135                    try {
136                            session = openSession();
137    
138                            SocialEquityAssetEntry socialEquityAssetEntry = (SocialEquityAssetEntry)session.get(SocialEquityAssetEntryImpl.class,
139                                            new Long(equityAssetEntryId));
140    
141                            if (socialEquityAssetEntry == null) {
142                                    if (_log.isWarnEnabled()) {
143                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
144                                                    equityAssetEntryId);
145                                    }
146    
147                                    throw new NoSuchEquityAssetEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
148                                            equityAssetEntryId);
149                            }
150    
151                            return remove(socialEquityAssetEntry);
152                    }
153                    catch (NoSuchEquityAssetEntryException nsee) {
154                            throw nsee;
155                    }
156                    catch (Exception e) {
157                            throw processException(e);
158                    }
159                    finally {
160                            closeSession(session);
161                    }
162            }
163    
164            protected SocialEquityAssetEntry removeImpl(
165                    SocialEquityAssetEntry socialEquityAssetEntry)
166                    throws SystemException {
167                    socialEquityAssetEntry = toUnwrappedModel(socialEquityAssetEntry);
168    
169                    Session session = null;
170    
171                    try {
172                            session = openSession();
173    
174                            if (socialEquityAssetEntry.isCachedModel() ||
175                                            BatchSessionUtil.isEnabled()) {
176                                    Object staleObject = session.get(SocialEquityAssetEntryImpl.class,
177                                                    socialEquityAssetEntry.getPrimaryKeyObj());
178    
179                                    if (staleObject != null) {
180                                            session.evict(staleObject);
181                                    }
182                            }
183    
184                            session.delete(socialEquityAssetEntry);
185    
186                            session.flush();
187                    }
188                    catch (Exception e) {
189                            throw processException(e);
190                    }
191                    finally {
192                            closeSession(session);
193                    }
194    
195                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
196    
197                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
198    
199                    FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
200                            new Object[] {
201                                    new Long(socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())
202                            });
203    
204                    EntityCacheUtil.removeResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
205                            SocialEquityAssetEntryImpl.class,
206                            socialEquityAssetEntry.getPrimaryKey());
207    
208                    return socialEquityAssetEntry;
209            }
210    
211            public SocialEquityAssetEntry updateImpl(
212                    com.liferay.portlet.social.model.SocialEquityAssetEntry socialEquityAssetEntry,
213                    boolean merge) throws SystemException {
214                    socialEquityAssetEntry = toUnwrappedModel(socialEquityAssetEntry);
215    
216                    boolean isNew = socialEquityAssetEntry.isNew();
217    
218                    SocialEquityAssetEntryModelImpl socialEquityAssetEntryModelImpl = (SocialEquityAssetEntryModelImpl)socialEquityAssetEntry;
219    
220                    Session session = null;
221    
222                    try {
223                            session = openSession();
224    
225                            BatchSessionUtil.update(session, socialEquityAssetEntry, merge);
226    
227                            socialEquityAssetEntry.setNew(false);
228                    }
229                    catch (Exception e) {
230                            throw processException(e);
231                    }
232                    finally {
233                            closeSession(session);
234                    }
235    
236                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
237    
238                    EntityCacheUtil.putResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
239                            SocialEquityAssetEntryImpl.class,
240                            socialEquityAssetEntry.getPrimaryKey(), socialEquityAssetEntry);
241    
242                    if (!isNew &&
243                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
244                            FinderCacheUtil.removeResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
245                                    new Object[] {
246                                            new Long(socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())
247                                    });
248                    }
249    
250                    if (isNew ||
251                                    (socialEquityAssetEntry.getAssetEntryId() != socialEquityAssetEntryModelImpl.getOriginalAssetEntryId())) {
252                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
253                                    new Object[] { new Long(socialEquityAssetEntry.getAssetEntryId()) },
254                                    socialEquityAssetEntry);
255                    }
256    
257                    return socialEquityAssetEntry;
258            }
259    
260            protected SocialEquityAssetEntry toUnwrappedModel(
261                    SocialEquityAssetEntry socialEquityAssetEntry) {
262                    if (socialEquityAssetEntry instanceof SocialEquityAssetEntryImpl) {
263                            return socialEquityAssetEntry;
264                    }
265    
266                    SocialEquityAssetEntryImpl socialEquityAssetEntryImpl = new SocialEquityAssetEntryImpl();
267    
268                    socialEquityAssetEntryImpl.setNew(socialEquityAssetEntry.isNew());
269                    socialEquityAssetEntryImpl.setPrimaryKey(socialEquityAssetEntry.getPrimaryKey());
270    
271                    socialEquityAssetEntryImpl.setEquityAssetEntryId(socialEquityAssetEntry.getEquityAssetEntryId());
272                    socialEquityAssetEntryImpl.setGroupId(socialEquityAssetEntry.getGroupId());
273                    socialEquityAssetEntryImpl.setCompanyId(socialEquityAssetEntry.getCompanyId());
274                    socialEquityAssetEntryImpl.setUserId(socialEquityAssetEntry.getUserId());
275                    socialEquityAssetEntryImpl.setAssetEntryId(socialEquityAssetEntry.getAssetEntryId());
276                    socialEquityAssetEntryImpl.setInformationK(socialEquityAssetEntry.getInformationK());
277                    socialEquityAssetEntryImpl.setInformationB(socialEquityAssetEntry.getInformationB());
278    
279                    return socialEquityAssetEntryImpl;
280            }
281    
282            public SocialEquityAssetEntry findByPrimaryKey(Serializable primaryKey)
283                    throws NoSuchModelException, SystemException {
284                    return findByPrimaryKey(((Long)primaryKey).longValue());
285            }
286    
287            public SocialEquityAssetEntry findByPrimaryKey(long equityAssetEntryId)
288                    throws NoSuchEquityAssetEntryException, SystemException {
289                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByPrimaryKey(equityAssetEntryId);
290    
291                    if (socialEquityAssetEntry == null) {
292                            if (_log.isWarnEnabled()) {
293                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
294                                            equityAssetEntryId);
295                            }
296    
297                            throw new NoSuchEquityAssetEntryException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
298                                    equityAssetEntryId);
299                    }
300    
301                    return socialEquityAssetEntry;
302            }
303    
304            public SocialEquityAssetEntry fetchByPrimaryKey(Serializable primaryKey)
305                    throws SystemException {
306                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
307            }
308    
309            public SocialEquityAssetEntry fetchByPrimaryKey(long equityAssetEntryId)
310                    throws SystemException {
311                    SocialEquityAssetEntry socialEquityAssetEntry = (SocialEquityAssetEntry)EntityCacheUtil.getResult(SocialEquityAssetEntryModelImpl.ENTITY_CACHE_ENABLED,
312                                    SocialEquityAssetEntryImpl.class, equityAssetEntryId, this);
313    
314                    if (socialEquityAssetEntry == null) {
315                            Session session = null;
316    
317                            try {
318                                    session = openSession();
319    
320                                    socialEquityAssetEntry = (SocialEquityAssetEntry)session.get(SocialEquityAssetEntryImpl.class,
321                                                    new Long(equityAssetEntryId));
322                            }
323                            catch (Exception e) {
324                                    throw processException(e);
325                            }
326                            finally {
327                                    if (socialEquityAssetEntry != null) {
328                                            cacheResult(socialEquityAssetEntry);
329                                    }
330    
331                                    closeSession(session);
332                            }
333                    }
334    
335                    return socialEquityAssetEntry;
336            }
337    
338            public SocialEquityAssetEntry findByAssetEntryId(long assetEntryId)
339                    throws NoSuchEquityAssetEntryException, SystemException {
340                    SocialEquityAssetEntry socialEquityAssetEntry = fetchByAssetEntryId(assetEntryId);
341    
342                    if (socialEquityAssetEntry == null) {
343                            StringBundler msg = new StringBundler(4);
344    
345                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
346    
347                            msg.append("assetEntryId=");
348                            msg.append(assetEntryId);
349    
350                            msg.append(StringPool.CLOSE_CURLY_BRACE);
351    
352                            if (_log.isWarnEnabled()) {
353                                    _log.warn(msg.toString());
354                            }
355    
356                            throw new NoSuchEquityAssetEntryException(msg.toString());
357                    }
358    
359                    return socialEquityAssetEntry;
360            }
361    
362            public SocialEquityAssetEntry fetchByAssetEntryId(long assetEntryId)
363                    throws SystemException {
364                    return fetchByAssetEntryId(assetEntryId, true);
365            }
366    
367            public SocialEquityAssetEntry fetchByAssetEntryId(long assetEntryId,
368                    boolean retrieveFromCache) throws SystemException {
369                    Object[] finderArgs = new Object[] { assetEntryId };
370    
371                    Object result = null;
372    
373                    if (retrieveFromCache) {
374                            result = FinderCacheUtil.getResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
375                                            finderArgs, this);
376                    }
377    
378                    if (result == null) {
379                            Session session = null;
380    
381                            try {
382                                    session = openSession();
383    
384                                    StringBundler query = new StringBundler(2);
385    
386                                    query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE);
387    
388                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
389    
390                                    String sql = query.toString();
391    
392                                    Query q = session.createQuery(sql);
393    
394                                    QueryPos qPos = QueryPos.getInstance(q);
395    
396                                    qPos.add(assetEntryId);
397    
398                                    List<SocialEquityAssetEntry> list = q.list();
399    
400                                    result = list;
401    
402                                    SocialEquityAssetEntry socialEquityAssetEntry = null;
403    
404                                    if (list.isEmpty()) {
405                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
406                                                    finderArgs, list);
407                                    }
408                                    else {
409                                            socialEquityAssetEntry = list.get(0);
410    
411                                            cacheResult(socialEquityAssetEntry);
412    
413                                            if ((socialEquityAssetEntry.getAssetEntryId() != assetEntryId)) {
414                                                    FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
415                                                            finderArgs, socialEquityAssetEntry);
416                                            }
417                                    }
418    
419                                    return socialEquityAssetEntry;
420                            }
421                            catch (Exception e) {
422                                    throw processException(e);
423                            }
424                            finally {
425                                    if (result == null) {
426                                            FinderCacheUtil.putResult(FINDER_PATH_FETCH_BY_ASSETENTRYID,
427                                                    finderArgs, new ArrayList<SocialEquityAssetEntry>());
428                                    }
429    
430                                    closeSession(session);
431                            }
432                    }
433                    else {
434                            if (result instanceof List<?>) {
435                                    return null;
436                            }
437                            else {
438                                    return (SocialEquityAssetEntry)result;
439                            }
440                    }
441            }
442    
443            public List<SocialEquityAssetEntry> findAll() throws SystemException {
444                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
445            }
446    
447            public List<SocialEquityAssetEntry> findAll(int start, int end)
448                    throws SystemException {
449                    return findAll(start, end, null);
450            }
451    
452            public List<SocialEquityAssetEntry> findAll(int start, int end,
453                    OrderByComparator orderByComparator) throws SystemException {
454                    Object[] finderArgs = new Object[] {
455                                    String.valueOf(start), String.valueOf(end),
456                                    String.valueOf(orderByComparator)
457                            };
458    
459                    List<SocialEquityAssetEntry> list = (List<SocialEquityAssetEntry>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
460                                    finderArgs, this);
461    
462                    if (list == null) {
463                            Session session = null;
464    
465                            try {
466                                    session = openSession();
467    
468                                    StringBundler query = null;
469                                    String sql = null;
470    
471                                    if (orderByComparator != null) {
472                                            query = new StringBundler(2 +
473                                                            (orderByComparator.getOrderByFields().length * 3));
474    
475                                            query.append(_SQL_SELECT_SOCIALEQUITYASSETENTRY);
476    
477                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
478                                                    orderByComparator);
479    
480                                            sql = query.toString();
481                                    }
482                                    else {
483                                            sql = _SQL_SELECT_SOCIALEQUITYASSETENTRY;
484                                    }
485    
486                                    Query q = session.createQuery(sql);
487    
488                                    if (orderByComparator == null) {
489                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
490                                                            getDialect(), start, end, false);
491    
492                                            Collections.sort(list);
493                                    }
494                                    else {
495                                            list = (List<SocialEquityAssetEntry>)QueryUtil.list(q,
496                                                            getDialect(), start, end);
497                                    }
498                            }
499                            catch (Exception e) {
500                                    throw processException(e);
501                            }
502                            finally {
503                                    if (list == null) {
504                                            list = new ArrayList<SocialEquityAssetEntry>();
505                                    }
506    
507                                    cacheResult(list);
508    
509                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
510    
511                                    closeSession(session);
512                            }
513                    }
514    
515                    return list;
516            }
517    
518            public void removeByAssetEntryId(long assetEntryId)
519                    throws NoSuchEquityAssetEntryException, SystemException {
520                    SocialEquityAssetEntry socialEquityAssetEntry = findByAssetEntryId(assetEntryId);
521    
522                    remove(socialEquityAssetEntry);
523            }
524    
525            public void removeAll() throws SystemException {
526                    for (SocialEquityAssetEntry socialEquityAssetEntry : findAll()) {
527                            remove(socialEquityAssetEntry);
528                    }
529            }
530    
531            public int countByAssetEntryId(long assetEntryId) throws SystemException {
532                    Object[] finderArgs = new Object[] { assetEntryId };
533    
534                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
535                                    finderArgs, this);
536    
537                    if (count == null) {
538                            Session session = null;
539    
540                            try {
541                                    session = openSession();
542    
543                                    StringBundler query = new StringBundler(2);
544    
545                                    query.append(_SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE);
546    
547                                    query.append(_FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2);
548    
549                                    String sql = query.toString();
550    
551                                    Query q = session.createQuery(sql);
552    
553                                    QueryPos qPos = QueryPos.getInstance(q);
554    
555                                    qPos.add(assetEntryId);
556    
557                                    count = (Long)q.uniqueResult();
558                            }
559                            catch (Exception e) {
560                                    throw processException(e);
561                            }
562                            finally {
563                                    if (count == null) {
564                                            count = Long.valueOf(0);
565                                    }
566    
567                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ASSETENTRYID,
568                                            finderArgs, count);
569    
570                                    closeSession(session);
571                            }
572                    }
573    
574                    return count.intValue();
575            }
576    
577            public int countAll() throws SystemException {
578                    Object[] finderArgs = new Object[0];
579    
580                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
581                                    finderArgs, this);
582    
583                    if (count == null) {
584                            Session session = null;
585    
586                            try {
587                                    session = openSession();
588    
589                                    Query q = session.createQuery(_SQL_COUNT_SOCIALEQUITYASSETENTRY);
590    
591                                    count = (Long)q.uniqueResult();
592                            }
593                            catch (Exception e) {
594                                    throw processException(e);
595                            }
596                            finally {
597                                    if (count == null) {
598                                            count = Long.valueOf(0);
599                                    }
600    
601                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
602                                            count);
603    
604                                    closeSession(session);
605                            }
606                    }
607    
608                    return count.intValue();
609            }
610    
611            public void afterPropertiesSet() {
612                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
613                                            com.liferay.portal.util.PropsUtil.get(
614                                                    "value.object.listener.com.liferay.portlet.social.model.SocialEquityAssetEntry")));
615    
616                    if (listenerClassNames.length > 0) {
617                            try {
618                                    List<ModelListener<SocialEquityAssetEntry>> listenersList = new ArrayList<ModelListener<SocialEquityAssetEntry>>();
619    
620                                    for (String listenerClassName : listenerClassNames) {
621                                            listenersList.add((ModelListener<SocialEquityAssetEntry>)InstanceFactory.newInstance(
622                                                            listenerClassName));
623                                    }
624    
625                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
626                            }
627                            catch (Exception e) {
628                                    _log.error(e);
629                            }
630                    }
631            }
632    
633            @BeanReference(type = SocialActivityPersistence.class)
634            protected SocialActivityPersistence socialActivityPersistence;
635            @BeanReference(type = SocialEquityAssetEntryPersistence.class)
636            protected SocialEquityAssetEntryPersistence socialEquityAssetEntryPersistence;
637            @BeanReference(type = SocialEquityHistoryPersistence.class)
638            protected SocialEquityHistoryPersistence socialEquityHistoryPersistence;
639            @BeanReference(type = SocialEquityLogPersistence.class)
640            protected SocialEquityLogPersistence socialEquityLogPersistence;
641            @BeanReference(type = SocialEquitySettingPersistence.class)
642            protected SocialEquitySettingPersistence socialEquitySettingPersistence;
643            @BeanReference(type = SocialEquityUserPersistence.class)
644            protected SocialEquityUserPersistence socialEquityUserPersistence;
645            @BeanReference(type = SocialRelationPersistence.class)
646            protected SocialRelationPersistence socialRelationPersistence;
647            @BeanReference(type = SocialRequestPersistence.class)
648            protected SocialRequestPersistence socialRequestPersistence;
649            @BeanReference(type = ResourcePersistence.class)
650            protected ResourcePersistence resourcePersistence;
651            @BeanReference(type = UserPersistence.class)
652            protected UserPersistence userPersistence;
653            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry";
654            private static final String _SQL_SELECT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT socialEquityAssetEntry FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
655            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry";
656            private static final String _SQL_COUNT_SOCIALEQUITYASSETENTRY_WHERE = "SELECT COUNT(socialEquityAssetEntry) FROM SocialEquityAssetEntry socialEquityAssetEntry WHERE ";
657            private static final String _FINDER_COLUMN_ASSETENTRYID_ASSETENTRYID_2 = "socialEquityAssetEntry.assetEntryId = ?";
658            private static final String _ORDER_BY_ENTITY_ALIAS = "socialEquityAssetEntry.";
659            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No SocialEquityAssetEntry exists with the primary key ";
660            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No SocialEquityAssetEntry exists with the key {";
661            private static Log _log = LogFactoryUtil.getLog(SocialEquityAssetEntryPersistenceImpl.class);
662    }