1 Reply Latest reply on May 27, 2009 1:07 AM by luxspes

    Help with this class

      Hello,
      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;


      @Name("Actividad")
      public class Actividad extends EntityQuery {

           private static final long serialVersionUID = 1L;

           private static final String[] RESTRICTIONS = { };
           
           @Override
           public String getEjbql() {
                return "select campo from NmcampoPlantilla campo";
           }
           
           @Override
           public List<String> getRestrictions() {
                return Arrays.asList(RESTRICTIONS);
           }
           
           @In     EntityManager entityManager;
           @SuppressWarnings("unchecked")
           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) {
                try{
                
                List<String> a = new ArrayList<String>();
                
                Actividad act = new Actividad();
                act.camposActividad();
                
                }
                catch (Exception e){
                      System.err.println(e);
                      System.exit(0);
                    } 
           
           }     
      }


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


      Can anybody look the code and helpme?


      Thanks