quarkus
quarkus copied to clipboard
Put in line delete method of Quakus Panache Commons JPA methods with Spring Data Commons.
Description
Looking at the Spring implementation of CrudRepository backed by SimpleJpaRepository there are some divergences to Quarkus AbstractJpaOperations.
The method delete(Object entity) on Spring tries to find the entity first through the entity manager before calling the delete. This helps a lot when you have a detached entity you want to delete, as you don't need to wrap the call in any upper transaction.
Reference:
Implementation ideas
Put in line Quarkus's AbstractJpaOperations with Spring's SimpleJpaRepository by doing something similar to:
public void delete(Object entity) {
EntityManager em = getEntityManager(entity.getClass());
Class<?> type = ProxyUtils.getUserClass(entity);
Object existing = em.find(type, entityInformation.getId(entity));
if (existing == null) {
return;
}
em.remove(em.contains(entity) ? entity : em.merge(entity));
}
/cc @FroMage, @geoand, @loicmathieu