Download presentation
Presentation is loading. Please wait.
Published byCarmel Patrick Modified over 8 years ago
1
JPA in Vaadin CSCI 3130 Winter 2016
2
What is JPA? Java Persistence API Allows for “easy” storage of Java Objects Is a type of Object Relational Mapping (ORM) framework Book of Vaadin: https://vaadin.com/docs/- /part/framework/jpacontainer/jpacontainer- overview.htmlhttps://vaadin.com/docs/- /part/framework/jpacontainer/jpacontainer- overview.html Java Persistence API Allows for “easy” storage of Java Objects Is a type of Object Relational Mapping (ORM) framework Book of Vaadin: https://vaadin.com/docs/- /part/framework/jpacontainer/jpacontainer- overview.htmlhttps://vaadin.com/docs/- /part/framework/jpacontainer/jpacontainer- overview.html
3
How does it work? Your ObjectsYour UI JPA Database
4
How do I use it? Carefully! 1.Update ivy.xml 2.Change Project Facet 3.Edit persistence.xml 4.Define Data Model 5.Connect JPA to UI Carefully! 1.Update ivy.xml 2.Change Project Facet 3.Edit persistence.xml 4.Define Data Model 5.Connect JPA to UI
5
1. Update ivy.xml
6
Update ivy.xml Add these lines to ivy.xml: Save and wait for the new libraries to download Add these lines to ivy.xml: Save and wait for the new libraries to download
7
2. Add Project Facet
8
Add Project Facet
17
Edit Persistence.xml
18
Edit persistence.xml persistence.xml tells JPA how to connect to the database By default it is in src/META-INF/persistence.xml persistence.xml tells JPA how to connect to the database By default it is in src/META-INF/persistence.xml
19
Edit persistence.xml
25
4. Define Data Model
26
Define Data Model Create the classes to hold your data Annotate data classes with @Entity Annotate id field with @Id Annotate relationships with @OneToMany, @ManyToOne, @ManyToMany, etc… For reciprocal relationships, make sure to use mappedBy Create the classes to hold your data Annotate data classes with @Entity Annotate id field with @Id Annotate relationships with @OneToMany, @ManyToOne, @ManyToMany, etc… For reciprocal relationships, make sure to use mappedBy
27
5. Connect JPA to UI
28
Connect JPA to UI Create a new JPAContainer. Connect it to a Table, Form, etc. Perform operations on the container (add, delete, update, etc) Create a new JPAContainer. Connect it to a Table, Form, etc. Perform operations on the container (add, delete, update, etc)
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.