JPA 2.2

Java EE 8 updates the JPA specification to version 2.2. This version mainly targets Java SE 8 features.

Similar to Bean Validation, the Java SE 8 support includes the Date and Time API. Types such as LocalDate or LocalDateTime are now natively supported for entity properties.

Version 2.2 makes it possible to return a query result, not only as List<T> but Stream<T>, using the getResultStream() method as shown in the following code snippet:

Stream<Car> cars = entityManager
        .createNamedQuery(Car.FIND_TWO_SEATERS, Car.class)
        .getResultStream();
cars.map(...)

What JPA 2.2 also finally added is support to inject managed beans into attribute converters using CDI's @Inject. This increases the use and number of scenarios of custom attribute converters. Similar to other standards such as JSON-B, better CDI integration encourages reuse of Java EE components.

Also version 2.2 adds repeatable annotations, such as @JoinColumn, @NamedQuery, or @NamedEntityGraph. Since Java SE 8 allows to repeat the same annotation type multiple times, developers are no longer required to use the corresponding group annotations, such as @JoinColumns, for these functionalities.

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

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