Category: Spring Data

  • How to integrate SQLite Database with Spring Boot?

    Spring Boot doesn’t provide a straightforward way to integrate SQLite database compared to other databases such as MySQL , MongoDB etc. SQLite is the most used database engine in the world as SQLite website claims. And yet it is a surprise Spring Boot doesn’t treat it the same way as it treats other databases. To…

  • How to write custom queries in Spring Data at method level?

    Say you want to write a custom JPA query for one of your data requirements. Spring Data provides great abstraction over JPA to perform CRUD operations. You can easily retrieve entity objects from database based on field values using methods like ‘findByName’ , ‘findByNameAndAge’ etc in your interface extending Spring Data repositories. If you need…

  • How to load initial data in Spring Boot with and without defining schema?

    Let’s say that you want to populate your database with initial set of values as soon as your spring boot application starts. You may particularly need it if you are using an in memory database like H2. The process differs a bit when you define the schema yourself or let Spring Data define it. Spring…

  • How to delete records in Spring Data based on multiple field values?

    Spring Data has made it so easy to deal with database. Most boiler plate code are removed and user can just concentrate on the business logic. Here is a simple way to delete records using multiple field values from a relational database table . STEP 1: Prepare your entity which corresponds to the table. Write…