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.portal.service.persistence;
016    
017    import com.liferay.portal.NoSuchModelException;
018    import com.liferay.portal.NoSuchOrgLaborException;
019    import com.liferay.portal.kernel.annotation.BeanReference;
020    import com.liferay.portal.kernel.cache.CacheRegistryUtil;
021    import com.liferay.portal.kernel.dao.orm.EntityCacheUtil;
022    import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
023    import com.liferay.portal.kernel.dao.orm.FinderPath;
024    import com.liferay.portal.kernel.dao.orm.Query;
025    import com.liferay.portal.kernel.dao.orm.QueryPos;
026    import com.liferay.portal.kernel.dao.orm.QueryUtil;
027    import com.liferay.portal.kernel.dao.orm.Session;
028    import com.liferay.portal.kernel.exception.SystemException;
029    import com.liferay.portal.kernel.log.Log;
030    import com.liferay.portal.kernel.log.LogFactoryUtil;
031    import com.liferay.portal.kernel.util.GetterUtil;
032    import com.liferay.portal.kernel.util.InstanceFactory;
033    import com.liferay.portal.kernel.util.OrderByComparator;
034    import com.liferay.portal.kernel.util.StringBundler;
035    import com.liferay.portal.kernel.util.StringPool;
036    import com.liferay.portal.kernel.util.StringUtil;
037    import com.liferay.portal.model.ModelListener;
038    import com.liferay.portal.model.OrgLabor;
039    import com.liferay.portal.model.impl.OrgLaborImpl;
040    import com.liferay.portal.model.impl.OrgLaborModelImpl;
041    import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
042    
043    import java.io.Serializable;
044    
045    import java.util.ArrayList;
046    import java.util.Collections;
047    import java.util.List;
048    
049    /**
050     * @author    Brian Wing Shun Chan
051     * @see       OrgLaborPersistence
052     * @see       OrgLaborUtil
053     * @generated
054     */
055    public class OrgLaborPersistenceImpl extends BasePersistenceImpl<OrgLabor>
056            implements OrgLaborPersistence {
057            public static final String FINDER_CLASS_NAME_ENTITY = OrgLaborImpl.class.getName();
058            public static final String FINDER_CLASS_NAME_LIST = FINDER_CLASS_NAME_ENTITY +
059                    ".List";
060            public static final FinderPath FINDER_PATH_FIND_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
061                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
062                            "findByOrganizationId",
063                            new String[] {
064                                    Long.class.getName(),
065                                    
066                            "java.lang.Integer", "java.lang.Integer",
067                                    "com.liferay.portal.kernel.util.OrderByComparator"
068                            });
069            public static final FinderPath FINDER_PATH_COUNT_BY_ORGANIZATIONID = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
070                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
071                            "countByOrganizationId", new String[] { Long.class.getName() });
072            public static final FinderPath FINDER_PATH_FIND_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
073                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
074                            "findAll", new String[0]);
075            public static final FinderPath FINDER_PATH_COUNT_ALL = new FinderPath(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
076                            OrgLaborModelImpl.FINDER_CACHE_ENABLED, FINDER_CLASS_NAME_LIST,
077                            "countAll", new String[0]);
078    
079            public void cacheResult(OrgLabor orgLabor) {
080                    EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
081                            OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
082            }
083    
084            public void cacheResult(List<OrgLabor> orgLabors) {
085                    for (OrgLabor orgLabor : orgLabors) {
086                            if (EntityCacheUtil.getResult(
087                                                    OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
088                                                    OrgLaborImpl.class, orgLabor.getPrimaryKey(), this) == null) {
089                                    cacheResult(orgLabor);
090                            }
091                    }
092            }
093    
094            public void clearCache() {
095                    CacheRegistryUtil.clear(OrgLaborImpl.class.getName());
096                    EntityCacheUtil.clearCache(OrgLaborImpl.class.getName());
097                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_ENTITY);
098                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
099            }
100    
101            public void clearCache(OrgLabor orgLabor) {
102                    EntityCacheUtil.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
103                            OrgLaborImpl.class, orgLabor.getPrimaryKey());
104            }
105    
106            public OrgLabor create(long orgLaborId) {
107                    OrgLabor orgLabor = new OrgLaborImpl();
108    
109                    orgLabor.setNew(true);
110                    orgLabor.setPrimaryKey(orgLaborId);
111    
112                    return orgLabor;
113            }
114    
115            public OrgLabor remove(Serializable primaryKey)
116                    throws NoSuchModelException, SystemException {
117                    return remove(((Long)primaryKey).longValue());
118            }
119    
120            public OrgLabor remove(long orgLaborId)
121                    throws NoSuchOrgLaborException, SystemException {
122                    Session session = null;
123    
124                    try {
125                            session = openSession();
126    
127                            OrgLabor orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
128                                            new Long(orgLaborId));
129    
130                            if (orgLabor == null) {
131                                    if (_log.isWarnEnabled()) {
132                                            _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
133                                    }
134    
135                                    throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
136                                            orgLaborId);
137                            }
138    
139                            return remove(orgLabor);
140                    }
141                    catch (NoSuchOrgLaborException nsee) {
142                            throw nsee;
143                    }
144                    catch (Exception e) {
145                            throw processException(e);
146                    }
147                    finally {
148                            closeSession(session);
149                    }
150            }
151    
152            protected OrgLabor removeImpl(OrgLabor orgLabor) throws SystemException {
153                    orgLabor = toUnwrappedModel(orgLabor);
154    
155                    Session session = null;
156    
157                    try {
158                            session = openSession();
159    
160                            if (orgLabor.isCachedModel() || BatchSessionUtil.isEnabled()) {
161                                    Object staleObject = session.get(OrgLaborImpl.class,
162                                                    orgLabor.getPrimaryKeyObj());
163    
164                                    if (staleObject != null) {
165                                            session.evict(staleObject);
166                                    }
167                            }
168    
169                            session.delete(orgLabor);
170    
171                            session.flush();
172                    }
173                    catch (Exception e) {
174                            throw processException(e);
175                    }
176                    finally {
177                            closeSession(session);
178                    }
179    
180                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
181    
182                    EntityCacheUtil.removeResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
183                            OrgLaborImpl.class, orgLabor.getPrimaryKey());
184    
185                    return orgLabor;
186            }
187    
188            public OrgLabor updateImpl(com.liferay.portal.model.OrgLabor orgLabor,
189                    boolean merge) throws SystemException {
190                    orgLabor = toUnwrappedModel(orgLabor);
191    
192                    Session session = null;
193    
194                    try {
195                            session = openSession();
196    
197                            BatchSessionUtil.update(session, orgLabor, merge);
198    
199                            orgLabor.setNew(false);
200                    }
201                    catch (Exception e) {
202                            throw processException(e);
203                    }
204                    finally {
205                            closeSession(session);
206                    }
207    
208                    FinderCacheUtil.clearCache(FINDER_CLASS_NAME_LIST);
209    
210                    EntityCacheUtil.putResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
211                            OrgLaborImpl.class, orgLabor.getPrimaryKey(), orgLabor);
212    
213                    return orgLabor;
214            }
215    
216            protected OrgLabor toUnwrappedModel(OrgLabor orgLabor) {
217                    if (orgLabor instanceof OrgLaborImpl) {
218                            return orgLabor;
219                    }
220    
221                    OrgLaborImpl orgLaborImpl = new OrgLaborImpl();
222    
223                    orgLaborImpl.setNew(orgLabor.isNew());
224                    orgLaborImpl.setPrimaryKey(orgLabor.getPrimaryKey());
225    
226                    orgLaborImpl.setOrgLaborId(orgLabor.getOrgLaborId());
227                    orgLaborImpl.setOrganizationId(orgLabor.getOrganizationId());
228                    orgLaborImpl.setTypeId(orgLabor.getTypeId());
229                    orgLaborImpl.setSunOpen(orgLabor.getSunOpen());
230                    orgLaborImpl.setSunClose(orgLabor.getSunClose());
231                    orgLaborImpl.setMonOpen(orgLabor.getMonOpen());
232                    orgLaborImpl.setMonClose(orgLabor.getMonClose());
233                    orgLaborImpl.setTueOpen(orgLabor.getTueOpen());
234                    orgLaborImpl.setTueClose(orgLabor.getTueClose());
235                    orgLaborImpl.setWedOpen(orgLabor.getWedOpen());
236                    orgLaborImpl.setWedClose(orgLabor.getWedClose());
237                    orgLaborImpl.setThuOpen(orgLabor.getThuOpen());
238                    orgLaborImpl.setThuClose(orgLabor.getThuClose());
239                    orgLaborImpl.setFriOpen(orgLabor.getFriOpen());
240                    orgLaborImpl.setFriClose(orgLabor.getFriClose());
241                    orgLaborImpl.setSatOpen(orgLabor.getSatOpen());
242                    orgLaborImpl.setSatClose(orgLabor.getSatClose());
243    
244                    return orgLaborImpl;
245            }
246    
247            public OrgLabor findByPrimaryKey(Serializable primaryKey)
248                    throws NoSuchModelException, SystemException {
249                    return findByPrimaryKey(((Long)primaryKey).longValue());
250            }
251    
252            public OrgLabor findByPrimaryKey(long orgLaborId)
253                    throws NoSuchOrgLaborException, SystemException {
254                    OrgLabor orgLabor = fetchByPrimaryKey(orgLaborId);
255    
256                    if (orgLabor == null) {
257                            if (_log.isWarnEnabled()) {
258                                    _log.warn(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY + orgLaborId);
259                            }
260    
261                            throw new NoSuchOrgLaborException(_NO_SUCH_ENTITY_WITH_PRIMARY_KEY +
262                                    orgLaborId);
263                    }
264    
265                    return orgLabor;
266            }
267    
268            public OrgLabor fetchByPrimaryKey(Serializable primaryKey)
269                    throws SystemException {
270                    return fetchByPrimaryKey(((Long)primaryKey).longValue());
271            }
272    
273            public OrgLabor fetchByPrimaryKey(long orgLaborId)
274                    throws SystemException {
275                    OrgLabor orgLabor = (OrgLabor)EntityCacheUtil.getResult(OrgLaborModelImpl.ENTITY_CACHE_ENABLED,
276                                    OrgLaborImpl.class, orgLaborId, this);
277    
278                    if (orgLabor == null) {
279                            Session session = null;
280    
281                            try {
282                                    session = openSession();
283    
284                                    orgLabor = (OrgLabor)session.get(OrgLaborImpl.class,
285                                                    new Long(orgLaborId));
286                            }
287                            catch (Exception e) {
288                                    throw processException(e);
289                            }
290                            finally {
291                                    if (orgLabor != null) {
292                                            cacheResult(orgLabor);
293                                    }
294    
295                                    closeSession(session);
296                            }
297                    }
298    
299                    return orgLabor;
300            }
301    
302            public List<OrgLabor> findByOrganizationId(long organizationId)
303                    throws SystemException {
304                    return findByOrganizationId(organizationId, QueryUtil.ALL_POS,
305                            QueryUtil.ALL_POS, null);
306            }
307    
308            public List<OrgLabor> findByOrganizationId(long organizationId, int start,
309                    int end) throws SystemException {
310                    return findByOrganizationId(organizationId, start, end, null);
311            }
312    
313            public List<OrgLabor> findByOrganizationId(long organizationId, int start,
314                    int end, OrderByComparator orderByComparator) throws SystemException {
315                    Object[] finderArgs = new Object[] {
316                                    organizationId,
317                                    
318                                    String.valueOf(start), String.valueOf(end),
319                                    String.valueOf(orderByComparator)
320                            };
321    
322                    List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
323                                    finderArgs, this);
324    
325                    if (list == null) {
326                            Session session = null;
327    
328                            try {
329                                    session = openSession();
330    
331                                    StringBundler query = null;
332    
333                                    if (orderByComparator != null) {
334                                            query = new StringBundler(3 +
335                                                            (orderByComparator.getOrderByFields().length * 3));
336                                    }
337                                    else {
338                                            query = new StringBundler(3);
339                                    }
340    
341                                    query.append(_SQL_SELECT_ORGLABOR_WHERE);
342    
343                                    query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
344    
345                                    if (orderByComparator != null) {
346                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
347                                                    orderByComparator);
348                                    }
349    
350                                    else {
351                                            query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
352                                    }
353    
354                                    String sql = query.toString();
355    
356                                    Query q = session.createQuery(sql);
357    
358                                    QueryPos qPos = QueryPos.getInstance(q);
359    
360                                    qPos.add(organizationId);
361    
362                                    list = (List<OrgLabor>)QueryUtil.list(q, getDialect(), start,
363                                                    end);
364                            }
365                            catch (Exception e) {
366                                    throw processException(e);
367                            }
368                            finally {
369                                    if (list == null) {
370                                            list = new ArrayList<OrgLabor>();
371                                    }
372    
373                                    cacheResult(list);
374    
375                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_BY_ORGANIZATIONID,
376                                            finderArgs, list);
377    
378                                    closeSession(session);
379                            }
380                    }
381    
382                    return list;
383            }
384    
385            public OrgLabor findByOrganizationId_First(long organizationId,
386                    OrderByComparator orderByComparator)
387                    throws NoSuchOrgLaborException, SystemException {
388                    List<OrgLabor> list = findByOrganizationId(organizationId, 0, 1,
389                                    orderByComparator);
390    
391                    if (list.isEmpty()) {
392                            StringBundler msg = new StringBundler(4);
393    
394                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
395    
396                            msg.append("organizationId=");
397                            msg.append(organizationId);
398    
399                            msg.append(StringPool.CLOSE_CURLY_BRACE);
400    
401                            throw new NoSuchOrgLaborException(msg.toString());
402                    }
403                    else {
404                            return list.get(0);
405                    }
406            }
407    
408            public OrgLabor findByOrganizationId_Last(long organizationId,
409                    OrderByComparator orderByComparator)
410                    throws NoSuchOrgLaborException, SystemException {
411                    int count = countByOrganizationId(organizationId);
412    
413                    List<OrgLabor> list = findByOrganizationId(organizationId, count - 1,
414                                    count, orderByComparator);
415    
416                    if (list.isEmpty()) {
417                            StringBundler msg = new StringBundler(4);
418    
419                            msg.append(_NO_SUCH_ENTITY_WITH_KEY);
420    
421                            msg.append("organizationId=");
422                            msg.append(organizationId);
423    
424                            msg.append(StringPool.CLOSE_CURLY_BRACE);
425    
426                            throw new NoSuchOrgLaborException(msg.toString());
427                    }
428                    else {
429                            return list.get(0);
430                    }
431            }
432    
433            public OrgLabor[] findByOrganizationId_PrevAndNext(long orgLaborId,
434                    long organizationId, OrderByComparator orderByComparator)
435                    throws NoSuchOrgLaborException, SystemException {
436                    OrgLabor orgLabor = findByPrimaryKey(orgLaborId);
437    
438                    Session session = null;
439    
440                    try {
441                            session = openSession();
442    
443                            OrgLabor[] array = new OrgLaborImpl[3];
444    
445                            array[0] = getByOrganizationId_PrevAndNext(session, orgLabor,
446                                            organizationId, orderByComparator, true);
447    
448                            array[1] = orgLabor;
449    
450                            array[2] = getByOrganizationId_PrevAndNext(session, orgLabor,
451                                            organizationId, orderByComparator, false);
452    
453                            return array;
454                    }
455                    catch (Exception e) {
456                            throw processException(e);
457                    }
458                    finally {
459                            closeSession(session);
460                    }
461            }
462    
463            protected OrgLabor getByOrganizationId_PrevAndNext(Session session,
464                    OrgLabor orgLabor, long organizationId,
465                    OrderByComparator orderByComparator, boolean previous) {
466                    StringBundler query = null;
467    
468                    if (orderByComparator != null) {
469                            query = new StringBundler(6 +
470                                            (orderByComparator.getOrderByFields().length * 6));
471                    }
472                    else {
473                            query = new StringBundler(3);
474                    }
475    
476                    query.append(_SQL_SELECT_ORGLABOR_WHERE);
477    
478                    query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
479    
480                    if (orderByComparator != null) {
481                            String[] orderByFields = orderByComparator.getOrderByFields();
482    
483                            if (orderByFields.length > 0) {
484                                    query.append(WHERE_AND);
485                            }
486    
487                            for (int i = 0; i < orderByFields.length; i++) {
488                                    query.append(_ORDER_BY_ENTITY_ALIAS);
489                                    query.append(orderByFields[i]);
490    
491                                    if ((i + 1) < orderByFields.length) {
492                                            if (orderByComparator.isAscending() ^ previous) {
493                                                    query.append(WHERE_GREATER_THAN_HAS_NEXT);
494                                            }
495                                            else {
496                                                    query.append(WHERE_LESSER_THAN_HAS_NEXT);
497                                            }
498                                    }
499                                    else {
500                                            if (orderByComparator.isAscending() ^ previous) {
501                                                    query.append(WHERE_GREATER_THAN);
502                                            }
503                                            else {
504                                                    query.append(WHERE_LESSER_THAN);
505                                            }
506                                    }
507                            }
508    
509                            query.append(ORDER_BY_CLAUSE);
510    
511                            for (int i = 0; i < orderByFields.length; i++) {
512                                    query.append(_ORDER_BY_ENTITY_ALIAS);
513                                    query.append(orderByFields[i]);
514    
515                                    if ((i + 1) < orderByFields.length) {
516                                            if (orderByComparator.isAscending() ^ previous) {
517                                                    query.append(ORDER_BY_ASC_HAS_NEXT);
518                                            }
519                                            else {
520                                                    query.append(ORDER_BY_DESC_HAS_NEXT);
521                                            }
522                                    }
523                                    else {
524                                            if (orderByComparator.isAscending() ^ previous) {
525                                                    query.append(ORDER_BY_ASC);
526                                            }
527                                            else {
528                                                    query.append(ORDER_BY_DESC);
529                                            }
530                                    }
531                            }
532                    }
533    
534                    else {
535                            query.append(OrgLaborModelImpl.ORDER_BY_JPQL);
536                    }
537    
538                    String sql = query.toString();
539    
540                    Query q = session.createQuery(sql);
541    
542                    q.setFirstResult(0);
543                    q.setMaxResults(2);
544    
545                    QueryPos qPos = QueryPos.getInstance(q);
546    
547                    qPos.add(organizationId);
548    
549                    if (orderByComparator != null) {
550                            Object[] values = orderByComparator.getOrderByValues(orgLabor);
551    
552                            for (Object value : values) {
553                                    qPos.add(value);
554                            }
555                    }
556    
557                    List<OrgLabor> list = q.list();
558    
559                    if (list.size() == 2) {
560                            return list.get(1);
561                    }
562                    else {
563                            return null;
564                    }
565            }
566    
567            public List<OrgLabor> findAll() throws SystemException {
568                    return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
569            }
570    
571            public List<OrgLabor> findAll(int start, int end) throws SystemException {
572                    return findAll(start, end, null);
573            }
574    
575            public List<OrgLabor> findAll(int start, int end,
576                    OrderByComparator orderByComparator) throws SystemException {
577                    Object[] finderArgs = new Object[] {
578                                    String.valueOf(start), String.valueOf(end),
579                                    String.valueOf(orderByComparator)
580                            };
581    
582                    List<OrgLabor> list = (List<OrgLabor>)FinderCacheUtil.getResult(FINDER_PATH_FIND_ALL,
583                                    finderArgs, this);
584    
585                    if (list == null) {
586                            Session session = null;
587    
588                            try {
589                                    session = openSession();
590    
591                                    StringBundler query = null;
592                                    String sql = null;
593    
594                                    if (orderByComparator != null) {
595                                            query = new StringBundler(2 +
596                                                            (orderByComparator.getOrderByFields().length * 3));
597    
598                                            query.append(_SQL_SELECT_ORGLABOR);
599    
600                                            appendOrderByComparator(query, _ORDER_BY_ENTITY_ALIAS,
601                                                    orderByComparator);
602    
603                                            sql = query.toString();
604                                    }
605                                    else {
606                                            sql = _SQL_SELECT_ORGLABOR.concat(OrgLaborModelImpl.ORDER_BY_JPQL);
607                                    }
608    
609                                    Query q = session.createQuery(sql);
610    
611                                    if (orderByComparator == null) {
612                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
613                                                            start, end, false);
614    
615                                            Collections.sort(list);
616                                    }
617                                    else {
618                                            list = (List<OrgLabor>)QueryUtil.list(q, getDialect(),
619                                                            start, end);
620                                    }
621                            }
622                            catch (Exception e) {
623                                    throw processException(e);
624                            }
625                            finally {
626                                    if (list == null) {
627                                            list = new ArrayList<OrgLabor>();
628                                    }
629    
630                                    cacheResult(list);
631    
632                                    FinderCacheUtil.putResult(FINDER_PATH_FIND_ALL, finderArgs, list);
633    
634                                    closeSession(session);
635                            }
636                    }
637    
638                    return list;
639            }
640    
641            public void removeByOrganizationId(long organizationId)
642                    throws SystemException {
643                    for (OrgLabor orgLabor : findByOrganizationId(organizationId)) {
644                            remove(orgLabor);
645                    }
646            }
647    
648            public void removeAll() throws SystemException {
649                    for (OrgLabor orgLabor : findAll()) {
650                            remove(orgLabor);
651                    }
652            }
653    
654            public int countByOrganizationId(long organizationId)
655                    throws SystemException {
656                    Object[] finderArgs = new Object[] { organizationId };
657    
658                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
659                                    finderArgs, this);
660    
661                    if (count == null) {
662                            Session session = null;
663    
664                            try {
665                                    session = openSession();
666    
667                                    StringBundler query = new StringBundler(2);
668    
669                                    query.append(_SQL_COUNT_ORGLABOR_WHERE);
670    
671                                    query.append(_FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2);
672    
673                                    String sql = query.toString();
674    
675                                    Query q = session.createQuery(sql);
676    
677                                    QueryPos qPos = QueryPos.getInstance(q);
678    
679                                    qPos.add(organizationId);
680    
681                                    count = (Long)q.uniqueResult();
682                            }
683                            catch (Exception e) {
684                                    throw processException(e);
685                            }
686                            finally {
687                                    if (count == null) {
688                                            count = Long.valueOf(0);
689                                    }
690    
691                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_BY_ORGANIZATIONID,
692                                            finderArgs, count);
693    
694                                    closeSession(session);
695                            }
696                    }
697    
698                    return count.intValue();
699            }
700    
701            public int countAll() throws SystemException {
702                    Object[] finderArgs = new Object[0];
703    
704                    Long count = (Long)FinderCacheUtil.getResult(FINDER_PATH_COUNT_ALL,
705                                    finderArgs, this);
706    
707                    if (count == null) {
708                            Session session = null;
709    
710                            try {
711                                    session = openSession();
712    
713                                    Query q = session.createQuery(_SQL_COUNT_ORGLABOR);
714    
715                                    count = (Long)q.uniqueResult();
716                            }
717                            catch (Exception e) {
718                                    throw processException(e);
719                            }
720                            finally {
721                                    if (count == null) {
722                                            count = Long.valueOf(0);
723                                    }
724    
725                                    FinderCacheUtil.putResult(FINDER_PATH_COUNT_ALL, finderArgs,
726                                            count);
727    
728                                    closeSession(session);
729                            }
730                    }
731    
732                    return count.intValue();
733            }
734    
735            public void afterPropertiesSet() {
736                    String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
737                                            com.liferay.portal.util.PropsUtil.get(
738                                                    "value.object.listener.com.liferay.portal.model.OrgLabor")));
739    
740                    if (listenerClassNames.length > 0) {
741                            try {
742                                    List<ModelListener<OrgLabor>> listenersList = new ArrayList<ModelListener<OrgLabor>>();
743    
744                                    for (String listenerClassName : listenerClassNames) {
745                                            listenersList.add((ModelListener<OrgLabor>)InstanceFactory.newInstance(
746                                                            listenerClassName));
747                                    }
748    
749                                    listeners = listenersList.toArray(new ModelListener[listenersList.size()]);
750                            }
751                            catch (Exception e) {
752                                    _log.error(e);
753                            }
754                    }
755            }
756    
757            @BeanReference(type = AccountPersistence.class)
758            protected AccountPersistence accountPersistence;
759            @BeanReference(type = AddressPersistence.class)
760            protected AddressPersistence addressPersistence;
761            @BeanReference(type = BrowserTrackerPersistence.class)
762            protected BrowserTrackerPersistence browserTrackerPersistence;
763            @BeanReference(type = ClassNamePersistence.class)
764            protected ClassNamePersistence classNamePersistence;
765            @BeanReference(type = CompanyPersistence.class)
766            protected CompanyPersistence companyPersistence;
767            @BeanReference(type = ContactPersistence.class)
768            protected ContactPersistence contactPersistence;
769            @BeanReference(type = CountryPersistence.class)
770            protected CountryPersistence countryPersistence;
771            @BeanReference(type = EmailAddressPersistence.class)
772            protected EmailAddressPersistence emailAddressPersistence;
773            @BeanReference(type = GroupPersistence.class)
774            protected GroupPersistence groupPersistence;
775            @BeanReference(type = ImagePersistence.class)
776            protected ImagePersistence imagePersistence;
777            @BeanReference(type = LayoutPersistence.class)
778            protected LayoutPersistence layoutPersistence;
779            @BeanReference(type = LayoutPrototypePersistence.class)
780            protected LayoutPrototypePersistence layoutPrototypePersistence;
781            @BeanReference(type = LayoutSetPersistence.class)
782            protected LayoutSetPersistence layoutSetPersistence;
783            @BeanReference(type = LayoutSetPrototypePersistence.class)
784            protected LayoutSetPrototypePersistence layoutSetPrototypePersistence;
785            @BeanReference(type = ListTypePersistence.class)
786            protected ListTypePersistence listTypePersistence;
787            @BeanReference(type = LockPersistence.class)
788            protected LockPersistence lockPersistence;
789            @BeanReference(type = MembershipRequestPersistence.class)
790            protected MembershipRequestPersistence membershipRequestPersistence;
791            @BeanReference(type = OrganizationPersistence.class)
792            protected OrganizationPersistence organizationPersistence;
793            @BeanReference(type = OrgGroupPermissionPersistence.class)
794            protected OrgGroupPermissionPersistence orgGroupPermissionPersistence;
795            @BeanReference(type = OrgGroupRolePersistence.class)
796            protected OrgGroupRolePersistence orgGroupRolePersistence;
797            @BeanReference(type = OrgLaborPersistence.class)
798            protected OrgLaborPersistence orgLaborPersistence;
799            @BeanReference(type = PasswordPolicyPersistence.class)
800            protected PasswordPolicyPersistence passwordPolicyPersistence;
801            @BeanReference(type = PasswordPolicyRelPersistence.class)
802            protected PasswordPolicyRelPersistence passwordPolicyRelPersistence;
803            @BeanReference(type = PasswordTrackerPersistence.class)
804            protected PasswordTrackerPersistence passwordTrackerPersistence;
805            @BeanReference(type = PermissionPersistence.class)
806            protected PermissionPersistence permissionPersistence;
807            @BeanReference(type = PhonePersistence.class)
808            protected PhonePersistence phonePersistence;
809            @BeanReference(type = PluginSettingPersistence.class)
810            protected PluginSettingPersistence pluginSettingPersistence;
811            @BeanReference(type = PortletPersistence.class)
812            protected PortletPersistence portletPersistence;
813            @BeanReference(type = PortletItemPersistence.class)
814            protected PortletItemPersistence portletItemPersistence;
815            @BeanReference(type = PortletPreferencesPersistence.class)
816            protected PortletPreferencesPersistence portletPreferencesPersistence;
817            @BeanReference(type = RegionPersistence.class)
818            protected RegionPersistence regionPersistence;
819            @BeanReference(type = ReleasePersistence.class)
820            protected ReleasePersistence releasePersistence;
821            @BeanReference(type = ResourcePersistence.class)
822            protected ResourcePersistence resourcePersistence;
823            @BeanReference(type = ResourceActionPersistence.class)
824            protected ResourceActionPersistence resourceActionPersistence;
825            @BeanReference(type = ResourceCodePersistence.class)
826            protected ResourceCodePersistence resourceCodePersistence;
827            @BeanReference(type = ResourcePermissionPersistence.class)
828            protected ResourcePermissionPersistence resourcePermissionPersistence;
829            @BeanReference(type = RolePersistence.class)
830            protected RolePersistence rolePersistence;
831            @BeanReference(type = ServiceComponentPersistence.class)
832            protected ServiceComponentPersistence serviceComponentPersistence;
833            @BeanReference(type = ShardPersistence.class)
834            protected ShardPersistence shardPersistence;
835            @BeanReference(type = SubscriptionPersistence.class)
836            protected SubscriptionPersistence subscriptionPersistence;
837            @BeanReference(type = TicketPersistence.class)
838            protected TicketPersistence ticketPersistence;
839            @BeanReference(type = TeamPersistence.class)
840            protected TeamPersistence teamPersistence;
841            @BeanReference(type = UserPersistence.class)
842            protected UserPersistence userPersistence;
843            @BeanReference(type = UserGroupPersistence.class)
844            protected UserGroupPersistence userGroupPersistence;
845            @BeanReference(type = UserGroupGroupRolePersistence.class)
846            protected UserGroupGroupRolePersistence userGroupGroupRolePersistence;
847            @BeanReference(type = UserGroupRolePersistence.class)
848            protected UserGroupRolePersistence userGroupRolePersistence;
849            @BeanReference(type = UserIdMapperPersistence.class)
850            protected UserIdMapperPersistence userIdMapperPersistence;
851            @BeanReference(type = UserTrackerPersistence.class)
852            protected UserTrackerPersistence userTrackerPersistence;
853            @BeanReference(type = UserTrackerPathPersistence.class)
854            protected UserTrackerPathPersistence userTrackerPathPersistence;
855            @BeanReference(type = WebDAVPropsPersistence.class)
856            protected WebDAVPropsPersistence webDAVPropsPersistence;
857            @BeanReference(type = WebsitePersistence.class)
858            protected WebsitePersistence websitePersistence;
859            @BeanReference(type = WorkflowDefinitionLinkPersistence.class)
860            protected WorkflowDefinitionLinkPersistence workflowDefinitionLinkPersistence;
861            @BeanReference(type = WorkflowInstanceLinkPersistence.class)
862            protected WorkflowInstanceLinkPersistence workflowInstanceLinkPersistence;
863            private static final String _SQL_SELECT_ORGLABOR = "SELECT orgLabor FROM OrgLabor orgLabor";
864            private static final String _SQL_SELECT_ORGLABOR_WHERE = "SELECT orgLabor FROM OrgLabor orgLabor WHERE ";
865            private static final String _SQL_COUNT_ORGLABOR = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor";
866            private static final String _SQL_COUNT_ORGLABOR_WHERE = "SELECT COUNT(orgLabor) FROM OrgLabor orgLabor WHERE ";
867            private static final String _FINDER_COLUMN_ORGANIZATIONID_ORGANIZATIONID_2 = "orgLabor.organizationId = ?";
868            private static final String _ORDER_BY_ENTITY_ALIAS = "orgLabor.";
869            private static final String _NO_SUCH_ENTITY_WITH_PRIMARY_KEY = "No OrgLabor exists with the primary key ";
870            private static final String _NO_SUCH_ENTITY_WITH_KEY = "No OrgLabor exists with the key {";
871            private static Log _log = LogFactoryUtil.getLog(OrgLaborPersistenceImpl.class);
872    }