I am trying to create simple repository. But can’t get EntityManager instance.
As mentioned in documentation I create new component, but javax.persistence.Persistence has no getEntityManager() method.
And I don’t see any other Persistence anywhere in dependencies.
@PersistenceContext EntityManager em
doesn’t work eather.
My full code of repository:
import org.springframework.stereotype.Component;
import javax.inject.Inject;
import javax.persistence.Persistence;
@Component(CustomUserRepository.NAME)
public class CustomUserRepository {
public static final String NAME = "cuba_CustomUserRepository";
@Inject
private Persistence persistence;
public void findUserByEmbriaId(String embriaId) {
persistence.getEntityManager(); // Compilation error. There are no getEntityManager()
}
}