Java Persistence API (JPA)

The JPA code is defined to access the database. The JokesJpaRepository interface extends JpaRepository. This allows the developer access JPA predefined and developer custom interfaces to perform CRUD operations on persistent storage. It is left to student to define “Delete” operation in CRUD.

import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;

// JPA is an object-relational mapping (ORM) to persistent data, originally relational databases (SQL). Today JPA implementations has been extended for NoSQL.
public interface JokesJpaRepository extends JpaRepository<Jokes, Long> {
    // JPA has many built in methods, these few have been prototyped for this application
    void save(String Joke);  // used for Create, Update operations in CRUD

    // Accessors, Read operations in CRUD
    List<Jokes> findAllByOrderByJokeAsc();  // returns a List of Jokes in Ascending order
    List<Jokes> findByJokeIgnoreCase(String joke);  // look to see if Joke(s) exist
}

JPA returns List

List is a super class to ArrayList. In the JPA code you can see that List of Jokes is common result from JPA accessor method. It is left to the student to review List and ArrayList from GeeksForGeeks and understand research difference between interface and implementation.