Joined: Tue Mar 27, 2007 10:55 pm Posts: 2103 Location: Earth Has thanked: 39 time Have thanks: 56 time
Delete using native query , the following example is supposed to delete a topic record using its id .Notice that native query use actual physical names of database . For example TOPIC (Database table name ) instead of Topic (Name of the entity class ) .
/** * @param id * * @return * number of affected columns . */ public int deleteTopicById(int id){ Query query = entityManager.createNativeQuery("Delete from TOPIC where ID=?"); query.setParameter(1, id); return query.executeUpdate();