spring boot mysql jpa code example
Example 1: spring application properties mysql jpa
spring.datasource.url=jdbc:mysql:
spring.datasource.username=${USERNAME}
spring.datasource.password=${PASSWORD}
spring.jpa.hibernate.ddl-auto=create-drop
spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5Dialect
spring.logging.level.org.hibernate.SQL=debug
spring.jpa.show-sql=true
Example 2: mysql driver spring jpa application.properties
spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql:
spring.datasource.username=springuser
spring.datasource.password=ThePasswordCopy
Example 3: jpql spring boot
@Query("SELECT u FROM User u WHERE u.status = :status and u.name = :name")User findUserByStatusAndNameNamedParams( @Param("status") Integer status, @Param("name") String name);