import java.util.Iterator;
import org.hibernate.Query;
import org.hibernate.Session;
/**
* For a given subject, dumps the list of people to be emailed.
*
* @author bob
*/
public class Dumper {
public static void main(String[] args) {
String subject = "tech";
if (args.length != 0)
subject = args[0];
Session sess = SessionFactoryFascade.getSession4ReadOrUpdate();
Query q = sess
.createQuery("from Person p, Subscription s where p.email = s.email and s.subject ='"
+ subject + "'");
System.out.println("Email users of subject: " + subject);
for (Iterator iter = q.iterate(); iter.hasNext();) {
Person p = (Person) ((Object[]) iter.next())[0];
System.out.println(p);
}
}
}
|