Thats just a load of CRUD

CRUD stands for Create, Read, Update and Delete which are probably the most basic of things that you can do to a piece of data. Spring Boot gives you a very easy way to setup an interface between your application logic and your data entities that can provide this CRUD interface without making you write a ton of code with what is known as a repository.

A repository is just a set of data entities, So for our application we will need two repositories, one for the Location entity and one for the Person entity. I’ve created a new package in my application to hold these called repositories. This is the LocationRepository

and this is the PersonRepository

These are both interfaces and they extend another interface called CrudRepository which will give you all the basic CRUD operations.

Assuming that I have setup access to my repository ( which I will show later ) I can now use any of the above methods on the repository to Create, Read, Update and Delete data from the repository. deleteAll() will obviously delete all the entities in the repository and findAll() will return all the entities that you can then iterate through. count() will tell you how many entities are in the repository.

Advertisement
Tagged with: , , ,
Posted in Domino To Spring, None
One comment on “Thats just a load of CRUD
  1. axel says:

    I felt much more at ease with Spring Data after I realized that the highly structured approach doesn’t hinder me as developer to enter more specific queries, when needed.
    One may use @Query for this purpose.
    @Query(“SELECT distinct b FROM someMaster b left join fetch b.someDetail a WHERE b.bearbeitungsId= :bearbeitungsid”)
    Set findAllMasterWithDetail();

    Well, there may even be a Spring Data way to build those from my practice very important fetch joins. I don’t know yet 😉

    Like

Comments are closed.

Archives
%d bloggers like this: