Package org.fryske_akademy.jpa
Class JpaUtil
- java.lang.Object
-
- org.fryske_akademy.jpa.JpaUtil
-
public class JpaUtil extends Object
-
-
Constructor Summary
Constructors Constructor Description JpaUtil()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> List<T>findAll(Class<T> type, jakarta.persistence.EntityManager entityManager)static PrincipalfindPrincipal()Looks for principal in CDIstatic Optional<EntityInterface>fromException(Throwable ex)looks for an EntityInterface in a EntityException or ConstraintViolationException (in the first ConstraintViolation).static jakarta.persistence.EntityManagerFactorygetEntityManagerFactory(String name)return a cached EntityManagerFactory, make sure you close it when it is not needed anymore.
-
-
-
Method Detail
-
getEntityManagerFactory
public static jakarta.persistence.EntityManagerFactory getEntityManagerFactory(String name)
return a cached EntityManagerFactory, make sure you close it when it is not needed anymore.- Parameters:
name-- Returns:
-
findPrincipal
public static Principal findPrincipal() throws IllegalStateException
Looks for principal in CDI- Returns:
- Throws:
IllegalStateException
-
findAll
public static <T> List<T> findAll(Class<T> type, jakarta.persistence.EntityManager entityManager)
-
fromException
public static Optional<EntityInterface> fromException(Throwable ex)
looks for an EntityInterface in a EntityException or ConstraintViolationException (in the first ConstraintViolation).- Parameters:
ex-- Returns:
- an EntityInterface or empty optional
-
-