1 Reply Latest reply on May 27, 2009 1:07 AM by Francisco Jose Peredo Noguez

    Help with this class

    Bryan Enriquez Newbie

      I'm new in java, and I have a problem. In this class I make a query to the database and return the result but this not return nothing.

      When I call the method in the main program, it return an exception that says java.lang.NullPointerException.

      This is the code of the class and the main program:

      import suite.mod_administracion.entity.*;
      import org.jboss.seam.annotations.Name;
      import org.jboss.seam.framework.EntityQuery;

      import java.util.ArrayList;
      import java.util.List;
      import java.util.Arrays;
      import javax.persistence.EntityManager;
      import org.jboss.seam.annotations.In;

      public class Actividad extends EntityQuery {

           private static final long serialVersionUID = 1L;

           private static final String[] RESTRICTIONS = { };
           public String getEjbql() {
                return "select campo from NmcampoPlantilla campo";
           public List<String> getRestrictions() {
                return Arrays.asList(RESTRICTIONS);
           @In     EntityManager entityManager;
           public List<String> camposActividad(){
                     return entityManager.createQuery("select actividad from Nmactividad actividad, Nmplantilla plantilla where actividad.idListaPlantilla=plantilla.idListaPlantilla order by actividad.actividad").getResultList();

      This is the main program:

      public class probarActividad {

           public static void main(String[] args) {
                List<String> a = new ArrayList<String>();
                Actividad act = new Actividad();
                catch (Exception e){

      The method camposActividad() the method should return a List of object.

      Can anybody look the code and helpme?