M
M
muratruslanov2017-01-24 19:29:14
Java
muratruslanov, 2017-01-24 19:29:14

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

1 answer(s)
A
aol-nnov, 2017-01-24
@muratruslanov

in spring boot, for example, without a single xml. Open source and go! :)
here you can start, then find a specific implementation.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question