In the following code I am trying to get a List of Products which contains all the products in the database:
public List getAllProducts() throws
Your answer not only adds a cast, but switches from SQL to HQL. Since your 2nd query is in HQL, Hibernate is able to use mapping information to know what class to return. This is the preferred way to do things in Hibernate, but if you had to use SQL for some reason you could achieve the same thing with:
(List)session.createSQLQuery("SELECT * FROM Products").addEntity(Products.class).list();