The change from my DAO looks like this:
private EntityManager entityManager;
public void alterar() throws Exception {
System.out.println("T encontrada");
System.out.println("iniciando Alterar id: " + this.getId());
System.out.println("this Class" + this.getClass());
T encontrada = (T) entityManager.find(this.getClass(), this.getId());
System.out.println("encontrada");
try {
System.out.println("Iniciando a transacao de alteracao");
EntityManagerControl.transactionBegin(entityManager);
entityManager.merge(this);
EntityManagerControl.transactionCommit(entityManager);
} catch (Exception e) {
EntityManagerControl.transactionRollback(entityManager);
e.printStackTrace();
} finally {
// manager.close();
}
}
I have records in the database and I'm with that record recorded in the bank but the moment I declare in the Controller object.change (), it's nullPointer in the find following command:
T encontrada = (T) entityManager.find(this.getClass(), this.getId());
How do you fix this error?