CHAPTER 11 (Web hosting rating) n FILTERING THE RESULTS OF SEARCHES
CHAPTER 11 n FILTERING THE RESULTS OF SEARCHES 229 n FILTERING THE RESULTS OF SEARCHES 229 Listing 11-2. Invoking Filters from Code package com.hibernatebook.filters; import java.util.Iterator; import org.hibernate.Filter; import org.hibernate.Query; import org.hibernate.Session; import org.hibernate.SessionFactory; import org.hibernate.Transaction; import org.hibernate.cfg.Configuration; public class SimpleFilterExample { public static void main (String args[]) { SessionFactory factory = new Configuration().configure().buildSessionFactory(); Session session = factory.openSession(); //insert the users insertUser(”ray”,true,session); insertUser(”jason”,true,session); insertUser(”beth”,false,session); insertUser(”judy”,false,session); insertUser(”rob”,false,session); //Show all users System.out.println(”===ALL USERS===”); displayUsers(session); //Show activated users Filter filter = session.enableFilter(”activatedFilter”); filter.setParameter(”activatedParam”,new Boolean(true)); System.out.println(”===ACTIVATED USERS===”); displayUsers(session); //Show nonactivated users filter.setParameter(”activatedParam”,new Boolean(false)); System.out.println(”===NON-ACTIVATED USERS===”); displayUsers(session);
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.