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.user;
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.referential.Status;
32  import fr.ifremer.quadrige3.core.dao.technical.hibernate.HibernateDaoSupport;
33  import fr.ifremer.quadrige3.core.vo.administration.user.LightQuserVO;
34  import fr.ifremer.quadrige3.core.vo.administration.user.QuserVO;
35  import java.security.Principal;
36  import java.sql.Timestamp;
37  import java.util.ArrayList;
38  import java.util.Collection;
39  import java.util.Date;
40  import java.util.Iterator;
41  import java.util.LinkedHashSet;
42  import java.util.List;
43  import java.util.Set;
44  import javax.annotation.Resource;
45  import org.andromda.spring.PaginationResult;
46  import org.apache.commons.collections.CollectionUtils;
47  import org.apache.commons.collections.Transformer;
48  import org.hibernate.Criteria;
49  import org.hibernate.HibernateException;
50  import org.hibernate.Query;
51  import org.hibernate.ScrollableResults;
52  
53  /**
54   * <p>
55   * Base Spring DAO Class: is able to create, update, remove, load, and find
56   * objects of type <code>Quser</code>.
57   * </p>
58   *
59   * @see Quser
60   */
61  public abstract class QuserDaoBase
62      extends HibernateDaoSupport    
63      implements QuserDao
64  {
65      /**
66       * {@inheritDoc}
67       */
68      @Override
69      public Object get(final int transform, final Integer quserId)
70      {
71          if (quserId == null)
72          {
73              throw new IllegalArgumentException(
74                  "Quser.get - 'quserId' can not be null");
75          }
76          final Quser entity = get(QuserImpl.class, quserId);
77          return transformEntity(transform, entity);
78      }
79      /**
80       * {@inheritDoc}
81       */
82      @Override
83      public Quser get(Integer quserId)
84      {
85          return (Quser)this.get(TRANSFORM_NONE, quserId);
86      }
87  
88      /**
89       * {@inheritDoc}
90       */
91      @Override
92      public Object load(final int transform, final Integer quserId)
93      {
94          if (quserId == null)
95          {
96              throw new IllegalArgumentException(
97                  "Quser.load - 'quserId' can not be null");
98          }
99          final Quser entity = get(QuserImpl.class, quserId);
100         return transformEntity(transform, entity);
101     }
102 
103     /**
104      * {@inheritDoc}
105      */
106     @Override
107     public Quser load(Integer quserId)
108     {
109         return (Quser)this.load(TRANSFORM_NONE, quserId);
110     }
111 
112     /**
113      * {@inheritDoc}
114      */
115     @Override
116     @SuppressWarnings({"unchecked"})
117     public Collection<Quser> loadAll()
118     {
119         return (Collection<Quser>) this.loadAll(QuserDao.TRANSFORM_NONE);
120     }
121 
122     /**
123      * {@inheritDoc}
124      */
125     @Override
126     public Collection<?> loadAll(final int transform)
127     {
128         return this.loadAll(transform, -1, -1);
129     }
130 
131     /**
132      * {@inheritDoc}
133      */
134     @Override
135     public Collection<?> loadAll(final int pageNumber, final int pageSize)
136     {
137         return this.loadAll(QuserDao.TRANSFORM_NONE, pageNumber, pageSize);
138     }
139 
140     /**
141      * {@inheritDoc}
142      */
143     @Override
144     public Collection<?> loadAll(final int transform, final int pageNumber, final int pageSize)
145     {
146         try
147         {
148             final Criteria criteria = this.getSession().createCriteria(QuserImpl.class);
149             if (pageNumber > 0 && pageSize > 0)
150             {
151                 criteria.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
152                 criteria.setMaxResults(pageSize);
153             }
154             final Collection<?> results = criteria.list();
155             this.transformEntities(transform, results);
156             return results;
157         }
158         catch (HibernateException ex)
159         {
160             throw ex;
161         }
162     }
163 
164     /**
165      * firstResult = (pageNumber - 1) * pageSize
166      * @param pageNumber
167      * @param pageSize
168      * @return firstResult
169      */
170     protected int calculateFirstResult(int pageNumber, int pageSize)
171     {
172         int firstResult = 0;
173         if (pageNumber > 0)
174         {
175             firstResult = (pageNumber - 1) * pageSize;
176         }
177         return firstResult;
178     }
179 
180     /**
181      * {@inheritDoc}
182      */
183     @Override
184     public Quser create(Quser quser)
185     {
186         return (Quser)this.create(QuserDao.TRANSFORM_NONE, quser);
187     }
188 
189     /**
190      * {@inheritDoc}
191      */
192     @Override
193     public Object create(final int transform, final Quser quser)
194     {
195         if (quser == null)
196         {
197             throw new IllegalArgumentException(
198                 "Quser.create - 'quser' can not be null");
199         }
200         this.getSessionFactory().getCurrentSession().save(quser);
201         return this.transformEntity(transform, quser);
202     }
203 
204     /**
205      * {@inheritDoc}
206      */
207     @Override
208     @SuppressWarnings({"unchecked"})
209     public Collection<Quser> create(final Collection<Quser> entities)
210     {
211         return (Collection<Quser>) create(QuserDao.TRANSFORM_NONE, entities);
212     }
213 
214     /**
215      * {@inheritDoc}
216      */
217     @Override
218     public Collection<?> create(final int transform, final Collection<Quser> entities)
219     {
220         if (entities == null)
221         {
222             throw new IllegalArgumentException(
223                 "Quser.create - 'entities' can not be null");
224         }
225                     for (Quser entity : entities)
226                     {
227                         create(transform, entity);
228                     }
229         return entities;
230     }
231 
232     /**
233      * {@inheritDoc}
234      */
235     @Override
236     public Quser create(
237         String quserCd,
238         String quserLastNm,
239         String quserFirstNm,
240         String quserIntranetLg,
241         String quserExtranetLg,
242         String quserEMail,
243         String quserAddress,
244         String quserPhone,
245         String quserOrgan,
246         String quserAdminCenter,
247         String quserSite,
248         String quserLdapPresent,
249         String quserCryptPassword,
250         Date quserCreationDt,
251         Timestamp updateDt,
252         String quserCm)
253     {
254         return (Quser)this.create(QuserDao.TRANSFORM_NONE, quserCd, quserLastNm, quserFirstNm, quserIntranetLg, quserExtranetLg, quserEMail, quserAddress, quserPhone, quserOrgan, quserAdminCenter, quserSite, quserLdapPresent, quserCryptPassword, quserCreationDt, updateDt, quserCm);
255     }
256 
257     /**
258      * {@inheritDoc}
259      */
260     @Override
261     public Object create(
262         final int transform,
263         String quserCd,
264         String quserLastNm,
265         String quserFirstNm,
266         String quserIntranetLg,
267         String quserExtranetLg,
268         String quserEMail,
269         String quserAddress,
270         String quserPhone,
271         String quserOrgan,
272         String quserAdminCenter,
273         String quserSite,
274         String quserLdapPresent,
275         String quserCryptPassword,
276         Date quserCreationDt,
277         Timestamp updateDt,
278         String quserCm)
279     {
280         Quser entity = new QuserImpl();
281         entity.setQuserCd(quserCd);
282         entity.setQuserLastNm(quserLastNm);
283         entity.setQuserFirstNm(quserFirstNm);
284         entity.setQuserIntranetLg(quserIntranetLg);
285         entity.setQuserExtranetLg(quserExtranetLg);
286         entity.setQuserEMail(quserEMail);
287         entity.setQuserAddress(quserAddress);
288         entity.setQuserPhone(quserPhone);
289         entity.setQuserOrgan(quserOrgan);
290         entity.setQuserAdminCenter(quserAdminCenter);
291         entity.setQuserSite(quserSite);
292         entity.setQuserLdapPresent(quserLdapPresent);
293         entity.setQuserCryptPassword(quserCryptPassword);
294         entity.setQuserCreationDt(quserCreationDt);
295         entity.setUpdateDt(updateDt);
296         entity.setQuserCm(quserCm);
297         return this.create(transform, entity);
298     }
299 
300     /**
301      * {@inheritDoc}
302      */
303     @Override
304     public Quser create(
305         String quserFirstNm,
306         String quserLastNm,
307         Department department,
308         Status status)
309     {
310         return (Quser)this.create(QuserDao.TRANSFORM_NONE, quserFirstNm, quserLastNm, department, status);
311     }
312 
313     /**
314      * {@inheritDoc}
315      */
316     @Override
317     public Object create(
318         final int transform,
319         String quserFirstNm,
320         String quserLastNm,
321         Department department,
322         Status status)
323     {
324         Quser entity = new QuserImpl();
325         entity.setQuserFirstNm(quserFirstNm);
326         entity.setQuserLastNm(quserLastNm);
327         entity.setDepartment(department);
328         entity.setStatus(status);
329         return this.create(transform, entity);
330     }
331 
332     /**
333      * {@inheritDoc}
334      */
335     @Override
336     public void update(Quser quser)
337     {
338         if (quser == null)
339         {
340             throw new IllegalArgumentException(
341                 "Quser.update - 'quser' can not be null");
342         }
343         this.getSessionFactory().getCurrentSession().update(quser);
344     }
345 
346     /**
347      * {@inheritDoc}
348      */
349     @Override
350     public void update(final Collection<Quser> entities)
351     {
352         if (entities == null)
353         {
354             throw new IllegalArgumentException(
355                 "Quser.update - 'entities' can not be null");
356         }
357                     for (Quser entity : entities)
358                     {
359                         update(entity);
360                     }
361     }
362 
363     /**
364      * {@inheritDoc}
365      */
366     @Override
367     public void remove(Quser quser)
368     {
369         if (quser == null)
370         {
371             throw new IllegalArgumentException(
372                 "Quser.remove - 'quser' can not be null");
373         }
374         this.getSessionFactory().getCurrentSession().delete(quser);
375     }
376 
377     /**
378      * {@inheritDoc}
379      */
380     @Override
381     public void remove(Integer quserId)
382     {
383         if (quserId == null)
384         {
385             throw new IllegalArgumentException(
386                 "Quser.remove - 'quserId' can not be null");
387         }
388         Quser entity = this.get(quserId);
389         if (entity != null)
390         {
391             this.remove(entity);
392         }
393     }
394 
395     /**
396      * {@inheritDoc}
397      */
398     @Override
399     public void remove(Collection<Quser> entities)
400     {
401         if (entities == null)
402         {
403             throw new IllegalArgumentException(
404                 "Quser.remove - 'entities' can not be null");
405         }
406         deleteAll(entities);
407     }
408     /**
409      * Allows transformation of entities into value objects
410      * (or something else for that matter), when the <code>transform</code>
411      * flag is set to one of the constants defined in <code>QuserDao</code>, please note
412      * that the {@link #TRANSFORM_NONE} constant denotes no transformation, so the entity itself
413      * will be returned.
414      * <p>
415      * This method will return instances of these types:
416      * <ul>
417      *   <li>{@link Quser} - {@link #TRANSFORM_NONE}</li>
418      *   <li>{@link QuserVO} - {@link #TRANSFORM_QUSERVO}</li>
419      *   <li>{@link LightQuserVO} - {@link #TRANSFORM_LIGHTQUSERVO}</li>
420      * </ul>
421      *
422      * If the integer argument value is unknown {@link #TRANSFORM_NONE} is assumed.
423      *
424      * @param transform one of the constants declared in {@link QuserDao}
425      * @param entity an entity that was found
426      * @return the transformed entity (i.e. new value object, etc)
427      * @see QuserDao#transformEntity(int, Quser)
428      */
429     public Object transformEntity(final int transform, final Quser entity)
430     {
431         Object target = null;
432         if (entity != null)
433         {
434             switch (transform)
435             {
436                 case TRANSFORM_QUSERVO :
437                     target = toQuserVO(entity);
438                     break;
439                 case TRANSFORM_LIGHTQUSERVO :
440                     target = toLightQuserVO(entity);
441                     break;
442                 case QuserDao.TRANSFORM_NONE : // fall-through
443                 default:
444                     target = entity;
445             }
446         }
447         return target;
448     }
449 
450     /**
451      * {@inheritDoc}
452      */
453     @Override
454     public void transformEntities(final int transform, final Collection<?> entities)
455     {
456         switch (transform)
457         {
458             case TRANSFORM_QUSERVO :
459                 toQuserVOCollection(entities);
460                 break;
461             case TRANSFORM_LIGHTQUSERVO :
462                 toLightQuserVOCollection(entities);
463                 break;
464             case QuserDao.TRANSFORM_NONE : // fall-through
465                 default:
466                 // do nothing;
467         }
468     }
469 
470     /**
471      * @see QuserDao#toEntities(Collection)
472      */
473     public void toEntities(final Collection<?> results)
474     {
475         if (results != null)
476         {
477             CollectionUtils.transform(results, this.ENTITYTRANSFORMER);
478         }
479     }
480 
481     /**
482      * This anonymous transformer is designed to transform report query results
483      * (which result in an array of entities) to {@link Quser}
484      * using the Jakarta Commons-Collections Transformation API.
485      */
486     private Transformer ENTITYTRANSFORMER =
487         new Transformer()
488         {
489             public Object transform(Object input)
490             {
491                 Object result = null;
492                 if (input instanceof Object[])
493                 {
494                     result = toEntity((Object[])input);
495                 }
496                 else if (input instanceof Quser)
497                 {
498                     result = input;
499                 }
500                 return result;
501             }
502         };
503 
504     /**
505      * @param row
506      * @return Quser
507      */
508     protected Quser toEntity(Object[] row)
509     {
510         Quser target = null;
511         if (row != null)
512         {
513             final int numberOfObjects = row.length;
514             for (int ctr = 0; ctr < numberOfObjects; ctr++)
515             {
516                 final Object object = row[ctr];
517                 if (object instanceof Quser)
518                 {
519                     target = (Quser)object;
520                     break;
521                 }
522             }
523         }
524         return target;
525     }
526 
527     /**
528      * {@inheritDoc}
529      */
530     @Override
531     @SuppressWarnings({"unchecked"})
532     public final Collection<QuserVO> toQuserVOCollection(Collection<?> entities)
533     {
534         Collection<QuserVO> result = new ArrayList<QuserVO>();
535         if (entities != null)
536         {
537             CollectionUtils.transform(entities, this.QUSERVO_TRANSFORMER);
538             result.addAll((Collection<? extends QuserVO>) entities);
539         }
540         return result;
541     }
542 
543     /**
544      * {@inheritDoc}
545      */
546     @Override
547     @SuppressWarnings({ "unchecked" })
548     public final QuserVO[] toQuserVOArray(Collection<?> entities)
549     {
550         QuserVO[] result = null;
551         if (entities != null)
552         {
553             // Unchecked transformation: reuses entities Collection
554             final Collection collection = new ArrayList(entities);
555             this.toQuserVOCollection(collection);
556             result = (QuserVO[]) collection.toArray(new QuserVO[collection.size()]);
557         }
558         return result;
559     }
560 
561     /**
562      * Default implementation for transforming the results of a report query into a value object. This
563      * implementation exists for convenience reasons only. It needs only be overridden in the
564      * {@link QuserDaoImpl} class if you intend to use reporting queries.
565      * @param row
566      * @return toQuserVO(this.toEntity(row))
567      * @see QuserDao#toQuserVO(Quser)
568      */
569     protected QuserVO toQuserVO(Object[] row)
570     {
571         return this.toQuserVO(this.toEntity(row));
572     }
573 
574     /**
575      * This anonymous transformer is designed to transform entities or report query results
576      * (which result in an array of objects) to {@link QuserVO}
577      * using the Jakarta Commons-Collections Transformation API.
578      */
579     private Transformer QUSERVO_TRANSFORMER =
580         new Transformer()
581         {
582             public Object transform(Object input)
583             {
584                 Object result = null;
585                 if (input instanceof Quser)
586                 {
587                     result = toQuserVO((Quser)input);
588                 }
589                 else if (input instanceof Object[])
590                 {
591                     result = toQuserVO((Object[])input);
592                 }
593                 return result;
594             }
595         };
596 
597     /**
598      * {@inheritDoc}
599      */
600     @Override
601     public final void quserVOToEntityCollection(Collection<?> instances)
602     {
603         if (instances != null)
604         {
605             for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();)
606             {
607                 // - remove an objects that are null or not of the correct instance
608                 if (!(iterator.next() instanceof QuserVO))
609                 {
610                     iterator.remove();
611                 }
612             }
613             CollectionUtils.transform(instances, this.QuserVOToEntityTransformer);
614         }
615     }
616 
617     private final Transformer QuserVOToEntityTransformer =
618         new Transformer()
619         {
620             public Object transform(Object input)
621             {
622                 return quserVOToEntity((QuserVO)input);
623             }
624         };
625 
626 
627     /**
628      * {@inheritDoc}
629      */
630     @Override
631     public void toQuserVO(
632         Quser source,
633         QuserVO target)
634     {
635         target.setQuserId(source.getQuserId());
636         target.setQuserCd(source.getQuserCd());
637         target.setQuserLastNm(source.getQuserLastNm());
638         target.setQuserFirstNm(source.getQuserFirstNm());
639         target.setQuserIntranetLg(source.getQuserIntranetLg());
640         target.setQuserExtranetLg(source.getQuserExtranetLg());
641         target.setQuserEMail(source.getQuserEMail());
642         target.setQuserAddress(source.getQuserAddress());
643         target.setQuserPhone(source.getQuserPhone());
644         target.setQuserOrgan(source.getQuserOrgan());
645         target.setQuserAdminCenter(source.getQuserAdminCenter());
646         target.setQuserSite(source.getQuserSite());
647         target.setQuserLdapPresent(source.getQuserLdapPresent());
648         target.setQuserCreationDt(source.getQuserCreationDt());
649         target.setUpdateDt(source.getUpdateDt());
650         // No conversion for target.department (can't convert source.getDepartment():Department to fr.ifremer.quadrige3.core.vo.administration.user.DepartmentVO)
651         // No conversion for target.privileges (can't convert source.getPrivileges():fr.ifremer.quadrige3.core.dao.referential.Privilege to fr.ifremer.quadrige3.core.vo.administration.user.PrivilegeVO)
652     }
653 
654     /**
655      * {@inheritDoc}
656      */
657     @Override
658     public QuserVO toQuserVO(final Quser entity)
659     {
660         QuserVO target = null;
661         if (entity != null)
662         {
663             target =  new QuserVO();
664             this.toQuserVO(entity, target);
665         }
666         return target;
667     }
668 
669     /**
670      * {@inheritDoc}
671      */
672     @Override
673     public void quserVOToEntity(
674         QuserVO source,
675         Quser target,
676         boolean copyIfNull)
677     {
678         if (copyIfNull || source.getQuserCd() != null)
679         {
680             target.setQuserCd(source.getQuserCd());
681         }
682         if (copyIfNull || source.getQuserLastNm() != null)
683         {
684             target.setQuserLastNm(source.getQuserLastNm());
685         }
686         if (copyIfNull || source.getQuserFirstNm() != null)
687         {
688             target.setQuserFirstNm(source.getQuserFirstNm());
689         }
690         if (copyIfNull || source.getQuserIntranetLg() != null)
691         {
692             target.setQuserIntranetLg(source.getQuserIntranetLg());
693         }
694         if (copyIfNull || source.getQuserExtranetLg() != null)
695         {
696             target.setQuserExtranetLg(source.getQuserExtranetLg());
697         }
698         if (copyIfNull || source.getQuserEMail() != null)
699         {
700             target.setQuserEMail(source.getQuserEMail());
701         }
702         if (copyIfNull || source.getQuserAddress() != null)
703         {
704             target.setQuserAddress(source.getQuserAddress());
705         }
706         if (copyIfNull || source.getQuserPhone() != null)
707         {
708             target.setQuserPhone(source.getQuserPhone());
709         }
710         if (copyIfNull || source.getQuserOrgan() != null)
711         {
712             target.setQuserOrgan(source.getQuserOrgan());
713         }
714         if (copyIfNull || source.getQuserAdminCenter() != null)
715         {
716             target.setQuserAdminCenter(source.getQuserAdminCenter());
717         }
718         if (copyIfNull || source.getQuserSite() != null)
719         {
720             target.setQuserSite(source.getQuserSite());
721         }
722         if (copyIfNull || source.getQuserLdapPresent() != null)
723         {
724             target.setQuserLdapPresent(source.getQuserLdapPresent());
725         }
726         if (copyIfNull || source.getQuserCreationDt() != null)
727         {
728             target.setQuserCreationDt(source.getQuserCreationDt());
729         }
730         if (copyIfNull || source.getUpdateDt() != null)
731         {
732             target.setUpdateDt(source.getUpdateDt());
733         }
734     }
735 
736     /**
737      * {@inheritDoc}
738      */
739     @Override
740     @SuppressWarnings({"unchecked"})
741     public final Collection<LightQuserVO> toLightQuserVOCollection(Collection<?> entities)
742     {
743         Collection<LightQuserVO> result = new ArrayList<LightQuserVO>();
744         if (entities != null)
745         {
746             CollectionUtils.transform(entities, this.LIGHTQUSERVO_TRANSFORMER);
747             result.addAll((Collection<? extends LightQuserVO>) entities);
748         }
749         return result;
750     }
751 
752     /**
753      * {@inheritDoc}
754      */
755     @Override
756     @SuppressWarnings({ "unchecked" })
757     public final LightQuserVO[] toLightQuserVOArray(Collection<?> entities)
758     {
759         LightQuserVO[] result = null;
760         if (entities != null)
761         {
762             // Unchecked transformation: reuses entities Collection
763             final Collection collection = new ArrayList(entities);
764             this.toLightQuserVOCollection(collection);
765             result = (LightQuserVO[]) collection.toArray(new LightQuserVO[collection.size()]);
766         }
767         return result;
768     }
769 
770     /**
771      * Default implementation for transforming the results of a report query into a value object. This
772      * implementation exists for convenience reasons only. It needs only be overridden in the
773      * {@link QuserDaoImpl} class if you intend to use reporting queries.
774      * @param row
775      * @return toLightQuserVO(this.toEntity(row))
776      * @see QuserDao#toLightQuserVO(Quser)
777      */
778     protected LightQuserVO toLightQuserVO(Object[] row)
779     {
780         return this.toLightQuserVO(this.toEntity(row));
781     }
782 
783     /**
784      * This anonymous transformer is designed to transform entities or report query results
785      * (which result in an array of objects) to {@link LightQuserVO}
786      * using the Jakarta Commons-Collections Transformation API.
787      */
788     private Transformer LIGHTQUSERVO_TRANSFORMER =
789         new Transformer()
790         {
791             public Object transform(Object input)
792             {
793                 Object result = null;
794                 if (input instanceof Quser)
795                 {
796                     result = toLightQuserVO((Quser)input);
797                 }
798                 else if (input instanceof Object[])
799                 {
800                     result = toLightQuserVO((Object[])input);
801                 }
802                 return result;
803             }
804         };
805 
806     /**
807      * {@inheritDoc}
808      */
809     @Override
810     public final void lightQuserVOToEntityCollection(Collection<?> instances)
811     {
812         if (instances != null)
813         {
814             for (final Iterator<?> iterator = instances.iterator(); iterator.hasNext();)
815             {
816                 // - remove an objects that are null or not of the correct instance
817                 if (!(iterator.next() instanceof LightQuserVO))
818                 {
819                     iterator.remove();
820                 }
821             }
822             CollectionUtils.transform(instances, this.LightQuserVOToEntityTransformer);
823         }
824     }
825 
826     private final Transformer LightQuserVOToEntityTransformer =
827         new Transformer()
828         {
829             public Object transform(Object input)
830             {
831                 return lightQuserVOToEntity((LightQuserVO)input);
832             }
833         };
834 
835 
836     /**
837      * {@inheritDoc}
838      */
839     @Override
840     public void toLightQuserVO(
841         Quser source,
842         LightQuserVO target)
843     {
844     }
845 
846     /**
847      * {@inheritDoc}
848      */
849     @Override
850     public LightQuserVO toLightQuserVO(final Quser entity)
851     {
852         LightQuserVO target = null;
853         if (entity != null)
854         {
855             target =  new LightQuserVO();
856             this.toLightQuserVO(entity, target);
857         }
858         return target;
859     }
860 
861     /**
862      * {@inheritDoc}
863      */
864     @Override
865     public void lightQuserVOToEntity(
866         LightQuserVO source,
867         Quser target,
868         boolean copyIfNull)
869     {
870     }
871 
872     /**
873      * Gets the current <code>principal</code> if one has been set,
874      * otherwise returns <code>null</code>.
875      *
876      * @return the current principal
877      */
878     protected Principal getPrincipal()
879     {
880         return PrincipalStore.get();
881     }
882 
883     /**
884      * {@inheritDoc}
885      */
886     @Override
887     @SuppressWarnings({ "unchecked" })
888     public PaginationResult search(final int transform, final int pageNumber, final int pageSize, final Search search)
889     {
890         try
891         {
892             search.setPageNumber(pageNumber);
893             search.setPageSize(pageSize);
894             final PropertySearch propertySearch = new PropertySearch(
895                 this.getSession(), QuserImpl.class, search);
896             final List results = propertySearch.executeAsList();
897             this.transformEntities(transform, results);
898             return new PaginationResult(results.toArray(new Object[results.size()]), propertySearch.getTotalCount());
899         }
900         catch (HibernateException ex)
901         {
902             throw ex; /*super.convertHibernateAccessException(ex);*/
903         }
904     }
905 
906     /**
907      * {@inheritDoc}
908      */
909     @Override
910     public PaginationResult search(final int pageNumber, final int pageSize, final Search search)
911     {
912         return this.search(QuserDao.TRANSFORM_NONE, pageNumber, pageSize, search);
913     }
914 
915     /**
916      * {@inheritDoc}
917      */
918     @Override
919     public Set<?> search(final int transform, final Search search)
920     {
921         try
922         {
923             final PropertySearch propertySearch = new PropertySearch(
924                 this.getSession(), QuserImpl.class, search);
925             final Set<?> results = propertySearch.executeAsSet();
926             this.transformEntities(transform, results);
927             return results;
928         }
929         catch (HibernateException ex)
930         {
931             throw ex; /*super.convertHibernateAccessException(ex);*/
932         }
933     }
934 
935     /**
936      * {@inheritDoc}
937      */
938     @Override
939     @SuppressWarnings("unchecked")
940     public Set<Quser> search(final Search search)
941     {
942         return (Set<Quser>) this.search(QuserDao.TRANSFORM_NONE, search);
943     }
944 
945     /**
946      * Executes and returns the given Hibernate queryObject as a {@link PaginationResult} instance.
947      * @param queryObject
948      * @param transform
949      * @param pageNumber
950      * @param pageSize
951      * @return PaginationResult
952      */
953     @SuppressWarnings({ "unchecked" })
954     protected PaginationResult getPaginationResult(
955         final Query queryObject,
956         final int transform, int pageNumber, int pageSize)
957     {
958         try
959         {
960             final ScrollableResults scrollableResults = queryObject.scroll();
961             scrollableResults.last();
962             int totalCount = scrollableResults.getRowNumber();
963             totalCount = totalCount >= 0 ? totalCount + 1 : 0;
964             if (pageNumber > 0 && pageSize > 0)
965             {
966                 queryObject.setFirstResult(this.calculateFirstResult(pageNumber, pageSize));
967                 queryObject.setMaxResults(pageSize);
968             }
969             // Unchecked transformation because Set object is reused, cannot be strongly typed.
970             Set results = new LinkedHashSet(queryObject.list());
971             transformEntities(transform, results);
972             return new PaginationResult(results.toArray(new Object[results.size()]), totalCount);
973         }
974         catch (HibernateException ex)
975         {
976             throw ex; /*super.convertHibernateAccessException(ex);*/
977         }
978     }
979 
980     // spring-hibernate-dao-base merge-point
981 }