Here we go for part 5 of this tutorial series! This part will cover our Data Acces Object Layer (DAO).
We will be mainly talking about CRUD (create,update,delete) operations using JPA and Spring.
I should start by saying that we will use an Interface and an Implementation for each Entity.
This way we can easily switch database providers later if we would like to.
The PostDao interface:
package blog.dao;
import blog.domain.Post;
import java.util.List;
public interface PostDao {
List<Post> findAllPosts();
Post findPostByPostId(Long postId);
void create(Post post);
void remove(Post post);
void update(Post post);
List<Post> findMostRecentPosts();
}
note that we created crud methods and some other selection methods we'll need later.