I’ve used eclipselink in a web project in NetBeans. It works nice and easy. How can I do the same in a project unrelated to the web (console application)?
In my web application I have:
@PersistenceUnit
EntityManagerFactory enf;
Which instantiates enf. This does not work in a console application.
In case of an Web or an application container, the container injects the
EntityManagerFactorywhen the@PersistenceUnitannotation is called. This will not hold good for a console application.The possible ways for achieving this are
Or
To write the initiation code yourself as follows.