There are following JPA persistence provider:
The Java Enterprise Edition (J2EE) supports JPA and supply a persistence provider. It uses the following elements to allow persistence management in EJB 3.0.
| import javax.persistence.Persistence; import javax.persistence.EntityManagerFactory; EntityManagerFactory emf = Persistence.createEntityManagerFactory("persistence_unit_name"); // paste your code here according to your requirement emf.close(); |
| import javax.persistence.EntityManager; EntityManager em = emf.createEntityManager(); // paste your code here according to your requirement em.close(); |
[Note: The injection of the EntityManager supports the following artifacts]
Query: The Java Persistence APIs defines the JPQL (JPA Query Language) that is used to select objects from data source. The JPQL query has an internal namespace which is declared in the from clause of the JPQL query. In JPQL, we define an arbitrary identifiers for assigning the entities. See the following JPQL query.
Query q = em.createQuery ("SELECT s FROM Student s");
In above query 's' is identifier that is assigned to the entity Student.
[Note: We can use "as" keyword. This is optionally that can be used when declaring an identifier in the "from" clause. Ex: SELECT s FROM s and SELECT s FROM Student AS s is synonymous.]
|
Recommend the tutorial |
Ask Questions? Discuss: Persistence
Post your Comment