Summary

The Java Persistence API is a large endeavor to learn and represent lots of lasting evidence of a breakthrough of thought and achievement by the Java community. Standardizing how a Java application can seamlessly save and retrieve the objects to and from a relational database is no mean feat. Consequently, JPA is extremely powerful for both the Java SE and Java EE engineers.

We touched on the fundamentals of JPA in this chapter. We saw how a simple POJO can be transformed into a persistence capable object, an entity bean, with some annotations. We learnt how to save an entity to the database, how to remove it from the database, and how to retrieve all the instances.

We added the @Entity, @Id, @GeneratedValue, @Column, and @Table annotations to an example bean.

You now understand how to write an integration unit test with Gradle, the Arquillian framework, embedded GlassFish, and the EclipseLink JPA provider.

We discussed the lifecycle of the entity manager, and the four different states of an entity bean. We touched on the transactional support. We saw how to create the composite primary keys in the entity beans with either @IdClass or the embeddable class styles. We built some queries using JPQL. We advanced our understanding of JPA by retrieving the entities using the composite key records.

Closing out the chapter, we made a short detour to the entity relationships and the four fundamental multiplicities: @OneToOne, @OneToMany, @ManyToOne, and@ManyToMany.

Finally, we looked at the configuration of the persistence unit, and that was just the start. In the next chapter, we will extend our knowledge on the entity relationships in depth.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.235.219