0
Gent,and I’m trying to create a method in which I delete the database record. However, the following error is occurring:
Caused by: org.hibernate.MappingException: Unknown entity: java.lang.Integer
Code:
public void delete(int user) {
Consultar consulta = new Consultar ();
EntityManager deletar = consulta.getEntityManager();
System.out.println("usuário deletado"+user);
deletar.getTransaction().begin();
deletar.remove(user);
deletar.getTransaction().commit();
}
I made this change but nothing happens. public void delete(User user) { Consult query = new Query (); //Long primaryKey = Long.parseLong(user); Entitymanager Entity = query.getEntityManager(); System.out.println("user deleted"+user); Entity.getTransaction(). Begin(); Entity.remove(user); Entity.getTransaction(). commit(); }
– Cleiton Conceição
in deletar.remove you have to insert an entity and not its code, maybe you can use findById to find the entity and then delete it
– Weslley Barbosa