title: can't get data from database using spring-mvc and hibernate
body: <p>this is my code:
  my model class:</p>
  
  <pre><code>@Entity
  @Table(name="admin")
  public class Admin extends Profile{
      public Admin(){}
  
      public Admin(String mail, String name, String lastName, String password, Date birthDate, int gsm){
          super(mail, name, lastName, password, birthDate, gsm);
      }
  }
  </code></pre>
  
  <p>the DAO class:</p>
  
  <pre><code>@Repository
  public class AdminDAO {
  
      private static final Logger logger = LoggerFactory.getLogger(AdminDAO.class);
  
      private SessionFactory sessionFactory;
  
      public void setSessionFactory(SessionFactory sf){
          this.sessionFactory = sf;
      }
      @SuppressWarnings("unchecked")
      public List&lt;Admin&gt; listAdmins() {
          Session session = this.sessionFactory.getCurrentSession();
          List&lt;Admin&gt; adminsList = session.createQuery("from Admin").list();
          for(Admin a : adminsList){
              logger.info("Admin List::"+a);
          }
          return adminsList;
      }
  }
  </code></pre>
  
  <p>my Service class:</p>
  
  <pre><code>@Service
  
      public class AdminService {
  
          @Autowired
          private AdminDAO adminDAO;
  
          public void setAdminDAO(AdminDAO adminDAO) {
              this.adminDAO = adminDAO;
          }
          @Transactional
          public List&lt;Admin&gt; listAdmins() {
              return this.adminDAO.listAdmins();
          }
      }
  </code></pre>
  
  <p>when i run my code i get this error message:</p>
  
  <blockquote>
    <p>java.lang.NullPointerException
    at com.journaldev.spring.dao.AdminDAO.listAdmins(AdminDAO.java:38)</p>
  </blockquote>
  
  <p>i added an admin manually in my database, but it still showing the null pointer exception
  what i am doing wrong ??
  note: i have another class that works fine, it gets all entities and when the database is empty, it doesn't generate null pointer exception</p>