Answer the question
In order to leave comments, you need to log in
How to create EntityManager without xml (runtime)?
How to create EntityManager without xml (runtime) ?
I saw someone in the project. In resources, he had only application.properties
. I get a NullPointerException with this code.
@Repository
public abstract class BaseCustomRepository {
@PersistenceContext
protected EntityManager entityManager;
protected Class aClass;
public BaseCustomRepository(Class aClass) {
this.aClass = aClass;
}
public Criteria getCriteria(){
Session session = entityManager.unwrap(Session.class);
return session.createCriteria(aClass);
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question