2

I want to call the BookDAO in my modelproject, which uses the annotation @PersistenceContext. Because I work in a Java SE project, the annotation will not work. Is there any posibility to keep the annotation for my Webapplication and to use this class also in the Java SE project?

My BookRepository :

public class BookJPARepository implements BookRepository {   

@PersistenceContext
private EntityManager em;

...
}

I have heard it's a possibility to inject the constructor, but I didn't find yet a solution

Kind Regards

BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555

0 Answers0