Coverage Report - br.com.arsmachina.authentication.dao.hibernate.PermissionDAOImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
PermissionDAOImpl
0%
0/6
N/A
0
 
 1  
 // Copyright 2008 Thiago H. de Paula Figueiredo
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package br.com.arsmachina.authentication.dao.hibernate;
 16  
 
 17  
 import org.hibernate.Criteria;
 18  
 import org.hibernate.SessionFactory;
 19  
 import org.hibernate.criterion.Restrictions;
 20  
 
 21  
 import br.com.arsmachina.authentication.dao.PermissionDAO;
 22  
 import br.com.arsmachina.authentication.entity.Permission;
 23  
 import br.com.arsmachina.dao.SortCriterion;
 24  
 import br.com.arsmachina.dao.hibernate.GenericDAOImpl;
 25  
 
 26  
 
 27  
 /**
 28  
  * {@link PermissionDAO} implementation using Hibernate
 29  
  * 
 30  
  * @author Thiago H. de Paula Figueiredo
 31  
  */
 32  
 public class PermissionDAOImpl extends GenericDAOImpl<Permission, Integer> implements PermissionDAO {
 33  
 
 34  
         /**
 35  
          * Single constructor of this class.
 36  
          * 
 37  
          * @param sessionFactory a {@link SessionFactory}. It cannot be null.
 38  
          */
 39  
         public PermissionDAOImpl(SessionFactory sessionFactory) {
 40  0
                 super(sessionFactory);
 41  0
         }
 42  
 
 43  
         /**
 44  
          * Returns {@link Constants#ASCENDING_NAME_SORT_CRITERIA}.
 45  
          * 
 46  
          * @see br.com.arsmachina.dao.hibernate.GenericDAOImpl#getDefaultSortCriteria()
 47  
          */
 48  
         @Override
 49  
         public SortCriterion[] getDefaultSortCriteria() {
 50  0
                 return Constants.ASCENDING_NAME_SORT_CRITERIA;
 51  
         }
 52  
 
 53  
         /**
 54  
          * @see br.com.arsmachina.authentication.dao.PermissionDAO#findByName(java.lang.String)
 55  
          */
 56  
         public Permission findByName(String name) {
 57  
                 
 58  0
                 final Criteria criteria = createCriteria();
 59  0
                 criteria.add(Restrictions.eq("name", name));
 60  
                 
 61  0
                 return (Permission) criteria.uniqueResult();
 62  
                 
 63  
         }
 64  
 
 65  
 }