Document not found! Please try again

Developing Enterprise Java Applications with JSF and JPA using ...

14 downloads 271 Views 1MB Size Report
JPA supports “The Persistence of Memory”—which is the title of a well known Salvador Dali painting. Salvador Dalí. The Persistence of Memory. 1931.
Developing Enterprise Java Applications with JSF and JPA using Eclipse WTP Sinan Konya [email protected]

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

Why ‘Dali’? JPA supports “The Persistence of Memory”—which is the title of a well known Salvador Dali painting.

Salvador Dalí. The Persistence of Memory. 1931. © 2005 Salvador Dalí, Gala-Salvador Dalí Foundation/Artists Rights Society (ARS), New York © 2007

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

JPA—POJO Entities ¾ Concrete classes ¾ No required interfaces ƒ No required business interfaces ƒ No required callback interfaces ¾ new() for instance creation ¾ Direct access or getter/setter methods ƒ Can contain logic (e.g. for validation, etc.) ¾ “Managed” by an EntityManager ¾ Can leave the Container (become “detached”)

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

Object-Relational Mappings ¾ Core JPA Mappings ƒId ƒBasic ƒRelationships ƒ OneToOne ƒ OneToMany/ManyToOne ƒ ManyToMany ƒAnd more… ¾ Can be specified using Annotations or XML ƒXML mapping will be supported in Dali 1.0 which will ship with WTP 2.0. © 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

POJO public class Address { private int id; private String street; private String city; private String state; private String country; … }

JPA Entity @Entity public class Address { @Id private int id; private String street; private String city; private String state; private String country; … }

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

JPA Relationship Mappings ¾Single Entitiy @OneToOne @ManyToOne

¾Collection of Entities @OneToMany @ManyToMany

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

JSF Tools Project

¾Visual JSF-JSP Page Designer ¾ Faces Configuration Model, Editor and Wizards ¾ JSF Library Registry ¾ Extensible Frameworks ¾ Support for JavaServer Faces 1.1 and 1.2 versions

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

Tutorial: Class Diagram

Course St udent

- id : Long - topic : String - beginDate : Date - endDate : Date

- id : Long - firstName : String = initval - lastName : String + + + + + + + + + +

getId() : Long getFirstName() : String getLastName() : String getAddress() : Address getCourses() : Set setId(id : Long) : void setFirstName(fName : String) : void setLastName(lName : String) : void setAddress(address : Address) : void setCourses(courses : Set) : void

+student 0..*

+ + + 0..* + + + + + + +

+courses

getId() : Long getTopic() : String getBeginDate() : Date getEndDate() : Date getStudents() : Set setId(id : Long) : void setTopic(topic : String) : void setBeginDate(beginDate : Date) : void setEndDate(endDate : Date) : void setStudents(students : Set) : void

+address 1..1 Address - id : Long - street : String - postalCode : String - city : String - country : String + + + + + + + + + +

getId() : Long getStreet() : String getPostalCode() : String getCity() : String getCountry() : String setId(id : Long) : void setStreet(street : String) : void setPostalCode(pk : String) : void setCity(city : String) : void setCountry(country : String) : void

© 2007 by Sinan Konya; made available under the EPL v1.0 | April 30,2007 | Eteration A.S.

Suggest Documents