View Javadoc
1   // license-header java merge-point
2   //
3   // Attention: Generated code! Do not modify by hand!
4   // Generated by: hibernate/SpringHibernateDaoBase.vsl in <project>/mda/src/main/cartridge/custom/...
5   //
6   package fr.ifremer.quadrige3.core.dao.administration.strategy;
7   
8   /*-
9    * #%L
10   * Quadrige3 Core :: Client API
11   * %%
12   * Copyright (C) 2017 - 2024 Ifremer
13   * %%
14   * This program is free software: you can redistribute it and/or modify
15   * it under the terms of the GNU Affero General Public License as published by
16   * the Free Software Foundation, either version 3 of the License, or
17   * (at your option) any later version.
18   * 
19   * This program is distributed in the hope that it will be useful,
20   * but WITHOUT ANY WARRANTY; without even the implied warranty of
21   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22   * GNU General Public License for more details.
23   * 
24   * You should have received a copy of the GNU Affero General Public License
25   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
26   * #L%
27   */
28  import fr.ifremer.quadrige3.core.dao.PrincipalStore;
29  import fr.ifremer.quadrige3.core.dao.PropertySearch;
30  import fr.ifremer.quadrige3.core.dao.Search;
31  import fr.ifremer.quadrige3.core.dao.technical.hibernate.HibernateDaoSupport;
32  import fr.ifremer.quadrige3.core.vo.administration.strategy.AppliedPeriodVO;
33  import java.security.Principal;
34  import java.sql.Timestamp;
35  import java.util.ArrayList;
36  import java.util.Collection;
37  import java.util.Date;
38  import java.util.Iterator;
39  import java.util.LinkedHashSet;
40  import java.util.List;
41  import java.util.Set;
42  import javax.annotation.Resource;
43  import org.andromda.spring.PaginationResult;
44  import org.apache.commons.collections.CollectionUtils;
45  import org.apache.commons.collections.Transformer;
46  import org.hibernate.Criteria;
47  import org.hibernate.HibernateException;
48  import org.hibernate.Query;
49  import org.hibernate.ScrollableResults;
50  
51  /**
52   * <p>
53   * Base Spring DAO Class: is able to create, update, remove, load, and find
54   * objects of type <code>AppliedPeriod</code>.
55   * </p>
56   *
57   * @see AppliedPeriod
58   */
59  public abstract class AppliedPeriodDaoBase
60      extends HibernateDaoSupport    
61      implements AppliedPeriodDao
62  {
63      /**
64       * {@inheritDoc}
65       */
66      @Override
67      public Object get(final int transform, final AppliedPeriodPK appliedPeriodPk)
68      {
69          if (appliedPeriodPk == null)
70          {
71              throw new IllegalArgumentException(
72                  "AppliedPeriod.get - 'appliedPeriodPk' can not be null");
73          }
74          final AppliedPeriod entity = get(AppliedPeriodImpl.class, appliedPeriodPk);
75          return transformEntity(transform, entity);
76      }
77      /**
78       * {@inheritDoc}
79       */
80      @Override
81      public AppliedPeriod get(AppliedPeriodPK appliedPeriodPk)
82      {
83          return (AppliedPeriod)this.get(TRANSFORM_NONE, appliedPeriodPk);
84      }
85  
86      /**
87       * {@inheritDoc}
88       */
89      @Override
90      public Object load(final int transform, final AppliedPeriodPK appliedPeriodPk)
91      {
92          if (appliedPeriodPk == null)
93          {
94              throw new IllegalArgumentException(
95                  "AppliedPeriod.load - 'appliedPeriodPk' can not be null");
96          }
97          final AppliedPeriod entity = get(AppliedPeriodImpl.class, appliedPeriodPk);
98          return transformEntity(transform, entity);
99      }
100 
101     /**
102      * {@inheritDoc}
103      */
104     @Override
105     public AppliedPeriod load(AppliedPeriodPK appliedPeriodPk)
106     {
107         return (AppliedPeriod)this.load(TRANSFORM_NONE, appliedPeriodPk);
108     }
109 
110     /**
111      * {@inheritDoc}
112      */
113     @Override
114     @SuppressWarnings({"unchecked"})
115     public Collection<AppliedPeriod> loadAll()
116     {
117         return (Collection<AppliedPeriod>) this.loadAll(AppliedPeriodDao.TRANSFORM_NONE);
118     }
119 
120     /**
121      * {@inheritDoc}
122      */
123     @Override
124     public Collection<?> loadAll(final int transform)
125     {
126         return this.loadAll(transform, -1, -1);
127     }
128 
129     /**
130      * {@inheritDoc}
131      */
132     @Override
133     public Collection<?> loadAll(final int pageNumber, final int pageSize)
134     {
135         return this.loadAll(AppliedPeriodDao.TRANSFORM_NONE, pageNumber, pageSize);
136     }
137 
138     /**
139      * {@inheritDoc}
140      */
141     @Override
142     public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize)
143     {
144         try
145         {
146             final Criteria criteria = this.getSession().createCriteria(AppliedPeriodImpl.class);
147             if (pageNumber > 0 && pageSize > 0)
148             {
149                 criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
150                 criteria.setMaxResults(pageSize);
151             }
152             final Collection<?> results = criteria.list();
153             this.transformEntities(transform, results);
154             return results;
155         }
156         catch (HibernateException ex)
157         {
158             throw ex;
159         }
160     }
161 
162     /**
163      * firstResult = (pageNumber - 1) * pageSize
164      * @param pageNumber
165      * @param pageSize
166      * @return firstResult
167      */
168     protected int calculateFirstResult(int pageNumber, int pageSize)
169     {
170         int firstResult = 0;
171         if (pageNumber > 0)
172         {
173             firstResult = (pageNumber - 1) * pageSize;
174         }
175         return firstResult;
176     }
177 
178     /**
179      * {@inheritDoc}
180      */
181     @Override
182     public AppliedPeriod create(AppliedPeriod appliedPeriod)
183     {
184         return (AppliedPeriod)this.create(AppliedPeriodDao.TRANSFORM_NONE, appliedPeriod);
185     }
186 
187     /**
188      * {@inheritDoc}
189      */
190     @Override
191     public Object create(final int transform, final AppliedPeriod appliedPeriod)
192     {
193         if (appliedPeriod == null)
194         {
195             throw new IllegalArgumentException(
196                 "AppliedPeriod.create - 'appliedPeriod' can not be null");
197         }
198         this.getSessionFactory().getCurrentSession().save(appliedPeriod);
199         return this.transformEntity(transform, appliedPeriod);
200     }
201 
202     /**
203      * {@inheritDoc}
204      */
205     @Override
206     @SuppressWarnings({"unchecked"})
207     public Collection<AppliedPeriod> create(final Collection<AppliedPeriod> entities)
208     {
209         return (Collection<AppliedPeriod>) create(AppliedPeriodDao.TRANSFORM_NONE, entities);
210     }
211 
212     /**
213      * {@inheritDoc}
214      */
215     @Override
216     public Collection<?> create(final int transform, final Collection<AppliedPeriod> entities)
217     {
218         if (entities == null)
219         {
220             throw new IllegalArgumentException(
221                 "AppliedPeriod.create - 'entities' can not be null");
222         }
223                     for (AppliedPeriod entity : entities)
224                     {
225                         create(transform, entity);
226                     }
227         return entities;
228     }
229 
230     /**
231      * {@inheritDoc}
232      */
233     @Override
234     public AppliedPeriod create(
235         Date appliedPeriodEndDt,
236         Timestamp updateDt)
237     {
238         return (AppliedPeriod)this.create(AppliedPeriodDao.TRANSFORM_NONE, appliedPeriodEndDt, updateDt);
239     }
240 
241     /**
242      * {@inheritDoc}
243      */
244     @Override
245     public Object create(
246         final int transform,
247         Date appliedPeriodEndDt,
248         Timestamp updateDt)
249     {
250         AppliedPeriod entity = new AppliedPeriodImpl();
251         entity.setAppliedPeriodEndDt(appliedPeriodEndDt);
252         entity.setUpdateDt(updateDt);
253         return this.create(transform, entity);
254     }
255 
256     /**
257      * {@inheritDoc}
258      */
259     @Override
260     public AppliedPeriod create(
261         Date appliedPeriodEndDt,
262         AppliedStrategy appliedStrategy)
263     {
264         return (AppliedPeriod)this.create(AppliedPeriodDao.TRANSFORM_NONE, appliedPeriodEndDt, appliedStrategy);
265     }
266 
267     /**
268      * {@inheritDoc}
269      */
270     @Override
271     public Object create(
272         final int transform,
273         Date appliedPeriodEndDt,
274         AppliedStrategy appliedStrategy)
275     {
276         AppliedPeriod entity = new AppliedPeriodImpl();
277         entity.setAppliedPeriodEndDt(appliedPeriodEndDt);
278         entity.setAppliedStrategy(appliedStrategy);
279         return this.create(transform, entity);
280     }
281 
282     /**
283      * {@inheritDoc}
284      */
285     @Override
286     public void update(AppliedPeriod appliedPeriod)
287     {
288         if (appliedPeriod == null)
289         {
290             throw new IllegalArgumentException(
291                 "AppliedPeriod.update - 'appliedPeriod' can not be null");
292         }
293         this.getSessionFactory().getCurrentSession().update(appliedPeriod);
294     }
295 
296     /**
297      * {@inheritDoc}
298      */
299     @Override
300     public void update(final Collection<AppliedPeriod> entities)
301     {
302         if (entities == null)
303         {
304             throw new IllegalArgumentException(
305                 "AppliedPeriod.update - 'entities' can not be null");
306         }
307                     for (AppliedPeriod entity : entities)
308                     {
309                         update(entity);
310                     }
311     }
312 
313     /**
314      * {@inheritDoc}
315      */
316     @Override
317     public void remove(AppliedPeriod appliedPeriod)
318     {
319         if (appliedPeriod == null)
320         {
321             throw new IllegalArgumentException(
322                 "AppliedPeriod.remove - 'appliedPeriod' can not be null");
323         }
324         this.getSessionFactory().getCurrentSession().delete(appliedPeriod);
325     }
326 
327     /**
328      * {@inheritDoc}
329      */
330     @Override
331     public void remove(AppliedPeriodPK appliedPeriodPk)
332     {
333         if (appliedPeriodPk == null)
334         {
335             throw new IllegalArgumentException(
336                 "AppliedPeriod.remove - 'appliedPeriodPk' can not be null");
337         }
338         AppliedPeriod entity = this.get(appliedPeriodPk);
339         if (entity != null)
340         {
341             this.remove(entity);
342         }
343     }
344 
345     /**
346      * {@inheritDoc}
347      */
348     @Override
349     public void remove(Collection<AppliedPeriod> entities)
350     {
351         if (entities == null)
352         {
353             throw new IllegalArgumentException(
354                 "AppliedPeriod.remove - 'entities' can not be null");
355         }
356         deleteAll(entities);
357     }
358     /**
359      * {@inheritDoc}
360      */
361     @Override
362     public AppliedPeriodVO save(final AppliedPeriodVO appliedPeriod, final Timestamp updateDt)
363     {
364         if (appliedPeriod == null)
365         {
366             throw new IllegalArgumentException(
367                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.save(AppliedPeriodVO appliedPeriod, Timestamp updateDt) - 'appliedPeriod' can not be null");
368         }
369         try
370         {
371             return this.handleSave(appliedPeriod, updateDt);
372         }
373         catch (Throwable th)
374         {
375             throw new RuntimeException(
376             "Error performing 'AppliedPeriodDao.save(AppliedPeriodVO appliedPeriod, Timestamp updateDt)' --> " + th,
377             th);
378         }
379     }
380 
381     /**
382      * Performs the core logic for {@link #save(AppliedPeriodVO, Timestamp)}
383      * @param appliedPeriod
384      * @param updateDt
385      * @return AppliedPeriodVO
386      * @throws Exception
387      */
388     protected abstract AppliedPeriodVO handleSave(AppliedPeriodVO appliedPeriod, Timestamp updateDt)
389         throws Exception;
390 
391     /**
392      * {@inheritDoc}
393      */
394     @Override
395     public void checkCanRemove(final Integer appliedStratId, final String progCd, final Integer monLocId, final Date startDate, final Date endDate)
396     {
397         if (appliedStratId == null)
398         {
399             throw new IllegalArgumentException(
400                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate) - 'appliedStratId' can not be null");
401         }
402         if (progCd == null)
403         {
404             throw new IllegalArgumentException(
405                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate) - 'progCd' can not be null");
406         }
407         if (monLocId == null)
408         {
409             throw new IllegalArgumentException(
410                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate) - 'monLocId' can not be null");
411         }
412         if (startDate == null)
413         {
414             throw new IllegalArgumentException(
415                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate) - 'startDate' can not be null");
416         }
417         if (endDate == null)
418         {
419             throw new IllegalArgumentException(
420                 "fr.ifremer.quadrige3.core.dao.administration.strategy.AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate) - 'endDate' can not be null");
421         }
422         try
423         {
424             this.handleCheckCanRemove(appliedStratId, progCd, monLocId, startDate, endDate);
425         }
426         catch (Throwable th)
427         {
428             throw new RuntimeException(
429             "Error performing 'AppliedPeriodDao.checkCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate)' --> " + th,
430             th);
431         }
432     }
433 
434     /**
435      * Performs the core logic for {@link #checkCanRemove(Integer, String, Integer, Date, Date)}
436      * @param appliedStratId
437      * @param progCd
438      * @param monLocId
439      * @param startDate
440      * @param endDate
441      * @return void
442      * @throws Exception
443      */
444     protected abstract void handleCheckCanRemove(Integer appliedStratId, String progCd, Integer monLocId, Date startDate, Date endDate)
445         throws Exception;
446 
447     /**
448      * Allows transformation of entities into value objects
449      * (or something else for that matter), when the <code>transform</code>
450      * flag is set to one of the constants defined in <code>AppliedPeriodDao</code>, please note
451      * that the {@link #TRANSFORM_NONE} constant denotes no transformation, so the entity itself
452      * will be returned.
453      * <p>
454      * This method will return instances of these types:
455      * <ul>
456      *   <li>{@link AppliedPeriod} - {@link #TRANSFORM_NONE}</li>
457      *   <li>{@link AppliedPeriodVO} - {@link #TRANSFORM_APPLIEDPERIODVO}</li>
458      * </ul>
459      *
460      * If the integer argument value is unknown {@link #TRANSFORM_NONE} is assumed.
461      *
462      * @param transform one of the constants declared in {@link AppliedPeriodDao}
463      * @param entity an entity that was found
464      * @return the transformed entity (i.e. new value object, etc)
465      * @see AppliedPeriodDao#transformEntity(int, AppliedPeriod)
466      */
467     public Object transformEntity(final int transform, final AppliedPeriod entity)
468     {
469         Object target = null;
470         if (entity != null)
471         {
472             switch (transform)
473             {
474                 case TRANSFORM_APPLIEDPERIODVO :
475                     target = toAppliedPeriodVO(entity);
476                     break;
477                 case AppliedPeriodDao.TRANSFORM_NONE : // fall-through
478                 default:
479                     target = entity;
480             }
481         }
482         return target;
483     }
484 
485     /**
486      * {@inheritDoc}
487      */
488     @Override
489     public void transformEntities(final int transform, final Collection<?> entities)
490     {
491         switch (transform)
492         {
493             case TRANSFORM_APPLIEDPERIODVO :
494                 toAppliedPeriodVOCollection(entities);
495                 break;
496             case AppliedPeriodDao.TRANSFORM_NONE : // fall-through
497                 default:
498                 // do nothing;
499         }
500     }
501 
502     /**
503      * @see AppliedPeriodDao#toEntities(Collection)
504      */
505     public void toEntities(final Collection<?> results)
506     {
507         if (results != null)
508         {
509             CollectionUtils.transform(results, this.ENTITYTRANSFORMER);
510         }
511     }
512 
513     /**
514      * This anonymous transformer is designed to transform report query results
515      * (which result in an array of entities) to {@link AppliedPeriod}
516      * using the Jakarta Commons-Collections Transformation API.
517      */
518     private Transformer ENTITYTRANSFORMER =
519         new Transformer()
520         {
521             public Object transform(Object input)
522             {
523                 Object result = null;
524                 if (input instanceof Object[])
525                 {
526                     result = toEntity((Object[])input);
527                 }
528                 else if (input instanceof AppliedPeriod)
529                 {
530                     result = input;
531                 }
532                 return result;
533             }
534         };
535 
536     /**
537      * @param row
538      * @return AppliedPeriod
539      */
540     protected AppliedPeriod toEntity(Object[] row)
541     {
542         AppliedPeriod target = null;
543         if (row != null)
544         {
545             final int numberOfObjects = row.length;
546             for (int ctr = 0; ctr < numberOfObjects; ctr++)
547             {
548                 final Object object = row[ctr];
549                 if (object instanceof AppliedPeriod)
550                 {
551                     target = (AppliedPeriod)object;
552                     break;
553                 }
554             }
555         }
556         return target;
557     }
558 
559     /**
560      * {@inheritDoc}
561      */
562     @Override
563     @SuppressWarnings({"unchecked"})
564     public final Collection<AppliedPeriodVO> toAppliedPeriodVOCollection(Collection<?> entities)
565     {
566         Collection<AppliedPeriodVO> result = new ArrayList<AppliedPeriodVO>();
567         if (entities != null)
568         {
569             CollectionUtils.transform(entities, this.APPLIEDPERIODVO_TRANSFORMER);
570             result.addAll((Collection<? extends AppliedPeriodVO>) entities);
571         }
572         return result;
573     }
574 
575     /**
576      * {@inheritDoc}
577      */
578     @Override
579     @SuppressWarnings({ "unchecked" })
580     public final AppliedPeriodVO[] toAppliedPeriodVOArray(Collection<?> entities)
581     {
582         AppliedPeriodVO[] result = null;
583         if (entities != null)
584         {
585             // Unchecked transformation: reuses entities Collection
586             final Collection collection = new ArrayList(entities);
587             this.toAppliedPeriodVOCollection(collection);
588             result = (AppliedPeriodVO[]) collection.toArray(new AppliedPeriodVO[collection.size()]);
589         }
590         return result;
591     }
592 
593     /**
594      * Default implementation for transforming the results of a report query into a value object. This
595      * implementation exists for convenience reasons only. It needs only be overridden in the
596      * {@link AppliedPeriodDaoImpl} class if you intend to use reporting queries.
597      * @param row
598      * @return toAppliedPeriodVO(this.toEntity(row))
599      * @see AppliedPeriodDao#toAppliedPeriodVO(AppliedPeriod)
600      */
601     protected AppliedPeriodVO toAppliedPeriodVO(Object[] row)
602     {
603         return this.toAppliedPeriodVO(this.toEntity(row));
604     }
605 
606     /**
607      * This anonymous transformer is designed to transform entities or report query results
608      * (which result in an array of objects) to {@link AppliedPeriodVO}
609      * using the Jakarta Commons-Collections Transformation API.
610      */
611     private Transformer APPLIEDPERIODVO_TRANSFORMER =
612         new Transformer()
613         {
614             public Object transform(Object input)
615             {
616                 Object result = null;
617                 if (input instanceof AppliedPeriod)
618                 {
619                     result = toAppliedPeriodVO((AppliedPeriod)input);
620                 }
621                 else if (input instanceof Object[])
622                 {
623                     result = toAppliedPeriodVO((Object[])input);
624                 }
625                 return result;
626             }
627         };
628 
629     /**
630      * {@inheritDoc}
631      */
632     @Override
633     public final void appliedPeriodVOToEntityCollection(Collection<?> instances)
634     {
635         if (instances != null)
636         {
637             for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();)
638             {
639                 // - remove an objects that are null or not of the correct instance
640                 if (!(iterator.next() instanceof AppliedPeriodVO))
641                 {
642                     iterator.remove();
643                 }
644             }
645             CollectionUtils.transform(instances, this.AppliedPeriodVOToEntityTransformer);
646         }
647     }
648 
649     private final Transformer AppliedPeriodVOToEntityTransformer =
650         new Transformer()
651         {
652             public Object transform(Object input)
653             {
654                 return appliedPeriodVOToEntity((AppliedPeriodVO)input);
655             }
656         };
657 
658 
659     /**
660      * {@inheritDoc}
661      */
662     @Override
663     public void toAppliedPeriodVO(
664         AppliedPeriod source,
665         AppliedPeriodVO target)
666     {
667         target.setAppliedPeriodEndDt(source.getAppliedPeriodEndDt());
668         target.setUpdateDt(source.getUpdateDt());
669     }
670 
671     /**
672      * {@inheritDoc}
673      */
674     @Override
675     public AppliedPeriodVO toAppliedPeriodVO(final AppliedPeriod entity)
676     {
677         AppliedPeriodVO target = null;
678         if (entity != null)
679         {
680             target =  new AppliedPeriodVO();
681             this.toAppliedPeriodVO(entity, target);
682         }
683         return target;
684     }
685 
686     /**
687      * {@inheritDoc}
688      */
689     @Override
690     public void appliedPeriodVOToEntity(
691         AppliedPeriodVO source,
692         AppliedPeriod target,
693         boolean copyIfNull)
694     {
695         if (copyIfNull || source.getAppliedPeriodEndDt() != null)
696         {
697             target.setAppliedPeriodEndDt(source.getAppliedPeriodEndDt());
698         }
699         if (copyIfNull || source.getUpdateDt() != null)
700         {
701             target.setUpdateDt(source.getUpdateDt());
702         }
703     }
704 
705     /**
706      * Gets the current <code>principal</code> if one has been set,
707      * otherwise returns <code>null</code>.
708      *
709      * @return the current principal
710      */
711     protected Principal getPrincipal()
712     {
713         return PrincipalStore.get();
714     }
715 
716     /**
717      * {@inheritDoc}
718      */
719     @Override
720     @SuppressWarnings({ "unchecked" })
721     public PaginationResult search(final int transform, final int pageNumber, final int pageSize, final Search search)
722     {
723         try
724         {
725             search.setPageNumber(pageNumber);
726             search.setPageSize(pageSize);
727             final PropertySearch propertySearch = new PropertySearch(
728                 this.getSession(), AppliedPeriodImpl.class, search);
729             final List results = propertySearch.executeAsList();
730             this.transformEntities(transform, results);
731             return new PaginationResult(results.toArray(new Object[results.size()]), propertySearch.getTotalCount());
732         }
733         catch (HibernateException ex)
734         {
735             throw ex; /*super.convertHibernateAccessException(ex);*/
736         }
737     }
738 
739     /**
740      * {@inheritDoc}
741      */
742     @Override
743     public PaginationResult search(final int pageNumber, final int pageSize, final Search search)
744     {
745         return this.search(AppliedPeriodDao.TRANSFORM_NONE, pageNumber, pageSize, search);
746     }
747 
748     /**
749      * {@inheritDoc}
750      */
751     @Override
752     public Set<?> search(final int transform, final Search search)
753     {
754         try
755         {
756             final PropertySearch propertySearch = new PropertySearch(
757                 this.getSession(), AppliedPeriodImpl.class, search);
758             final Set<?> results = propertySearch.executeAsSet();
759             this.transformEntities(transform, results);
760             return results;
761         }
762         catch (HibernateException ex)
763         {
764             throw ex; /*super.convertHibernateAccessException(ex);*/
765         }
766     }
767 
768     /**
769      * {@inheritDoc}
770      */
771     @Override
772     @SuppressWarnings("unchecked")
773     public Set<AppliedPeriod> search(final Search search)
774     {
775         return (Set<AppliedPeriod>) this.search(AppliedPeriodDao.TRANSFORM_NONE, search);
776     }
777 
778     /**
779      * Executes and returns the given Hibernate queryObject as a {@link PaginationResult} instance.
780      * @param queryObject
781      * @param transform
782      * @param pageNumber
783      * @param pageSize
784      * @return PaginationResult
785      */
786     @SuppressWarnings({ "unchecked" })
787     protected PaginationResult getPaginationResult(
788         final Query queryObject,
789         final int transform, int pageNumber, int pageSize)
790     {
791         try
792         {
793             final ScrollableResults scrollableResults = queryObject.scroll();
794             scrollableResults.last();
795             int totalCount = scrollableResults.getRowNumber();
796             totalCount = totalCount >= 0 ? totalCount + 1 : 0;
797             if (pageNumber > 0 && pageSize > 0)
798             {
799                 queryObject.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
800                 queryObject.setMaxResults(pageSize);
801             }
802             // Unchecked transformation because Set object is reused, cannot be strongly typed.
803             Set results = new LinkedHashSet(queryObject.list());
804             transformEntities(transform, results);
805             return new PaginationResult(results.toArray(new Object[results.size()]), totalCount);
806         }
807         catch (HibernateException ex)
808         {
809             throw ex; /*super.convertHibernateAccessException(ex);*/
810         }
811     }
812 
813     // spring-hibernate-dao-base merge-point
814 }