You are on page 1of 19

Developing Enterprise Java

Applications with JSF and JPA


using Eclipse WTP
Sinan Konya
sinan.konya@eteration.com

© 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 JPA Entity
@Entity
public class Address { public class Address {
private int id; @Id
private String street; private int id;
private String city; private String street;
private String state; private String city;
private String country; 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 ¾Collection of Entities


@OneToOne @OneToMany
@ManyToOne @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
- id : Long - topic : String
- firstName : String = initval - beginDate : Date
- lastName : String - endDate : Date

+ getId() : Long + getId() : Long


+ getFirstName() : String + getTopic() : String
+student +courses
+ getLastName() : String + getBeginDate() : Date
+ getAddress() : Address 0..* 0..* + getEndDate() : Date
+ getCourses() : Set<Course> + getStudents() : Set<Student>
+ setId(id : Long) : void + setId(id : Long) : void
+ setFirstName(fName : String) : void + setTopic(topic : String) : void
+ setLastName(lName : String) : void + setBeginDate(beginDate : Date) : void
+ setAddress(address : Address) : void + setEndDate(endDate : Date) : void
+ setCourses(courses : Set<Course>) : void + setStudents(students : Set<Student>) : 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.

You might also like