Presentation is loading. Please wait.

Presentation is loading. Please wait.

JPA in Vaadin CSCI 3130 Winter 2016. What is JPA?  Java Persistence API  Allows for “easy” storage of Java Objects  Is a type of Object Relational.

Similar presentations


Presentation on theme: "JPA in Vaadin CSCI 3130 Winter 2016. What is JPA?  Java Persistence API  Allows for “easy” storage of Java Objects  Is a type of Object Relational."— Presentation transcript:

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

9

10

11

12

13

14

15

16

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

20

21

22

23

24

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)


Download ppt "JPA in Vaadin CSCI 3130 Winter 2016. What is JPA?  Java Persistence API  Allows for “easy” storage of Java Objects  Is a type of Object Relational."

Similar presentations


Ads by Google