I have basic knowledge, not to say minimum, of programming. I need to create a CRUD model for school work. I did it through this video link .
First create my database in Java DB , then create a MasterTable (Swing GUI> Master / Detail Sample Form) from a table in that database, and that's when the armed CRUD came out.
But this way of doing it does not fulfill some of the requirements that my teacher wants the program to perform.
This is how the program runs, with the records already loaded in the database and when I click "High" it enables me the text fields
The problem is that when I click the High or Create button, it does not generate the auto-incremented ID but I must enter the ID, I would like to solve that. And I need you to let me add two buttons to import and export in CSV.java. I hope you can help me, thank you very much!
PD: I leave the code of the buttons for doubts:
private void bActualizarActionPerformed(java.awt.event.ActionEvent evt) {
entityManager.getTransaction().rollback();
entityManager.getTransaction().begin();
java.util.Collection data = query.getResultList();
for (Object entity : data) {
entityManager.refresh(entity);
}
list.clear();
list.addAll(data);
}
private void bBajaActionPerformed(java.awt.event.ActionEvent evt) {
int[] selected = masterTable.getSelectedRows();
List<tp.pkgfinal.paradigmas.Tablaempleados> toRemove = new ArrayList<tp.pkgfinal.paradigmas.Tablaempleados>(selected.length);
for (int idx = 0; idx < selected.length; idx++) {
tp.pkgfinal.paradigmas.Tablaempleados t = list.get(masterTable.convertRowIndexToModel(selected[idx]));
toRemove.add(t);
entityManager.remove(t);
}
list.removeAll(toRemove);
}
private void bAltaActionPerformed(java.awt.event.ActionEvent evt) {
tp.pkgfinal.paradigmas.Tablaempleados t = new tp.pkgfinal.paradigmas.Tablaempleados();
entityManager.persist(t);
list.add(t);
int row = list.size() - 1;
masterTable.setRowSelectionInterval(row, row);
masterTable.scrollRectToVisible(masterTable.getCellRect(row, 0, true));