@CreatedDate annotation does not work with mysql

I was Having this issue also and your solution helped me, Thanks, And I add some other annotations to work Fist make sure you put in SpringApplication Configuration @SpringBootApplication @EnableJpaAuditing Second, make sure you use this annotation on your needed entities @Entity @Table @EntityListeners(AuditingEntityListener.class)

Spring Data JPA Projection selected fields from the DB

If you want use the annotation @Query with Spring Data Projections you have to use field alias and you need to make sure you alias the projects matching the projection fields. The following code should work for question 1: interface PersonRepository extends CrudRepository<Person, Long> { @Query(“select p.firstName as firstname, p.address as address from Person p … Read more

Difference between findBy and findOneBy in Spring data JPA

Can I use findBy this way? Department findByDepartmentId(Long Id); Yes, this syntax is technically correct from Spring JPA point of view. Although Spring JPA infers what you’re trying to achieve with your query looking at the return type as well. Basically these are the cases for return types: with your query you want to return … Read more

Springfox swagger not working in spring boot 2.2.0

Fixed!!! The issue exists as spring fox libraries internally depend on spring-plugin-core:1.2.0 but it actually requires spring-plugin-core:2.0.0. This dependency correction seems to be missing in the SNAPSHOT version of the swagger libraries for supporting web flux. We just need to correct Maven dependencies as given below and no code change is required: Maven POM Dependencies … Read more

ERROR: update or delete on table “tablename” violates foreign key constraint

When you’re using a relational DB, you are setting entities with relationships between these entities. The error that you’re getting means that: You’re trying to delete a record that its primary key is functioning as a foreign key in another table, thus you can’t delete it. In order to delete that record, first, delete the … Read more

Spring Data JPA intelligence not working in Intellij

I solved this problem by adding JavaEE Persistence framework support. Just right click on the project, select Add Framework Support and then scroll down to find the JavaEE Persistence, then enable the checkbox and hit OK: Adding JavaEE Persistence Facet It will add a persistence.xml file, you can delete it. Finally your auto completions will … Read more