1   /**
2    * Copyright (c) 2000-2008 Liferay, Inc. All rights reserved.
3    *
4    * Permission is hereby granted, free of charge, to any person obtaining a copy
5    * of this software and associated documentation files (the "Software"), to deal
6    * in the Software without restriction, including without limitation the rights
7    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8    * copies of the Software, and to permit persons to whom the Software is
9    * furnished to do so, subject to the following conditions:
10   *
11   * The above copyright notice and this permission notice shall be included in
12   * all copies or substantial portions of the Software.
13   *
14   * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15   * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16   * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17   * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18   * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19   * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20   * SOFTWARE.
21   */
22  
23  package com.liferay.portlet.messageboards.service.persistence;
24  
25  import com.liferay.portal.SystemException;
26  import com.liferay.portal.kernel.bean.InitializingBean;
27  import com.liferay.portal.kernel.dao.orm.DynamicQuery;
28  import com.liferay.portal.kernel.dao.orm.FinderCacheUtil;
29  import com.liferay.portal.kernel.dao.orm.Query;
30  import com.liferay.portal.kernel.dao.orm.QueryPos;
31  import com.liferay.portal.kernel.dao.orm.QueryUtil;
32  import com.liferay.portal.kernel.dao.orm.Session;
33  import com.liferay.portal.kernel.util.GetterUtil;
34  import com.liferay.portal.kernel.util.ListUtil;
35  import com.liferay.portal.kernel.util.OrderByComparator;
36  import com.liferay.portal.kernel.util.StringPool;
37  import com.liferay.portal.kernel.util.StringUtil;
38  import com.liferay.portal.model.ModelListener;
39  import com.liferay.portal.service.persistence.impl.BasePersistenceImpl;
40  
41  import com.liferay.portlet.messageboards.NoSuchStatsUserException;
42  import com.liferay.portlet.messageboards.model.MBStatsUser;
43  import com.liferay.portlet.messageboards.model.impl.MBStatsUserImpl;
44  import com.liferay.portlet.messageboards.model.impl.MBStatsUserModelImpl;
45  
46  import org.apache.commons.logging.Log;
47  import org.apache.commons.logging.LogFactory;
48  
49  import java.util.ArrayList;
50  import java.util.Collections;
51  import java.util.Iterator;
52  import java.util.List;
53  
54  /**
55   * <a href="MBStatsUserPersistenceImpl.java.html"><b><i>View Source</i></b></a>
56   *
57   * @author Brian Wing Shun Chan
58   *
59   */
60  public class MBStatsUserPersistenceImpl extends BasePersistenceImpl
61      implements MBStatsUserPersistence, InitializingBean {
62      public MBStatsUser create(long statsUserId) {
63          MBStatsUser mbStatsUser = new MBStatsUserImpl();
64  
65          mbStatsUser.setNew(true);
66          mbStatsUser.setPrimaryKey(statsUserId);
67  
68          return mbStatsUser;
69      }
70  
71      public MBStatsUser remove(long statsUserId)
72          throws NoSuchStatsUserException, SystemException {
73          Session session = null;
74  
75          try {
76              session = openSession();
77  
78              MBStatsUser mbStatsUser = (MBStatsUser)session.get(MBStatsUserImpl.class,
79                      new Long(statsUserId));
80  
81              if (mbStatsUser == null) {
82                  if (_log.isWarnEnabled()) {
83                      _log.warn("No MBStatsUser exists with the primary key " +
84                          statsUserId);
85                  }
86  
87                  throw new NoSuchStatsUserException(
88                      "No MBStatsUser exists with the primary key " +
89                      statsUserId);
90              }
91  
92              return remove(mbStatsUser);
93          }
94          catch (NoSuchStatsUserException nsee) {
95              throw nsee;
96          }
97          catch (Exception e) {
98              throw processException(e);
99          }
100         finally {
101             closeSession(session);
102         }
103     }
104 
105     public MBStatsUser remove(MBStatsUser mbStatsUser)
106         throws SystemException {
107         if (_listeners.length > 0) {
108             for (ModelListener listener : _listeners) {
109                 listener.onBeforeRemove(mbStatsUser);
110             }
111         }
112 
113         mbStatsUser = removeImpl(mbStatsUser);
114 
115         if (_listeners.length > 0) {
116             for (ModelListener listener : _listeners) {
117                 listener.onAfterRemove(mbStatsUser);
118             }
119         }
120 
121         return mbStatsUser;
122     }
123 
124     protected MBStatsUser removeImpl(MBStatsUser mbStatsUser)
125         throws SystemException {
126         Session session = null;
127 
128         try {
129             session = openSession();
130 
131             session.delete(mbStatsUser);
132 
133             session.flush();
134 
135             return mbStatsUser;
136         }
137         catch (Exception e) {
138             throw processException(e);
139         }
140         finally {
141             closeSession(session);
142 
143             FinderCacheUtil.clearCache(MBStatsUser.class.getName());
144         }
145     }
146 
147     /**
148      * @deprecated Use <code>update(MBStatsUser mbStatsUser, boolean merge)</code>.
149      */
150     public MBStatsUser update(MBStatsUser mbStatsUser)
151         throws SystemException {
152         if (_log.isWarnEnabled()) {
153             _log.warn(
154                 "Using the deprecated update(MBStatsUser mbStatsUser) method. Use update(MBStatsUser mbStatsUser, boolean merge) instead.");
155         }
156 
157         return update(mbStatsUser, false);
158     }
159 
160     /**
161      * Add, update, or merge, the entity. This method also calls the model
162      * listeners to trigger the proper events associated with adding, deleting,
163      * or updating an entity.
164      *
165      * @param        mbStatsUser the entity to add, update, or merge
166      * @param        merge boolean value for whether to merge the entity. The
167      *                default value is false. Setting merge to true is more
168      *                expensive and should only be true when mbStatsUser is
169      *                transient. See LEP-5473 for a detailed discussion of this
170      *                method.
171      * @return        true if the portlet can be displayed via Ajax
172      */
173     public MBStatsUser update(MBStatsUser mbStatsUser, boolean merge)
174         throws SystemException {
175         boolean isNew = mbStatsUser.isNew();
176 
177         if (_listeners.length > 0) {
178             for (ModelListener listener : _listeners) {
179                 if (isNew) {
180                     listener.onBeforeCreate(mbStatsUser);
181                 }
182                 else {
183                     listener.onBeforeUpdate(mbStatsUser);
184                 }
185             }
186         }
187 
188         mbStatsUser = updateImpl(mbStatsUser, merge);
189 
190         if (_listeners.length > 0) {
191             for (ModelListener listener : _listeners) {
192                 if (isNew) {
193                     listener.onAfterCreate(mbStatsUser);
194                 }
195                 else {
196                     listener.onAfterUpdate(mbStatsUser);
197                 }
198             }
199         }
200 
201         return mbStatsUser;
202     }
203 
204     public MBStatsUser updateImpl(
205         com.liferay.portlet.messageboards.model.MBStatsUser mbStatsUser,
206         boolean merge) throws SystemException {
207         Session session = null;
208 
209         try {
210             session = openSession();
211 
212             if (merge) {
213                 session.merge(mbStatsUser);
214             }
215             else {
216                 if (mbStatsUser.isNew()) {
217                     session.save(mbStatsUser);
218                 }
219             }
220 
221             session.flush();
222 
223             mbStatsUser.setNew(false);
224 
225             return mbStatsUser;
226         }
227         catch (Exception e) {
228             throw processException(e);
229         }
230         finally {
231             closeSession(session);
232 
233             FinderCacheUtil.clearCache(MBStatsUser.class.getName());
234         }
235     }
236 
237     public MBStatsUser findByPrimaryKey(long statsUserId)
238         throws NoSuchStatsUserException, SystemException {
239         MBStatsUser mbStatsUser = fetchByPrimaryKey(statsUserId);
240 
241         if (mbStatsUser == null) {
242             if (_log.isWarnEnabled()) {
243                 _log.warn("No MBStatsUser exists with the primary key " +
244                     statsUserId);
245             }
246 
247             throw new NoSuchStatsUserException(
248                 "No MBStatsUser exists with the primary key " + statsUserId);
249         }
250 
251         return mbStatsUser;
252     }
253 
254     public MBStatsUser fetchByPrimaryKey(long statsUserId)
255         throws SystemException {
256         Session session = null;
257 
258         try {
259             session = openSession();
260 
261             return (MBStatsUser)session.get(MBStatsUserImpl.class,
262                 new Long(statsUserId));
263         }
264         catch (Exception e) {
265             throw processException(e);
266         }
267         finally {
268             closeSession(session);
269         }
270     }
271 
272     public List<MBStatsUser> findByGroupId(long groupId)
273         throws SystemException {
274         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
275         String finderClassName = MBStatsUser.class.getName();
276         String finderMethodName = "findByGroupId";
277         String[] finderParams = new String[] { Long.class.getName() };
278         Object[] finderArgs = new Object[] { new Long(groupId) };
279 
280         Object result = null;
281 
282         if (finderClassNameCacheEnabled) {
283             result = FinderCacheUtil.getResult(finderClassName,
284                     finderMethodName, finderParams, finderArgs, this);
285         }
286 
287         if (result == null) {
288             Session session = null;
289 
290             try {
291                 session = openSession();
292 
293                 StringBuilder query = new StringBuilder();
294 
295                 query.append(
296                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
297 
298                 query.append("groupId = ?");
299 
300                 query.append(" ");
301 
302                 query.append("ORDER BY ");
303 
304                 query.append("messageCount DESC");
305 
306                 Query q = session.createQuery(query.toString());
307 
308                 QueryPos qPos = QueryPos.getInstance(q);
309 
310                 qPos.add(groupId);
311 
312                 List<MBStatsUser> list = q.list();
313 
314                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
315                     finderClassName, finderMethodName, finderParams,
316                     finderArgs, list);
317 
318                 return list;
319             }
320             catch (Exception e) {
321                 throw processException(e);
322             }
323             finally {
324                 closeSession(session);
325             }
326         }
327         else {
328             return (List<MBStatsUser>)result;
329         }
330     }
331 
332     public List<MBStatsUser> findByGroupId(long groupId, int start, int end)
333         throws SystemException {
334         return findByGroupId(groupId, start, end, null);
335     }
336 
337     public List<MBStatsUser> findByGroupId(long groupId, int start, int end,
338         OrderByComparator obc) throws SystemException {
339         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
340         String finderClassName = MBStatsUser.class.getName();
341         String finderMethodName = "findByGroupId";
342         String[] finderParams = new String[] {
343                 Long.class.getName(),
344                 
345                 "java.lang.Integer", "java.lang.Integer",
346                 "com.liferay.portal.kernel.util.OrderByComparator"
347             };
348         Object[] finderArgs = new Object[] {
349                 new Long(groupId),
350                 
351                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
352             };
353 
354         Object result = null;
355 
356         if (finderClassNameCacheEnabled) {
357             result = FinderCacheUtil.getResult(finderClassName,
358                     finderMethodName, finderParams, finderArgs, this);
359         }
360 
361         if (result == null) {
362             Session session = null;
363 
364             try {
365                 session = openSession();
366 
367                 StringBuilder query = new StringBuilder();
368 
369                 query.append(
370                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
371 
372                 query.append("groupId = ?");
373 
374                 query.append(" ");
375 
376                 if (obc != null) {
377                     query.append("ORDER BY ");
378                     query.append(obc.getOrderBy());
379                 }
380 
381                 else {
382                     query.append("ORDER BY ");
383 
384                     query.append("messageCount DESC");
385                 }
386 
387                 Query q = session.createQuery(query.toString());
388 
389                 QueryPos qPos = QueryPos.getInstance(q);
390 
391                 qPos.add(groupId);
392 
393                 List<MBStatsUser> list = (List<MBStatsUser>)QueryUtil.list(q,
394                         getDialect(), start, end);
395 
396                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
397                     finderClassName, finderMethodName, finderParams,
398                     finderArgs, list);
399 
400                 return list;
401             }
402             catch (Exception e) {
403                 throw processException(e);
404             }
405             finally {
406                 closeSession(session);
407             }
408         }
409         else {
410             return (List<MBStatsUser>)result;
411         }
412     }
413 
414     public MBStatsUser findByGroupId_First(long groupId, OrderByComparator obc)
415         throws NoSuchStatsUserException, SystemException {
416         List<MBStatsUser> list = findByGroupId(groupId, 0, 1, obc);
417 
418         if (list.size() == 0) {
419             StringBuilder msg = new StringBuilder();
420 
421             msg.append("No MBStatsUser exists with the key {");
422 
423             msg.append("groupId=" + groupId);
424 
425             msg.append(StringPool.CLOSE_CURLY_BRACE);
426 
427             throw new NoSuchStatsUserException(msg.toString());
428         }
429         else {
430             return list.get(0);
431         }
432     }
433 
434     public MBStatsUser findByGroupId_Last(long groupId, OrderByComparator obc)
435         throws NoSuchStatsUserException, SystemException {
436         int count = countByGroupId(groupId);
437 
438         List<MBStatsUser> list = findByGroupId(groupId, count - 1, count, obc);
439 
440         if (list.size() == 0) {
441             StringBuilder msg = new StringBuilder();
442 
443             msg.append("No MBStatsUser exists with the key {");
444 
445             msg.append("groupId=" + groupId);
446 
447             msg.append(StringPool.CLOSE_CURLY_BRACE);
448 
449             throw new NoSuchStatsUserException(msg.toString());
450         }
451         else {
452             return list.get(0);
453         }
454     }
455 
456     public MBStatsUser[] findByGroupId_PrevAndNext(long statsUserId,
457         long groupId, OrderByComparator obc)
458         throws NoSuchStatsUserException, SystemException {
459         MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
460 
461         int count = countByGroupId(groupId);
462 
463         Session session = null;
464 
465         try {
466             session = openSession();
467 
468             StringBuilder query = new StringBuilder();
469 
470             query.append(
471                 "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
472 
473             query.append("groupId = ?");
474 
475             query.append(" ");
476 
477             if (obc != null) {
478                 query.append("ORDER BY ");
479                 query.append(obc.getOrderBy());
480             }
481 
482             else {
483                 query.append("ORDER BY ");
484 
485                 query.append("messageCount DESC");
486             }
487 
488             Query q = session.createQuery(query.toString());
489 
490             QueryPos qPos = QueryPos.getInstance(q);
491 
492             qPos.add(groupId);
493 
494             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
495                     mbStatsUser);
496 
497             MBStatsUser[] array = new MBStatsUserImpl[3];
498 
499             array[0] = (MBStatsUser)objArray[0];
500             array[1] = (MBStatsUser)objArray[1];
501             array[2] = (MBStatsUser)objArray[2];
502 
503             return array;
504         }
505         catch (Exception e) {
506             throw processException(e);
507         }
508         finally {
509             closeSession(session);
510         }
511     }
512 
513     public List<MBStatsUser> findByUserId(long userId)
514         throws SystemException {
515         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
516         String finderClassName = MBStatsUser.class.getName();
517         String finderMethodName = "findByUserId";
518         String[] finderParams = new String[] { Long.class.getName() };
519         Object[] finderArgs = new Object[] { new Long(userId) };
520 
521         Object result = null;
522 
523         if (finderClassNameCacheEnabled) {
524             result = FinderCacheUtil.getResult(finderClassName,
525                     finderMethodName, finderParams, finderArgs, this);
526         }
527 
528         if (result == null) {
529             Session session = null;
530 
531             try {
532                 session = openSession();
533 
534                 StringBuilder query = new StringBuilder();
535 
536                 query.append(
537                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
538 
539                 query.append("userId = ?");
540 
541                 query.append(" ");
542 
543                 query.append("ORDER BY ");
544 
545                 query.append("messageCount DESC");
546 
547                 Query q = session.createQuery(query.toString());
548 
549                 QueryPos qPos = QueryPos.getInstance(q);
550 
551                 qPos.add(userId);
552 
553                 List<MBStatsUser> list = q.list();
554 
555                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
556                     finderClassName, finderMethodName, finderParams,
557                     finderArgs, list);
558 
559                 return list;
560             }
561             catch (Exception e) {
562                 throw processException(e);
563             }
564             finally {
565                 closeSession(session);
566             }
567         }
568         else {
569             return (List<MBStatsUser>)result;
570         }
571     }
572 
573     public List<MBStatsUser> findByUserId(long userId, int start, int end)
574         throws SystemException {
575         return findByUserId(userId, start, end, null);
576     }
577 
578     public List<MBStatsUser> findByUserId(long userId, int start, int end,
579         OrderByComparator obc) throws SystemException {
580         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
581         String finderClassName = MBStatsUser.class.getName();
582         String finderMethodName = "findByUserId";
583         String[] finderParams = new String[] {
584                 Long.class.getName(),
585                 
586                 "java.lang.Integer", "java.lang.Integer",
587                 "com.liferay.portal.kernel.util.OrderByComparator"
588             };
589         Object[] finderArgs = new Object[] {
590                 new Long(userId),
591                 
592                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
593             };
594 
595         Object result = null;
596 
597         if (finderClassNameCacheEnabled) {
598             result = FinderCacheUtil.getResult(finderClassName,
599                     finderMethodName, finderParams, finderArgs, this);
600         }
601 
602         if (result == null) {
603             Session session = null;
604 
605             try {
606                 session = openSession();
607 
608                 StringBuilder query = new StringBuilder();
609 
610                 query.append(
611                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
612 
613                 query.append("userId = ?");
614 
615                 query.append(" ");
616 
617                 if (obc != null) {
618                     query.append("ORDER BY ");
619                     query.append(obc.getOrderBy());
620                 }
621 
622                 else {
623                     query.append("ORDER BY ");
624 
625                     query.append("messageCount DESC");
626                 }
627 
628                 Query q = session.createQuery(query.toString());
629 
630                 QueryPos qPos = QueryPos.getInstance(q);
631 
632                 qPos.add(userId);
633 
634                 List<MBStatsUser> list = (List<MBStatsUser>)QueryUtil.list(q,
635                         getDialect(), start, end);
636 
637                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
638                     finderClassName, finderMethodName, finderParams,
639                     finderArgs, list);
640 
641                 return list;
642             }
643             catch (Exception e) {
644                 throw processException(e);
645             }
646             finally {
647                 closeSession(session);
648             }
649         }
650         else {
651             return (List<MBStatsUser>)result;
652         }
653     }
654 
655     public MBStatsUser findByUserId_First(long userId, OrderByComparator obc)
656         throws NoSuchStatsUserException, SystemException {
657         List<MBStatsUser> list = findByUserId(userId, 0, 1, obc);
658 
659         if (list.size() == 0) {
660             StringBuilder msg = new StringBuilder();
661 
662             msg.append("No MBStatsUser exists with the key {");
663 
664             msg.append("userId=" + userId);
665 
666             msg.append(StringPool.CLOSE_CURLY_BRACE);
667 
668             throw new NoSuchStatsUserException(msg.toString());
669         }
670         else {
671             return list.get(0);
672         }
673     }
674 
675     public MBStatsUser findByUserId_Last(long userId, OrderByComparator obc)
676         throws NoSuchStatsUserException, SystemException {
677         int count = countByUserId(userId);
678 
679         List<MBStatsUser> list = findByUserId(userId, count - 1, count, obc);
680 
681         if (list.size() == 0) {
682             StringBuilder msg = new StringBuilder();
683 
684             msg.append("No MBStatsUser exists with the key {");
685 
686             msg.append("userId=" + userId);
687 
688             msg.append(StringPool.CLOSE_CURLY_BRACE);
689 
690             throw new NoSuchStatsUserException(msg.toString());
691         }
692         else {
693             return list.get(0);
694         }
695     }
696 
697     public MBStatsUser[] findByUserId_PrevAndNext(long statsUserId,
698         long userId, OrderByComparator obc)
699         throws NoSuchStatsUserException, SystemException {
700         MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
701 
702         int count = countByUserId(userId);
703 
704         Session session = null;
705 
706         try {
707             session = openSession();
708 
709             StringBuilder query = new StringBuilder();
710 
711             query.append(
712                 "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
713 
714             query.append("userId = ?");
715 
716             query.append(" ");
717 
718             if (obc != null) {
719                 query.append("ORDER BY ");
720                 query.append(obc.getOrderBy());
721             }
722 
723             else {
724                 query.append("ORDER BY ");
725 
726                 query.append("messageCount DESC");
727             }
728 
729             Query q = session.createQuery(query.toString());
730 
731             QueryPos qPos = QueryPos.getInstance(q);
732 
733             qPos.add(userId);
734 
735             Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
736                     mbStatsUser);
737 
738             MBStatsUser[] array = new MBStatsUserImpl[3];
739 
740             array[0] = (MBStatsUser)objArray[0];
741             array[1] = (MBStatsUser)objArray[1];
742             array[2] = (MBStatsUser)objArray[2];
743 
744             return array;
745         }
746         catch (Exception e) {
747             throw processException(e);
748         }
749         finally {
750             closeSession(session);
751         }
752     }
753 
754     public MBStatsUser findByG_U(long groupId, long userId)
755         throws NoSuchStatsUserException, SystemException {
756         MBStatsUser mbStatsUser = fetchByG_U(groupId, userId);
757 
758         if (mbStatsUser == null) {
759             StringBuilder msg = new StringBuilder();
760 
761             msg.append("No MBStatsUser exists with the key {");
762 
763             msg.append("groupId=" + groupId);
764 
765             msg.append(", ");
766             msg.append("userId=" + userId);
767 
768             msg.append(StringPool.CLOSE_CURLY_BRACE);
769 
770             if (_log.isWarnEnabled()) {
771                 _log.warn(msg.toString());
772             }
773 
774             throw new NoSuchStatsUserException(msg.toString());
775         }
776 
777         return mbStatsUser;
778     }
779 
780     public MBStatsUser fetchByG_U(long groupId, long userId)
781         throws SystemException {
782         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
783         String finderClassName = MBStatsUser.class.getName();
784         String finderMethodName = "fetchByG_U";
785         String[] finderParams = new String[] {
786                 Long.class.getName(), Long.class.getName()
787             };
788         Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
789 
790         Object result = null;
791 
792         if (finderClassNameCacheEnabled) {
793             result = FinderCacheUtil.getResult(finderClassName,
794                     finderMethodName, finderParams, finderArgs, this);
795         }
796 
797         if (result == null) {
798             Session session = null;
799 
800             try {
801                 session = openSession();
802 
803                 StringBuilder query = new StringBuilder();
804 
805                 query.append(
806                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
807 
808                 query.append("groupId = ?");
809 
810                 query.append(" AND ");
811 
812                 query.append("userId = ?");
813 
814                 query.append(" ");
815 
816                 query.append("ORDER BY ");
817 
818                 query.append("messageCount DESC");
819 
820                 Query q = session.createQuery(query.toString());
821 
822                 QueryPos qPos = QueryPos.getInstance(q);
823 
824                 qPos.add(groupId);
825 
826                 qPos.add(userId);
827 
828                 List<MBStatsUser> list = q.list();
829 
830                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
831                     finderClassName, finderMethodName, finderParams,
832                     finderArgs, list);
833 
834                 if (list.size() == 0) {
835                     return null;
836                 }
837                 else {
838                     return list.get(0);
839                 }
840             }
841             catch (Exception e) {
842                 throw processException(e);
843             }
844             finally {
845                 closeSession(session);
846             }
847         }
848         else {
849             List<MBStatsUser> list = (List<MBStatsUser>)result;
850 
851             if (list.size() == 0) {
852                 return null;
853             }
854             else {
855                 return list.get(0);
856             }
857         }
858     }
859 
860     public List<MBStatsUser> findByG_M(long groupId, int messageCount)
861         throws SystemException {
862         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
863         String finderClassName = MBStatsUser.class.getName();
864         String finderMethodName = "findByG_M";
865         String[] finderParams = new String[] {
866                 Long.class.getName(), Integer.class.getName()
867             };
868         Object[] finderArgs = new Object[] {
869                 new Long(groupId), new Integer(messageCount)
870             };
871 
872         Object result = null;
873 
874         if (finderClassNameCacheEnabled) {
875             result = FinderCacheUtil.getResult(finderClassName,
876                     finderMethodName, finderParams, finderArgs, this);
877         }
878 
879         if (result == null) {
880             Session session = null;
881 
882             try {
883                 session = openSession();
884 
885                 StringBuilder query = new StringBuilder();
886 
887                 query.append(
888                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
889 
890                 query.append("groupId = ?");
891 
892                 query.append(" AND ");
893 
894                 query.append("messageCount != ?");
895 
896                 query.append(" ");
897 
898                 query.append("ORDER BY ");
899 
900                 query.append("messageCount DESC");
901 
902                 Query q = session.createQuery(query.toString());
903 
904                 QueryPos qPos = QueryPos.getInstance(q);
905 
906                 qPos.add(groupId);
907 
908                 qPos.add(messageCount);
909 
910                 List<MBStatsUser> list = q.list();
911 
912                 FinderCacheUtil.putResult(finderClassNameCacheEnabled,
913                     finderClassName, finderMethodName, finderParams,
914                     finderArgs, list);
915 
916                 return list;
917             }
918             catch (Exception e) {
919                 throw processException(e);
920             }
921             finally {
922                 closeSession(session);
923             }
924         }
925         else {
926             return (List<MBStatsUser>)result;
927         }
928     }
929 
930     public List<MBStatsUser> findByG_M(long groupId, int messageCount,
931         int start, int end) throws SystemException {
932         return findByG_M(groupId, messageCount, start, end, null);
933     }
934 
935     public List<MBStatsUser> findByG_M(long groupId, int messageCount,
936         int start, int end, OrderByComparator obc) throws SystemException {
937         boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
938         String finderClassName = MBStatsUser.class.getName();
939         String finderMethodName = "findByG_M";
940         String[] finderParams = new String[] {
941                 Long.class.getName(), Integer.class.getName(),
942                 
943                 "java.lang.Integer", "java.lang.Integer",
944                 "com.liferay.portal.kernel.util.OrderByComparator"
945             };
946         Object[] finderArgs = new Object[] {
947                 new Long(groupId), new Integer(messageCount),
948                 
949                 String.valueOf(start), String.valueOf(end), String.valueOf(obc)
950             };
951 
952         Object result = null;
953 
954         if (finderClassNameCacheEnabled) {
955             result = FinderCacheUtil.getResult(finderClassName,
956                     finderMethodName, finderParams, finderArgs, this);
957         }
958 
959         if (result == null) {
960             Session session = null;
961 
962             try {
963                 session = openSession();
964 
965                 StringBuilder query = new StringBuilder();
966 
967                 query.append(
968                     "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
969 
970                 query.append("groupId = ?");
971 
972                 query.append(" AND ");
973 
974                 query.append("messageCount != ?");
975 
976                 query.append(" ");
977 
978                 if (obc != null) {
979                     query.append("ORDER BY ");
980                     query.append(obc.getOrderBy());
981                 }
982 
983                 else {
984                     query.append("ORDER BY ");
985 
986                     query.append("messageCount DESC");
987                 }
988 
989                 Query q = session.createQuery(query.toString());
990 
991                 QueryPos qPos = QueryPos.getInstance(q);
992 
993                 qPos.add(groupId);
994 
995                 qPos.add(messageCount);
996 
997                 List<MBStatsUser> list = (List<MBStatsUser>)QueryUtil.list(q,
998                         getDialect(), start, end);
999 
1000                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1001                    finderClassName, finderMethodName, finderParams,
1002                    finderArgs, list);
1003
1004                return list;
1005            }
1006            catch (Exception e) {
1007                throw processException(e);
1008            }
1009            finally {
1010                closeSession(session);
1011            }
1012        }
1013        else {
1014            return (List<MBStatsUser>)result;
1015        }
1016    }
1017
1018    public MBStatsUser findByG_M_First(long groupId, int messageCount,
1019        OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1020        List<MBStatsUser> list = findByG_M(groupId, messageCount, 0, 1, obc);
1021
1022        if (list.size() == 0) {
1023            StringBuilder msg = new StringBuilder();
1024
1025            msg.append("No MBStatsUser exists with the key {");
1026
1027            msg.append("groupId=" + groupId);
1028
1029            msg.append(", ");
1030            msg.append("messageCount=" + messageCount);
1031
1032            msg.append(StringPool.CLOSE_CURLY_BRACE);
1033
1034            throw new NoSuchStatsUserException(msg.toString());
1035        }
1036        else {
1037            return list.get(0);
1038        }
1039    }
1040
1041    public MBStatsUser findByG_M_Last(long groupId, int messageCount,
1042        OrderByComparator obc) throws NoSuchStatsUserException, SystemException {
1043        int count = countByG_M(groupId, messageCount);
1044
1045        List<MBStatsUser> list = findByG_M(groupId, messageCount, count - 1,
1046                count, obc);
1047
1048        if (list.size() == 0) {
1049            StringBuilder msg = new StringBuilder();
1050
1051            msg.append("No MBStatsUser exists with the key {");
1052
1053            msg.append("groupId=" + groupId);
1054
1055            msg.append(", ");
1056            msg.append("messageCount=" + messageCount);
1057
1058            msg.append(StringPool.CLOSE_CURLY_BRACE);
1059
1060            throw new NoSuchStatsUserException(msg.toString());
1061        }
1062        else {
1063            return list.get(0);
1064        }
1065    }
1066
1067    public MBStatsUser[] findByG_M_PrevAndNext(long statsUserId, long groupId,
1068        int messageCount, OrderByComparator obc)
1069        throws NoSuchStatsUserException, SystemException {
1070        MBStatsUser mbStatsUser = findByPrimaryKey(statsUserId);
1071
1072        int count = countByG_M(groupId, messageCount);
1073
1074        Session session = null;
1075
1076        try {
1077            session = openSession();
1078
1079            StringBuilder query = new StringBuilder();
1080
1081            query.append(
1082                "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1083
1084            query.append("groupId = ?");
1085
1086            query.append(" AND ");
1087
1088            query.append("messageCount != ?");
1089
1090            query.append(" ");
1091
1092            if (obc != null) {
1093                query.append("ORDER BY ");
1094                query.append(obc.getOrderBy());
1095            }
1096
1097            else {
1098                query.append("ORDER BY ");
1099
1100                query.append("messageCount DESC");
1101            }
1102
1103            Query q = session.createQuery(query.toString());
1104
1105            QueryPos qPos = QueryPos.getInstance(q);
1106
1107            qPos.add(groupId);
1108
1109            qPos.add(messageCount);
1110
1111            Object[] objArray = QueryUtil.getPrevAndNext(q, count, obc,
1112                    mbStatsUser);
1113
1114            MBStatsUser[] array = new MBStatsUserImpl[3];
1115
1116            array[0] = (MBStatsUser)objArray[0];
1117            array[1] = (MBStatsUser)objArray[1];
1118            array[2] = (MBStatsUser)objArray[2];
1119
1120            return array;
1121        }
1122        catch (Exception e) {
1123            throw processException(e);
1124        }
1125        finally {
1126            closeSession(session);
1127        }
1128    }
1129
1130    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery)
1131        throws SystemException {
1132        Session session = null;
1133
1134        try {
1135            session = openSession();
1136
1137            dynamicQuery.compile(session);
1138
1139            return dynamicQuery.list();
1140        }
1141        catch (Exception e) {
1142            throw processException(e);
1143        }
1144        finally {
1145            closeSession(session);
1146        }
1147    }
1148
1149    public List<Object> findWithDynamicQuery(DynamicQuery dynamicQuery,
1150        int start, int end) throws SystemException {
1151        Session session = null;
1152
1153        try {
1154            session = openSession();
1155
1156            dynamicQuery.setLimit(start, end);
1157
1158            dynamicQuery.compile(session);
1159
1160            return dynamicQuery.list();
1161        }
1162        catch (Exception e) {
1163            throw processException(e);
1164        }
1165        finally {
1166            closeSession(session);
1167        }
1168    }
1169
1170    public List<MBStatsUser> findAll() throws SystemException {
1171        return findAll(QueryUtil.ALL_POS, QueryUtil.ALL_POS, null);
1172    }
1173
1174    public List<MBStatsUser> findAll(int start, int end)
1175        throws SystemException {
1176        return findAll(start, end, null);
1177    }
1178
1179    public List<MBStatsUser> findAll(int start, int end, OrderByComparator obc)
1180        throws SystemException {
1181        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1182        String finderClassName = MBStatsUser.class.getName();
1183        String finderMethodName = "findAll";
1184        String[] finderParams = new String[] {
1185                "java.lang.Integer", "java.lang.Integer",
1186                "com.liferay.portal.kernel.util.OrderByComparator"
1187            };
1188        Object[] finderArgs = new Object[] {
1189                String.valueOf(start), String.valueOf(end), String.valueOf(obc)
1190            };
1191
1192        Object result = null;
1193
1194        if (finderClassNameCacheEnabled) {
1195            result = FinderCacheUtil.getResult(finderClassName,
1196                    finderMethodName, finderParams, finderArgs, this);
1197        }
1198
1199        if (result == null) {
1200            Session session = null;
1201
1202            try {
1203                session = openSession();
1204
1205                StringBuilder query = new StringBuilder();
1206
1207                query.append(
1208                    "FROM com.liferay.portlet.messageboards.model.MBStatsUser ");
1209
1210                if (obc != null) {
1211                    query.append("ORDER BY ");
1212                    query.append(obc.getOrderBy());
1213                }
1214
1215                else {
1216                    query.append("ORDER BY ");
1217
1218                    query.append("messageCount DESC");
1219                }
1220
1221                Query q = session.createQuery(query.toString());
1222
1223                List<MBStatsUser> list = (List<MBStatsUser>)QueryUtil.list(q,
1224                        getDialect(), start, end);
1225
1226                if (obc == null) {
1227                    Collections.sort(list);
1228                }
1229
1230                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1231                    finderClassName, finderMethodName, finderParams,
1232                    finderArgs, list);
1233
1234                return list;
1235            }
1236            catch (Exception e) {
1237                throw processException(e);
1238            }
1239            finally {
1240                closeSession(session);
1241            }
1242        }
1243        else {
1244            return (List<MBStatsUser>)result;
1245        }
1246    }
1247
1248    public void removeByGroupId(long groupId) throws SystemException {
1249        for (MBStatsUser mbStatsUser : findByGroupId(groupId)) {
1250            remove(mbStatsUser);
1251        }
1252    }
1253
1254    public void removeByUserId(long userId) throws SystemException {
1255        for (MBStatsUser mbStatsUser : findByUserId(userId)) {
1256            remove(mbStatsUser);
1257        }
1258    }
1259
1260    public void removeByG_U(long groupId, long userId)
1261        throws NoSuchStatsUserException, SystemException {
1262        MBStatsUser mbStatsUser = findByG_U(groupId, userId);
1263
1264        remove(mbStatsUser);
1265    }
1266
1267    public void removeByG_M(long groupId, int messageCount)
1268        throws SystemException {
1269        for (MBStatsUser mbStatsUser : findByG_M(groupId, messageCount)) {
1270            remove(mbStatsUser);
1271        }
1272    }
1273
1274    public void removeAll() throws SystemException {
1275        for (MBStatsUser mbStatsUser : findAll()) {
1276            remove(mbStatsUser);
1277        }
1278    }
1279
1280    public int countByGroupId(long groupId) throws SystemException {
1281        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1282        String finderClassName = MBStatsUser.class.getName();
1283        String finderMethodName = "countByGroupId";
1284        String[] finderParams = new String[] { Long.class.getName() };
1285        Object[] finderArgs = new Object[] { new Long(groupId) };
1286
1287        Object result = null;
1288
1289        if (finderClassNameCacheEnabled) {
1290            result = FinderCacheUtil.getResult(finderClassName,
1291                    finderMethodName, finderParams, finderArgs, this);
1292        }
1293
1294        if (result == null) {
1295            Session session = null;
1296
1297            try {
1298                session = openSession();
1299
1300                StringBuilder query = new StringBuilder();
1301
1302                query.append("SELECT COUNT(*) ");
1303                query.append(
1304                    "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1305
1306                query.append("groupId = ?");
1307
1308                query.append(" ");
1309
1310                Query q = session.createQuery(query.toString());
1311
1312                QueryPos qPos = QueryPos.getInstance(q);
1313
1314                qPos.add(groupId);
1315
1316                Long count = null;
1317
1318                Iterator<Long> itr = q.list().iterator();
1319
1320                if (itr.hasNext()) {
1321                    count = itr.next();
1322                }
1323
1324                if (count == null) {
1325                    count = new Long(0);
1326                }
1327
1328                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1329                    finderClassName, finderMethodName, finderParams,
1330                    finderArgs, count);
1331
1332                return count.intValue();
1333            }
1334            catch (Exception e) {
1335                throw processException(e);
1336            }
1337            finally {
1338                closeSession(session);
1339            }
1340        }
1341        else {
1342            return ((Long)result).intValue();
1343        }
1344    }
1345
1346    public int countByUserId(long userId) throws SystemException {
1347        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1348        String finderClassName = MBStatsUser.class.getName();
1349        String finderMethodName = "countByUserId";
1350        String[] finderParams = new String[] { Long.class.getName() };
1351        Object[] finderArgs = new Object[] { new Long(userId) };
1352
1353        Object result = null;
1354
1355        if (finderClassNameCacheEnabled) {
1356            result = FinderCacheUtil.getResult(finderClassName,
1357                    finderMethodName, finderParams, finderArgs, this);
1358        }
1359
1360        if (result == null) {
1361            Session session = null;
1362
1363            try {
1364                session = openSession();
1365
1366                StringBuilder query = new StringBuilder();
1367
1368                query.append("SELECT COUNT(*) ");
1369                query.append(
1370                    "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1371
1372                query.append("userId = ?");
1373
1374                query.append(" ");
1375
1376                Query q = session.createQuery(query.toString());
1377
1378                QueryPos qPos = QueryPos.getInstance(q);
1379
1380                qPos.add(userId);
1381
1382                Long count = null;
1383
1384                Iterator<Long> itr = q.list().iterator();
1385
1386                if (itr.hasNext()) {
1387                    count = itr.next();
1388                }
1389
1390                if (count == null) {
1391                    count = new Long(0);
1392                }
1393
1394                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1395                    finderClassName, finderMethodName, finderParams,
1396                    finderArgs, count);
1397
1398                return count.intValue();
1399            }
1400            catch (Exception e) {
1401                throw processException(e);
1402            }
1403            finally {
1404                closeSession(session);
1405            }
1406        }
1407        else {
1408            return ((Long)result).intValue();
1409        }
1410    }
1411
1412    public int countByG_U(long groupId, long userId) throws SystemException {
1413        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1414        String finderClassName = MBStatsUser.class.getName();
1415        String finderMethodName = "countByG_U";
1416        String[] finderParams = new String[] {
1417                Long.class.getName(), Long.class.getName()
1418            };
1419        Object[] finderArgs = new Object[] { new Long(groupId), new Long(userId) };
1420
1421        Object result = null;
1422
1423        if (finderClassNameCacheEnabled) {
1424            result = FinderCacheUtil.getResult(finderClassName,
1425                    finderMethodName, finderParams, finderArgs, this);
1426        }
1427
1428        if (result == null) {
1429            Session session = null;
1430
1431            try {
1432                session = openSession();
1433
1434                StringBuilder query = new StringBuilder();
1435
1436                query.append("SELECT COUNT(*) ");
1437                query.append(
1438                    "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1439
1440                query.append("groupId = ?");
1441
1442                query.append(" AND ");
1443
1444                query.append("userId = ?");
1445
1446                query.append(" ");
1447
1448                Query q = session.createQuery(query.toString());
1449
1450                QueryPos qPos = QueryPos.getInstance(q);
1451
1452                qPos.add(groupId);
1453
1454                qPos.add(userId);
1455
1456                Long count = null;
1457
1458                Iterator<Long> itr = q.list().iterator();
1459
1460                if (itr.hasNext()) {
1461                    count = itr.next();
1462                }
1463
1464                if (count == null) {
1465                    count = new Long(0);
1466                }
1467
1468                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1469                    finderClassName, finderMethodName, finderParams,
1470                    finderArgs, count);
1471
1472                return count.intValue();
1473            }
1474            catch (Exception e) {
1475                throw processException(e);
1476            }
1477            finally {
1478                closeSession(session);
1479            }
1480        }
1481        else {
1482            return ((Long)result).intValue();
1483        }
1484    }
1485
1486    public int countByG_M(long groupId, int messageCount)
1487        throws SystemException {
1488        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1489        String finderClassName = MBStatsUser.class.getName();
1490        String finderMethodName = "countByG_M";
1491        String[] finderParams = new String[] {
1492                Long.class.getName(), Integer.class.getName()
1493            };
1494        Object[] finderArgs = new Object[] {
1495                new Long(groupId), new Integer(messageCount)
1496            };
1497
1498        Object result = null;
1499
1500        if (finderClassNameCacheEnabled) {
1501            result = FinderCacheUtil.getResult(finderClassName,
1502                    finderMethodName, finderParams, finderArgs, this);
1503        }
1504
1505        if (result == null) {
1506            Session session = null;
1507
1508            try {
1509                session = openSession();
1510
1511                StringBuilder query = new StringBuilder();
1512
1513                query.append("SELECT COUNT(*) ");
1514                query.append(
1515                    "FROM com.liferay.portlet.messageboards.model.MBStatsUser WHERE ");
1516
1517                query.append("groupId = ?");
1518
1519                query.append(" AND ");
1520
1521                query.append("messageCount != ?");
1522
1523                query.append(" ");
1524
1525                Query q = session.createQuery(query.toString());
1526
1527                QueryPos qPos = QueryPos.getInstance(q);
1528
1529                qPos.add(groupId);
1530
1531                qPos.add(messageCount);
1532
1533                Long count = null;
1534
1535                Iterator<Long> itr = q.list().iterator();
1536
1537                if (itr.hasNext()) {
1538                    count = itr.next();
1539                }
1540
1541                if (count == null) {
1542                    count = new Long(0);
1543                }
1544
1545                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1546                    finderClassName, finderMethodName, finderParams,
1547                    finderArgs, count);
1548
1549                return count.intValue();
1550            }
1551            catch (Exception e) {
1552                throw processException(e);
1553            }
1554            finally {
1555                closeSession(session);
1556            }
1557        }
1558        else {
1559            return ((Long)result).intValue();
1560        }
1561    }
1562
1563    public int countAll() throws SystemException {
1564        boolean finderClassNameCacheEnabled = MBStatsUserModelImpl.CACHE_ENABLED;
1565        String finderClassName = MBStatsUser.class.getName();
1566        String finderMethodName = "countAll";
1567        String[] finderParams = new String[] {  };
1568        Object[] finderArgs = new Object[] {  };
1569
1570        Object result = null;
1571
1572        if (finderClassNameCacheEnabled) {
1573            result = FinderCacheUtil.getResult(finderClassName,
1574                    finderMethodName, finderParams, finderArgs, this);
1575        }
1576
1577        if (result == null) {
1578            Session session = null;
1579
1580            try {
1581                session = openSession();
1582
1583                Query q = session.createQuery(
1584                        "SELECT COUNT(*) FROM com.liferay.portlet.messageboards.model.MBStatsUser");
1585
1586                Long count = null;
1587
1588                Iterator<Long> itr = q.list().iterator();
1589
1590                if (itr.hasNext()) {
1591                    count = itr.next();
1592                }
1593
1594                if (count == null) {
1595                    count = new Long(0);
1596                }
1597
1598                FinderCacheUtil.putResult(finderClassNameCacheEnabled,
1599                    finderClassName, finderMethodName, finderParams,
1600                    finderArgs, count);
1601
1602                return count.intValue();
1603            }
1604            catch (Exception e) {
1605                throw processException(e);
1606            }
1607            finally {
1608                closeSession(session);
1609            }
1610        }
1611        else {
1612            return ((Long)result).intValue();
1613        }
1614    }
1615
1616    public void registerListener(ModelListener listener) {
1617        List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1618
1619        listeners.add(listener);
1620
1621        _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1622    }
1623
1624    public void unregisterListener(ModelListener listener) {
1625        List<ModelListener> listeners = ListUtil.fromArray(_listeners);
1626
1627        listeners.remove(listener);
1628
1629        _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1630    }
1631
1632    public void afterPropertiesSet() {
1633        String[] listenerClassNames = StringUtil.split(GetterUtil.getString(
1634                    com.liferay.portal.util.PropsUtil.get(
1635                        "value.object.listener.com.liferay.portlet.messageboards.model.MBStatsUser")));
1636
1637        if (listenerClassNames.length > 0) {
1638            try {
1639                List<ModelListener> listeners = new ArrayList<ModelListener>();
1640
1641                for (String listenerClassName : listenerClassNames) {
1642                    listeners.add((ModelListener)Class.forName(
1643                            listenerClassName).newInstance());
1644                }
1645
1646                _listeners = listeners.toArray(new ModelListener[listeners.size()]);
1647            }
1648            catch (Exception e) {
1649                _log.error(e);
1650            }
1651        }
1652    }
1653
1654    private static Log _log = LogFactory.getLog(MBStatsUserPersistenceImpl.class);
1655    private ModelListener[] _listeners = new ModelListener[0];
1656}