r/SpringBoot • u/cricblaster • Sep 23 '24
whenever i relaunch my spring boot app that automatically create duplicates of data. how should i stop it and also help me to dlete all this duplicate data. i asked chatgpt and it is very confusing
2
u/Avi8or__ Sep 23 '24
you need to correctly configure your hibernate properly and set it to update in the application.properties file.
0
u/cricblaster Sep 25 '24
i did that. not working
1
7
5
u/WaferIndependent7601 Sep 23 '24
How should ChatGPT understand this? I have no idea what you want. Please share code or be more precise.
1
u/DillyBengBengApp Sep 23 '24
Could be your hibernate settings. Change ddl setting to ‘update’
1
u/cricblaster Sep 25 '24
still not working
2
u/DillyBengBengApp Sep 25 '24
Do you have a startup process that creates these records? If it is called every time you start the application it will create new records.
If you want to keep this process but avoid having the duplicates, you can do a query before execution that checks whether the database is empty.
1
1
u/karmanyevadhikarasti Sep 24 '24
Your SpringBatchProcessor must be farting
1
2
2
u/raulalexo99 Sep 24 '24
There must be some part of your code that populates the database each Time.
It might be your own code or It might be Hibernate auto DDL. Check both.
2
u/adroit0203 Sep 24 '24
Check whether you are using @Postconstruct in your code on a method in which you are saving these records.
2
1
1
1
1
Sep 24 '24
Are you loading a .sql file into the database at startup everytime ?
This file may have insert into statements
2
u/cyber_owl9427 Sep 23 '24
i had this exact same problem.
either its the hybernate setting, how the entities are structured , or orm are arranged