Skip to content

Instantly share code, notes, and snippets.

View PlutonicJ's full-sized avatar
👨‍💻

Jens Kötterheinrich PlutonicJ

👨‍💻
View GitHub Profile
@PlutonicJ
PlutonicJ / keybase.md
Last active September 26, 2023 05:54

Keybase proof

I hereby claim:

  • I am plutonicj on github.
  • I am cybi (https://keybase.io/cybi) on keybase.
  • I have a public key ASC1Rte2uWRwVULdGUyM0LDlHDpDJ71JkGtBOcxvEolAVAo

To claim this, I am signing this object:

@PlutonicJ
PlutonicJ / EntityManagerHelper.java
Created January 18, 2017 23:26
A helper class to execute some actions with an EntityManager within a transaction
public class EntityManagerHelper {
public static <ENTITY_TYPE> void persistInTransaction(EntityManager entityManager, ENTITY_TYPE entity) {
executeInTransaction(entityManager, () -> entityManager.persist(entity));
}
public static <EC> void removeAll(EntityManager em, Class<EC> entityClass) {
executeInTransaction(em, () -> {
List<EC> all = findAll(em, entityClass);
for (EC entity : all) {
em.remove(entity);