How to debug SQL statements in Spring Boot applications

Spring boot auto-configuration does not require a dedicated logging configuration file. So, in order to debug your SQL Statements in Spring Boot applications, by default can use the following settings in your application.properties file: logging.level.org.hibernate.SQL=DEBUG logging.level.org.hibernate.type.descriptor.sql.BasicBinder=TRACE When this configuration is added, you will be able to see: 1) Each SQL Statement executed 2) The timing … Read more

How to add initial data in Spring Boot JPA applications

In order to have some data inserted at application start up, all you have to do is creating a data.sql file in your src/main/resources folder and it will be automatically executed on startup. Within this file, place your SQL INSERT Statements: INSERT into CUSTOMER(id,name,surname) VALUES (1,’aaaa’,’bbbbbb’) INSERT into CUSTOMER(id,name,surname) VALUES (2,’cccc’,’dddddd’) On the other hand, … Read more

How to get your DB Tables automatically created with Spring Boot

Here is a sample application.properties configuration that will let Hibernate create the Database tables out of your Entity beans: spring.datasource.url=jdbc:mysql://localhost:3306/mysqltutorial?useSSL=false spring.datasource.username=root spring.datasource.password= spring.datasource.driver-class-name=com.mysql.jdbc.Driver spring.jpa.properties.hibernate.dialect = org.hibernate.dialect.MySQL5Dialect spring.jpa.generate-ddl=true spring.jpa.hibernate.ddl-auto = create Here are the possible values for hibernate.hbm2ddl.auto : validate: validate the schema, makes no changes to the database. update: update the schema. create: creates the … Read more

Create a JPA Application using Groovy and Spring Boot

You can create a Spring Boot application using Groovy either from the IDE or using the online Spring Boot application generator http://start.spring.io and selecting Groovy as the language. You’ll now see how to develop a simple Spring Boot web application using Groovy, Spring Data JPA, and Thymeleaf. Add the Web, Thymeleaf, JPA, and H2 starters … Read more

Exit mobile version