22
33import guru .springframework .blog .hibernatepagination .domain .Product ;
44import guru .springframework .blog .hibernatepagination .util .HibernateUtil ;
5- import org .apache .log4j .Logger ;
65import org .hibernate .*;
76import org .hibernate .criterion .Order ;
87import org .hibernate .criterion .Projections ;
1110import java .util .List ;
1211
1312public class ProductDao {
14- private Logger log = Logger .getLogger (ProductDao .class );
1513 public void saveProducts () {
1614 Session session = HibernateUtil .getSessionFactory ().openSession ();
1715 Transaction trans = null ;
@@ -29,7 +27,7 @@ public void saveProducts() {
2927 } finally {
3028 session .close ();
3129 }
32- log . info ("Saved 30 products" );
30+ System . out . println ("Saved 30 products" );
3331 }
3432
3533 public int listPaginatedProductsUsingQuery (int firstResult , int maxResults ) {
@@ -42,9 +40,9 @@ public int listPaginatedProductsUsingQuery(int firstResult, int maxResults) {
4240 List <Product > products = (List <Product >) query .list ();
4341 if (products != null ) {
4442 paginatedCount = products .size ();
45- log . info ("Total Results: " + paginatedCount );
43+ System . out . println ("Total Results: " + paginatedCount );
4644 for (Product product : products ) {
47- log . info ("Retrieved Product using Query. Name: " + product .getProductName ());
45+ System . out . println ("Retrieved Product using Query. Name: " + product .getProductName ());
4846 }
4947 }
5048
@@ -68,9 +66,9 @@ public int listPaginatedProductsUsingCriteria(int firstResult, int maxResults) {
6866 List <Product > products = (List <Product >) criteria .list ();
6967 if (products != null ) {
7068 paginatedCount = products .size ();
71- log . info ("Total Results: " + paginatedCount );
69+ System . out . println ("Total Results: " + paginatedCount );
7270 for (Product product : products ) {
73- log . info ("Retrieved Product using Criteria. Name: " + product .getProductName ());
71+ System . out . println ("Retrieved Product using Criteria. Name: " + product .getProductName ());
7472 }
7573 }
7674
@@ -97,7 +95,7 @@ public int listPaginatedProductsUsingScrollableResults(int firstResult, int maxR
9795 List <Object []> products = criteria .list ();
9896 if (products != null ) {
9997 for (Object [] product : products ) {
100- log . info ("Retrieved Product using ScrollableResults. Name: " + product [0 ] + " out of " +totalRecords + " products" );
98+ System . out . println ("Retrieved Product using ScrollableResults. Name: " + product [0 ] + " out of " +totalRecords + " products" );
10199 }
102100 }
103101
@@ -135,7 +133,7 @@ public void deleteAllProducts() {
135133 } finally {
136134 session .close ();
137135 }
138- log . info ("Deleted all products" );
136+ System . out . println ("Deleted all products" );
139137
140138 }
141139}
0 commit comments