package org.domain.seamWebHibernate.session;
import java.math.BigDecimal;
import java.util.Iterator;
import java.util.List;
import javax.persistence.EntityManager;
import org.domain.seamWebHibernate.entity.Provincia;
import org.hibernate.Query;
import org.hibernate.Session;
import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Logger;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.faces.FacesMessages;
import org.jboss.seam.log.Log;
@Name("ping")
public class Ping {
@Logger private Log log;
@In FacesMessages facesMessages;
@In
EntityManager entityManager;
private Session getSession() {
return ((Session)((org.jboss.seam.persistence.EntityManagerProxy) entityManager).getDelegate());
}
public void doPing()
{
// implement your business logic here
Provincia provincia;
log.info("ping.doPing() action called");
facesMessages.add("doPing");
Query q = getSession().getNamedQuery("provincia.provinciasDelPais");
q.setParameter("_pais", new BigDecimal(4));
List list = q.list();
Iterator it = list.iterator();
while (it.hasNext()) {
provincia = (Provincia)it.next();
System.out.println(provincia.toString());
}
}
// add additional action methods
}
No hay comentarios:
Publicar un comentario