10 hibernate jpa

Download 10 Hibernate JPA

If you can't read please download the document

Upload: gharsallah-nizar

Post on 20-Nov-2014

164 views

Category:

Documents


13 download

TRANSCRIPT

2009 coreservlets.com

Java P J Persistence API i tOriginals of Slides and Source Code for Examples: http://courses.coreservlets.com/Course-Materials/hibernate.htmlCustomized Java EE Training: http://courses.coreservlets.com/Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.

2009 coreservlets.com

For live Spring & Hibernate training, see courses at http://courses.coreservlets.com/. t htt // l t /Taught by the experts that brought you this tutorial. Available at public venues, or customized versions venues can be held on-site at your organization.C Courses d developed and t l d d taught b M t H ll ht by Marty Hall Courses developed and taught by EE Training: http://courses.coreservlets.com/ Customized Java coreservlets.com experts (edited by Marty) Spring, Hibernate/JPA, EJB3, Ruby/Rails Java 5, Java 6, intermediate/beginning servlets/JSP, advanced servlets/JSP, Struts, JSF, Ajax, GWT, custom mix of topics

Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Contact [email protected] for details Developed and taught by well-known author and developer. At public venues or onsite at your location.

Topics in This Section p Become acquainted with the Java q Persistence API (JPA) Compare and contrast Hibernate and JPA Learn how to setup and use Hibernate as a JPA provider

5

2009 coreservlets.com

Java Persistence API (JPA)Originals of Slides and Source Code for Examples: http://courses.coreservlets.com/Course-Materials/hibernate.htmlCustomized Java EE Training: http://courses.coreservlets.com/Servlets, JSP, Struts, JSF/MyFaces/Facelets, Ajax, GWT, Spring, Hibernate/JPA, Java 5 & 6. Developed and taught by well-known author and developer. At public venues or onsite at your location.

Java Persistence API Developed as part of Java Specification R S ifi ti Request (JSR) 220 t Original goal to simplify EJB CMP entity beans

Si lifi th d Simplifies the development of J l t f Java EE and Java SE applications using data persistence i t Brings the Java community behind a single, standard persistence API i l t d d i t Draws upon the best ideas from existing persistence technologies Hibernate, TopLink, and JDO

Java Persistence API Usable both within Java SE environments as well as Java EE i t ll J POJO based Works with XML descriptors and k ih d i d annotations

E i ti EJB CMP applications Existing li ti continue to work unchanged M become part of Java SE May b t fJ Likely that this issue will be considered by the J th Java SE expert group in a future Java t i f t J SE release

Main JPA Components p Entity Classes Entity Manager Persistence Context

EntityManagerFactory y EntityTransaction Persistence Unit persistence.xml

Java Persistence Query Language (JPAQL) Query

Hibernate vs. JPA Components pJPAEntity Classes EntityManagerFactory E tit M F t EntityManager Persistence EntityTransaction E tit T ti Query Persistence Unit

HibernatePersistent Classes SessionFactory S i F t Session Configuration Transaction T ti Query Hibernate Config

Persistence Unit Defines all entity classes that are managed by JPA p Identified in the persistence.xml configuration file Entity classes and configuration y g files are packaged together The JAR or directory that contains the persistence.xml is called the root of the i li ll d h f h persistence unit Needs to be inside a META-INF directory Whether or not inside a jar

p persistence.xml

org.hibernate.ejb.HibernatePersistence hib t jb Hib t P i t orm.xml courses.hibernate.vo.Account c s s hib t Acc t courses.hibernate.vo.AccountOwner courses.hibernate.vo.AccountTransaction courses.hibernate.vo.EBill courses hibernate vo EBill courses.hibernate.vo.EBiller...

p persistence.xml... properties / ti

p persistence.xml: Pass-Through g Can satisfy the persistence.xml requirement with a pass th ith through to an existing Hibernate ht i ti Hib t configuration file