I'm creating a JAVA EE project with JPA and JSF primefaces on a glassfish server.
Development environment is ECLIPSE IDE
Here is what I've done so far:
Here is what I want to do:
Question: Am I on the right path ? (conception level, or am I missing something out) + How to do my next step and that is generate the entity managers for my entities, Thanks in advance!
You're on the right path, but entity managers and session beans are not the same. You will use an EntityManager
inside your session beans, like so:
@Stateless
public class MyService {
@PersistenceContext
private EntityManager em;
}
Make sure you have your persistence.xml
file present. Further reading and examples can be found here.
Example persistence.xml
file that uses a container managed datasource located through JNDI at jdbc/MyOrderDB
:
<persistence>
<persistence-unit name="OrderManagement">
<jta-data-source>jdbc/MyOrderDB</jta-data-source>
</persistence-unit>
</persistence>