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

    Help please, this class return an error

    Bryan Enriquez Newbie

      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:


      @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