1 Reply Latest reply on Jul 27, 2008 4:08 PM by Pete Muir

    EntityHome @Log dependancy

    Timothy Whitehead Newbie

      I recently used an EntityHome class to create a number of entites in a batch manner.
      The following function is inside flightHome

      public void batchCreateFlights() {
           Calendar cal = new GregorianCalendar();
           cal.setTime(Utils.dateRound(batchFrom, true, Calendar.DATE));     
           while (cal.getTime().before(Utils.dateRound(batchTo, false, Calendar.DATE))) {
                if (cal.get(Calendar.DAY_OF_WEEK) == getWeekDay().getCalendarDay()) {
                     FlightHome flightHome = new FlightHome();
                     // copy values off  getInstance into flightHome.getInstance()
                     //and generate some values
                cal.add(Calendar.DATE, 1);

      However I got a null pointer exception because EntityHomes persist() uses an injected @Log which doesn't exist when EntityHome is not used as a seam component as above.

      I solved it by overriding the relevant function without the @Log being used:

      protected void createdMessage() {
           getFacesMessages().add(new FacesMessage("Created flight no: "+getInstance().getFlightno()));