Available in versions: Dev (3.18) | Latest (3.17) | 3.16 | 3.15 | 3.14 | 3.13 | 3.12 | 3.11 | 3.10 | 3.9 | 3.8
Using jOOQ with JPA
Applies to ✅ Open Source Edition ✅ Express Edition ✅ Professional Edition ✅ Enterprise Edition
These sections will show how to use jOOQ with JPA's native query API in order to fetch tuples or managed entities using the Java EE standards.
In all of the following sections, let's assume we have the following JPA entities to model our database:
@Entity @Table(name = "book") public class JPABook { @Id public int id; @Column(name = "title") public String title; @ManyToOne public JPAAuthor author; @Override public String toString() { return "JPABook [id=" + id + ", title=" + title + ", author=" + author + "]"; } } @Entity @Table(name = "author") public class JPAAuthor { @Id public int id; @Column(name = "first_name") public String firstName; @Column(name = "last_name") public String lastName; @OneToMany(mappedBy = "author") public Set<JPABook> books; @Override public String toString() { return "JPAAuthor [id=" + id + ", firstName=" + firstName + ", lastName=" + lastName + ", book size=" + books.size() + "]"; } }
Feedback
Do you have any feedback about this page? We'd love to hear it!