0

I'm learning Netbeans Platform and I'm in the process of following this tutorial:

Link to Netbeans Tutorial

I've reached the point of running the prototype but I'm getting the following warning in the output window:

warning: [options] bootstrap class path not set in conjunction with -source 1.6
warning: No processor claimed any of these annotations: javax.annotation.Generated
~/BDManager/CustomerViewer/src/org/shop/viewer/CustomerViewerTopComponent.java:53: warning: [unchecked] unchecked conversion
       List<Employee> resultList = query.getResultList();
  required: List<Employee>
  found:    List
3 warnings

My EntityManager is as follows:

EntityManager entityManager = Persistence.createEntityManagerFactory("CustomerLibraryPU").createEntityManager();
       Query query  = entityManager.createNamedQuery("Employee.findAll");

       List<Employee> resultList = query.getResultList();
       for (Employee c : resultList){
           jTextArea1.append(c.getFirstName()+" "+c.getLastName()+"\n");
       }

Referencing #4 in Designing the Interface in the tutorial, instead of the List being List<Customer>, my List is List<Employee> as the entity class is returning data from a table called employee in my database.

How do I get rid of this warning?

Lymedo
  • 576
  • 9
  • 21

1 Answers1

1

That comes from the fact that getResultList() returns an untyped List (a raw type) which you are assigning to a typed List (where type parameter = Employee):

java.util.List getResultList()

Execute a SELECT query and return the query results as an untyped List.

More on generics and raw types here.

For suppressing that warning you can use @SuppressWarnings("unchecked"). Check for example here and in other related StackOverflow answers on how to do it.

Community
  • 1
  • 1
Baderous
  • 1,069
  • 1
  • 11
  • 32