I am trying to make a method to load a bombobox in an application of > mysql using jpa . I use:
- NETBEANS 8.2
- JAVA version "1.8.0_131"
- EclipseLink (JPA 2.1)
- JDBC Library
Form code
public jfrm_Administrador() {
initComponents();
emf = Persistence.createEntityManagerFactory("AdministradorRolesPU");
em = emf.createEntityManager();
loadComboBox();
}
And the method of loading jcombobox
that does NOT work
public void loadComboBox() {
//Creamos una Query
//"Pais.findAll" es una query que fue definida automaticamente gracias al mapeo de la db
//Luego obtenemos los resultados y los recorremos
Iterator it = em.createNamedQuery("Tblpermiso.findByDescripcion").getResultList().iterator();
while(it.hasNext()) {
//Agrego el resultado al Combobox
this.jComboBox1.addItem(((Tblpermiso)it.next()));
}
}
How do I do the method correctly?