Enviar búsqueda
Cargar
JPA - Java Persistence API
•
0 recomendaciones
•
103 vistas
Thomas Wöhlke
Seguir
Vortrag bei ObjectCode GmbH, Lünen anno 2008 sowie ImmobilienScout GmbH, Berlin anno 2009
Leer menos
Leer más
Presentaciones y charlas públicas
Vista de diapositivas
Denunciar
Compartir
Vista de diapositivas
Denunciar
Compartir
1 de 29
Descargar ahora
Descargar para leer sin conexión
Recomendados
Java CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server Database
Dudy Ali
Overview of JPA (Java Persistence API) v2.0
Overview of JPA (Java Persistence API) v2.0
Bryan Basham
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
Java Enterprise Edition
Java Enterprise Edition
Francesco Nolano
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Edureka!
EJB3 Basics
EJB3 Basics
Emprovise
Implicit objects advance Java
Implicit objects advance Java
Darshit Metaliya
Dependency Injection
Dependency Injection
Giovanni Scerra ☃
Recomendados
Java CRUD Mechanism with SQL Server Database
Java CRUD Mechanism with SQL Server Database
Dudy Ali
Overview of JPA (Java Persistence API) v2.0
Overview of JPA (Java Persistence API) v2.0
Bryan Basham
Java Persistence API (JPA) Step By Step
Java Persistence API (JPA) Step By Step
Guo Albert
Java Enterprise Edition
Java Enterprise Edition
Francesco Nolano
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Lambda Expressions in Java | Java Lambda Tutorial | Java Certification Traini...
Edureka!
EJB3 Basics
EJB3 Basics
Emprovise
Implicit objects advance Java
Implicit objects advance Java
Darshit Metaliya
Dependency Injection
Dependency Injection
Giovanni Scerra ☃
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
Introduction to java beans
Introduction to java beans
Hitesh Parmar
Testing with JUnit 5 and Spring
Testing with JUnit 5 and Spring
VMware Tanzu
jpa-hibernate-presentation
jpa-hibernate-presentation
John Slick
Solid Principles
Solid Principles
NexThoughts Technologies
Jdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
JDBC
JDBC
People Strategists
Hibernate Presentation
Hibernate Presentation
guest11106b
Spring boot jpa
Spring boot jpa
Hamid Ghorbani
Spring Data JPA
Spring Data JPA
Knoldus Inc.
SOLID
SOLID
Panos Pnevmatikatos
Curso Java Avanzado 5 Ejb
Curso Java Avanzado 5 Ejb
Emilio Aviles Avila
Dependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
Spring framework in depth
Spring framework in depth
Vinay Kumar
Java EE Introduction
Java EE Introduction
ejlp12
Java packages
Java packages
Shreyans Pathak
JPA For Beginner's
JPA For Beginner's
NarayanaMurthy Ganashree
Interfaces & Packages V2
Interfaces & Packages V2
Dr Anjan Krishnamurthy
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
Accessing Mule variables in groovy
Accessing Mule variables in groovy
Anirban Sen Chowdhary
Smoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
Markus Eisele
Más contenido relacionado
La actualidad más candente
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Edureka!
Introduction to java beans
Introduction to java beans
Hitesh Parmar
Testing with JUnit 5 and Spring
Testing with JUnit 5 and Spring
VMware Tanzu
jpa-hibernate-presentation
jpa-hibernate-presentation
John Slick
Solid Principles
Solid Principles
NexThoughts Technologies
Jdbc Ppt
Jdbc Ppt
Centre for Budget and Governance Accountability (CBGA)
JDBC
JDBC
People Strategists
Hibernate Presentation
Hibernate Presentation
guest11106b
Spring boot jpa
Spring boot jpa
Hamid Ghorbani
Spring Data JPA
Spring Data JPA
Knoldus Inc.
SOLID
SOLID
Panos Pnevmatikatos
Curso Java Avanzado 5 Ejb
Curso Java Avanzado 5 Ejb
Emilio Aviles Avila
Dependency injection presentation
Dependency injection presentation
Ahasanul Kalam Akib
Spring framework in depth
Spring framework in depth
Vinay Kumar
Java EE Introduction
Java EE Introduction
ejlp12
Java packages
Java packages
Shreyans Pathak
JPA For Beginner's
JPA For Beginner's
NarayanaMurthy Ganashree
Interfaces & Packages V2
Interfaces & Packages V2
Dr Anjan Krishnamurthy
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
VMware Tanzu
Accessing Mule variables in groovy
Accessing Mule variables in groovy
Anirban Sen Chowdhary
La actualidad más candente
(20)
Java Design Patterns Tutorial | Edureka
Java Design Patterns Tutorial | Edureka
Introduction to java beans
Introduction to java beans
Testing with JUnit 5 and Spring
Testing with JUnit 5 and Spring
jpa-hibernate-presentation
jpa-hibernate-presentation
Solid Principles
Solid Principles
Jdbc Ppt
Jdbc Ppt
JDBC
JDBC
Hibernate Presentation
Hibernate Presentation
Spring boot jpa
Spring boot jpa
Spring Data JPA
Spring Data JPA
SOLID
SOLID
Curso Java Avanzado 5 Ejb
Curso Java Avanzado 5 Ejb
Dependency injection presentation
Dependency injection presentation
Spring framework in depth
Spring framework in depth
Java EE Introduction
Java EE Introduction
Java packages
Java packages
JPA For Beginner's
JPA For Beginner's
Interfaces & Packages V2
Interfaces & Packages V2
Spring Data JPA from 0-100 in 60 minutes
Spring Data JPA from 0-100 in 60 minutes
Accessing Mule variables in groovy
Accessing Mule variables in groovy
Similar a JPA - Java Persistence API
Smoothing Your Java with DSLs
Smoothing Your Java with DSLs
intelliyole
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
Markus Eisele
IOC + Javascript
IOC + Javascript
Brian Cavalier
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
CHOOSE
XML-Free Programming : Java Server and Client Development without <>
XML-Free Programming : Java Server and Client Development without <>
Arun Gupta
Play 2.0
Play 2.0
elizhender
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Murat Yener
Eclipse World 2007: Fundamentals of the Eclipse Modeling Framework
Eclipse World 2007: Fundamentals of the Eclipse Modeling Framework
Dave Steinberg
CDI in JEE6
CDI in JEE6
PrasannaKumar Sathyanarayanan
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
Dave Steinberg
Greach 2019 - Creating Micronaut Configurations
Greach 2019 - Creating Micronaut Configurations
Iván López Martín
Refactoring
Refactoring
Amir Barylko
Angular JS2 Training Session #1
Angular JS2 Training Session #1
Paras Mendiratta
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
Peter Eisentraut
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
Ran Mizrahi
OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL
Suraj Bang
Eclipse Modeling Framework
Eclipse Modeling Framework
Ajay K
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Jonathan Felch
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Theo Jungeblut
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Fabio Franzini
Similar a JPA - Java Persistence API
(20)
Smoothing Your Java with DSLs
Smoothing Your Java with DSLs
New Features of JSR 317 (JPA 2.0)
New Features of JSR 317 (JPA 2.0)
IOC + Javascript
IOC + Javascript
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
Choose'10: Ralf Laemmel - Dealing Confortably with the Confusion of Tongues
XML-Free Programming : Java Server and Client Development without <>
XML-Free Programming : Java Server and Client Development without <>
Play 2.0
Play 2.0
Android and the Seven Dwarfs from Devox'15
Android and the Seven Dwarfs from Devox'15
Eclipse World 2007: Fundamentals of the Eclipse Modeling Framework
Eclipse World 2007: Fundamentals of the Eclipse Modeling Framework
CDI in JEE6
CDI in JEE6
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
EclipseCon 2008: Fundamentals of the Eclipse Modeling Framework
Greach 2019 - Creating Micronaut Configurations
Greach 2019 - Creating Micronaut Configurations
Refactoring
Refactoring
Angular JS2 Training Session #1
Angular JS2 Training Session #1
Porting Applications From Oracle To PostgreSQL
Porting Applications From Oracle To PostgreSQL
How AngularJS Embraced Traditional Design Patterns
How AngularJS Embraced Traditional Design Patterns
OWB11gR2 - Extending ETL
OWB11gR2 - Extending ETL
Eclipse Modeling Framework
Eclipse Modeling Framework
Groovy On Trading Desk (2010)
Groovy On Trading Desk (2010)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
Lego for Software Engineers at Silicon Valley Code Camp 2011 (2010-10-10)
WebNet Conference 2012 - Designing complex applications using html5 and knock...
WebNet Conference 2012 - Designing complex applications using html5 and knock...
Más de Thomas Wöhlke
Stahlkirche Otto Bartning 1928
Stahlkirche Otto Bartning 1928
Thomas Wöhlke
Pierre Bourdieu - Elemente einer soziologischen Theorie der Kunstwahrnehmung
Pierre Bourdieu - Elemente einer soziologischen Theorie der Kunstwahrnehmung
Thomas Wöhlke
Treesort Algorithmus und Datenstruktur
Treesort Algorithmus und Datenstruktur
Thomas Wöhlke
Produkt und Unternehmens Vorstellung in der Berufsschule
Produkt und Unternehmens Vorstellung in der Berufsschule
Thomas Wöhlke
OO Methodik für eCommerce-Engineering und -Consulting mit UML
OO Methodik für eCommerce-Engineering und -Consulting mit UML
Thomas Wöhlke
Zeitmanagement - Referat
Zeitmanagement - Referat
Thomas Wöhlke
Max Imdahl Ikonik
Max Imdahl Ikonik
Thomas Wöhlke
Más de Thomas Wöhlke
(7)
Stahlkirche Otto Bartning 1928
Stahlkirche Otto Bartning 1928
Pierre Bourdieu - Elemente einer soziologischen Theorie der Kunstwahrnehmung
Pierre Bourdieu - Elemente einer soziologischen Theorie der Kunstwahrnehmung
Treesort Algorithmus und Datenstruktur
Treesort Algorithmus und Datenstruktur
Produkt und Unternehmens Vorstellung in der Berufsschule
Produkt und Unternehmens Vorstellung in der Berufsschule
OO Methodik für eCommerce-Engineering und -Consulting mit UML
OO Methodik für eCommerce-Engineering und -Consulting mit UML
Zeitmanagement - Referat
Zeitmanagement - Referat
Max Imdahl Ikonik
Max Imdahl Ikonik
Último
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
futhumetsaneliswa
Using AI to boost productivity for developers
Using AI to boost productivity for developers
Teri Eyenike
"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXR
Megan Campos
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth death
phntsoaki
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
Abortion pills in Kuwait Cytotec pills in Kuwait
2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptx
nitishjain2015
SaaStr Workshop Wednesdays - RevenueCat.pdf
SaaStr Workshop Wednesdays - RevenueCat.pdf
saastr
ECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentation
FahadFazal7
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.
thamaeteboho94
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
Fabian de Rijk
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Hung Le
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
Mahamudul Hasan
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
Sosiaali- ja terveysministeriö / yleiset
globalisation project report displayed overview
globalisation project report displayed overview
asadzafar8520
Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20
rejz122017
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
tntlai16
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
David Celestin
Databricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdf
SkillCertProExams
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
Abortion pills in Kuwait Cytotec pills in Kuwait
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
thusosetemere
Último
(20)
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
BIG DEVELOPMENTS IN LESOTHO(DAMS & MINES
Using AI to boost productivity for developers
Using AI to boost productivity for developers
"I hear you": Moving beyond empathy in UXR
"I hear you": Moving beyond empathy in UXR
History of Morena Moshoeshoe birth death
History of Morena Moshoeshoe birth death
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
in kuwait௹+918133066128....) @abortion pills for sale in Kuwait City
2024-05-15-Surat Meetup-Hyperautomation.pptx
2024-05-15-Surat Meetup-Hyperautomation.pptx
SaaStr Workshop Wednesdays - RevenueCat.pdf
SaaStr Workshop Wednesdays - RevenueCat.pdf
ECOLOGY OF FISHES.pptx full presentation
ECOLOGY OF FISHES.pptx full presentation
Introduction to Artificial intelligence.
Introduction to Artificial intelligence.
Digital collaboration with Microsoft 365 as extension of Drupal
Digital collaboration with Microsoft 365 as extension of Drupal
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
Unlocking Exploration: Self-Motivated Agents Thrive on Memory-Driven Curiosity
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
SOLID WASTE MANAGEMENT SYSTEM OF FENI PAURASHAVA, BANGLADESH.pdf
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
STM valmiusseminaari 26-04-2024 PUUMALAINEN Ajankohtaista kansainvälisestä yh...
globalisation project report displayed overview
globalisation project report displayed overview
Ready Set Go Children Sermon about Mark 16:15-20
Ready Set Go Children Sermon about Mark 16:15-20
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
LITTLE ABOUT LESOTHO FROM THE TIME MOSHOESHOE THE FIRST WAS BORN
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Proofreading- Basics to Artificial Intelligence Integration - Presentation:Sl...
Databricks Machine Learning Associate Exam Dumps 2024.pdf
Databricks Machine Learning Associate Exam Dumps 2024.pdf
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
Abortion Pills Fahaheel ௹+918133066128💬@ Safe and Effective Mifepristion and ...
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
BEAUTIFUL PLACES TO VISIT IN LESOTHO.pptx
JPA - Java Persistence API
1.
JPA - Java
Persistence API Thomas Wöhlke ObjectCode GmbH 12.03.2009
2.
JPA: Agenda © 2009
ObjectCode GmbH
3.
Domain Object Model ©
2009 ObjectCode GmbH
4.
Object-Relational Mapping Analogie: OO
RDB Klasse Tabelle Objekt Zeile Variable Spalte Wert Feld Domain Object Modell = ERD ? © 2009 ObjectCode GmbH
5.
O/R Impedance Mismatch ©
2009 ObjectCode GmbH
6.
O/R Impedance Mismatch ©
2009 ObjectCode GmbH
7.
Domain Object Model:
GLE © 2009 ObjectCode GmbH
8.
... und die
Physik? • v(Harddisk) << v(RAM) • CPU 99% idle • Process 99% IO_WAIT • Page Impressions SQL-Requests? © 2009 ObjectCode GmbH
9.
Anno Domini 2004... ©
2009 ObjectCode GmbH © 2004-2005 TheServerside.com
10.
Hibernate Mapping von POJO‘s: 2.
Java Bean API 3. Collection API (Generics) 4. Mapping: XML oder Hibernate-Annotations Hibernate ist ein JPA-Vendor: Hibernate-Core Hibernate-Annotations Hibernate Entity Manager © 2009 ObjectCode GmbH
11.
Von Hibernate nach
JPA © 2009 ObjectCode GmbH
12.
JPA im JEE-Stack ©
2009 ObjectCode GmbH
13.
persistence.xml (Java EE) <?xml
version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="JPM_DB"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <jta-data-source>java:/JpmDS</jta-data-source> <properties> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> <!-- These are the default for JBoss EJB3, but not for HEM: --> <property name="hibernate.cache.provider_class" value="org.hibernate.cache.HashtableCacheProvider"/> <property name="hibernate.transaction.manager_lookup_class" value="org.hibernate.transaction.JBossTransactionManagerLookup"/> </properties> </persistence-unit> </persistence> © 2009 ObjectCode GmbH
14.
persistence.xml (Java SE) <?xml
version="1.0" encoding="UTF-8"?> <persistence xmlns="http://java.sun.com/xml/ns/persistence" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/persistence_1_0.xsd" version="1.0"> <persistence-unit name="JPM_DB"> <provider>org.hibernate.ejb.HibernatePersistence</provider> <class>org.woehlke.projecteering.kernel.calendar.pao.Day</class> <class>org.woehlke.projecteering.kernel.minutes.pao.Event</class> <class>org.woehlke.projecteering.kernel.minutes.pao.Minutes</class> <class>org.woehlke.projecteering.kernel.minutes.pao.MinutesItem</class> <class>org.woehlke.projecteering.kernel.projects.pao.Project</class> <class>org.woehlke.projecteering.kernel.projects.pao.ProjectCategory</class> <class>org.woehlke.projecteering.kernel.timerecording.pao.TimeRecordingItem</class> <class>org.woehlke.projecteering.kernel.userrights.pao.Company</class> <class>org.woehlke.projecteering.kernel.userrights.pao.Team</class> <class>org.woehlke.projecteering.kernel.userrights.pao.User</class> <exclude-unlisted-classes>true</exclude-unlisted-classes> <properties> <property name="hibernate.hbm2ddl.auto" value="create-drop"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.generate_statistics" value="true"/> <property name="hibernate.show_sql" value="true"/> <property name="hibernate.connection.driver_class" value="com.mysql.jdbc.Driver"/> <property name="hibernate.connection.username" value="jpm"/> <property name="hibernate.connection.password" value="jpmpwd"/> <property name="hibernate.connection.url" value="jdbc:mysql://localhost:3306/jpm"/> <property name="hibernate.dialect" value="org.hibernate.dialect.MySQLDialect"/> </properties> </persistence-unit> </persistence> © 2009 ObjectCode GmbH
15.
Mapping der Klassen
1 public class Customer extends Person { @OneToMany(mappedBy=“purchaser”) Set<Order> orders = new HashSet<Order>(); protected Customer() { } // for loading from db public Customer(String fname, String lname) { super(fname, lname); } public void addOrder(Order o) { orders.add(o); } public Set<Order> getOrders() { return orders; } } © 2009 ObjectCode GmbH
16.
Mapping der Klassen
2 @Entity @Table(name=“PRODUCTS”) public class Product { @Id @GeneratedValue @Column(name=“PRODUCT_PK”) long id; @Version int oplock; // column defaults to “OPLOCK” String name; // column defaults to “NAME” @ManyToOne @JoinColumn(name=“SUPP_FK”, referencedColumnName=“SUPP_PK”) Supplier supplier; ... } © 2009 ObjectCode GmbH
17.
Mapping der Assoziationen Kardinalität:
1:1 OneToOne 1:n OneToMany n:m ManyToMany Richtung: 1:n -> OneToMany N:1 <- ManyToOne Sichtbarkeit: Unidirektional -> Bidirektional <-> © 2009 ObjectCode GmbH
18.
Mapping der Vererbung 2.
Eine Tabelle pro Klassen-Hierarchie 3. Eine Tabelle pro konkrete Klasse 4. Eine Tabelle pro Subklasse 5. Non-Entity Vererbung 6. Keine Vererbung: Embbeding © 2009 ObjectCode GmbH
19.
Mapping der Vererbung? ©
2009 ObjectCode GmbH
20.
Einsatz von JPA
im JBoss/EJB3 @Stateless public class MinutesItemDao extends BaseDao<MinutesItem> implements IMinutesItemDao { @PersistenceContext(unitName = "JPM_DB") private EntityManager entityManager; public MinutesItem findById(Long id) { return entityManager.find(MinutesItem.class,id); } public EntityManager getEntityManager() { return entityManager; } public void setEntityManager(EntityManager entityManager) { this.entityManager = entityManager; } } © 2009 ObjectCode GmbH
21.
Einsatz von JPA
in Spring/Tomcat @Transactional public class MinutesDao extends BaseDao<Minutes> implements IMinutesDao { public Minutes findById(Long id) { return jpaTemplate.find(Minutes.class,id); } } © 2009 ObjectCode GmbH
22.
EJB-QL Query q =
em.createQuery(“select c from Customer c where c.firstName = :fname order by c.lastName”); q.setParameter(“fname”, “Joe”); q.setFirstResult(20); q.setMaxResults(10); List<Customer> customers = (List<Customer>) q.getResultList(); // all orders, as a named query @Entity @NamedQuery(name=“Order:findAllOrders”, query=“select o from Order o”); public class Order { ... } Query q = em.createNamedQuery(“Order:findAllOrders”); © 2009 ObjectCode GmbH
23.
Lebenszyklus Persistente Objekte 2.
Neu, transient (@Id id == null) 3. Persistent (@Id id != null) 4. Detached: – Wie persistent (@Id id!= null) – Jedoch ausserhalb des EntityManager Kontext – Lazy Loading nicht möglich! – Änderungen in DB sichern mit merge © 2009 ObjectCode GmbH
24.
EJB-QL // all people,
via a custom SQL statement Query q = em.createNativeQuery(“SELECT ID, VERSION, SUBCLASS, FIRSTNAME, LASTNAME FROM PERSON”, Person.class); List<Person> people = (List<Person>) q.getResultList(); // single-result aggregate: average order total price Query q = em.createQuery(“select avg(i.price) from Item i”); Number avgPrice = (Number) q.getSingleResult(); // traverse to-many relations Query q = em.createQuery(“select o from Order o left join o.items li where li.price > :price”); q.setParameter(“price”, 1000); List<Order> orders = (List<Order>) q.getResultList(); © 2009 ObjectCode GmbH
25.
Lazy Loading • Supplier
s = order.getItem().getProduct().getSupplier(); • Bei Aufruf eines Getters wird Objekt aus DB-Zeile nachgeladen. • Ohne Lazy Loading muss komplettes Objekt-Netz geladen werden. • Struktur des Objekt-Netzes variiert je nach Web-View © 2009 ObjectCode GmbH
26.
DAO und „Unit
of Work“ © 2009 ObjectCode GmbH
27.
Ausblick: Seam • Kern-Entwickler
von Hibernate sind nun im Seam-Projekt • O/R-Mapping von EJB3/JPA auch für die Webapplikation • OO im Datenbankbackend durch ORM • OO im Webfrontend durch JSF • Im Conversation-Scope ist Lazy-Loading möglich. • Detached Objects können für die Webview verwendet werden: Kein DTO-Antipattern © 2009 ObjectCode GmbH
28.
RTFM: http://www.hibernate.org/ O‘Reilly: Enterprise
JavaBeans 3.0 Manning: EJB3 in Action Manning: Hibernate in Action Literatur © 2009 ObjectCode GmbH
29.
FRAGEN? Fragen! ... Vielen
Dank für die Aufmerksamkeit © 2009 ObjectCode GmbH
Descargar ahora