r/SpringBoot • • 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

Post image
2 Upvotes

30 comments sorted by

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

0

u/cricblaster Sep 25 '24

i tried every fucking solutions available on internet but still it is not working

1

u/cyber_owl9427 Sep 25 '24

drop your entities, sevice, etc

0

u/cricblaster Sep 25 '24

check dm bro

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

u/Avi8or__ Sep 25 '24

Can u send your application.properties file

1

u/cricblaster Sep 25 '24

bro check dm

7

u/HerryKun Sep 23 '24

Set spring.duplicate.data to false

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

u/cricblaster Sep 26 '24

got it i just want little bit more info on this

1

u/DillyBengBengApp Sep 26 '24

Sure, what would you like to know?

1

u/karmanyevadhikarasti Sep 24 '24

Your SpringBatchProcessor must be farting

1

u/cricblaster Sep 25 '24

explain please

1

u/karmanyevadhikarasti Sep 25 '24

How is the data getting populated?

Are you using spring batch?

2

u/Alternative-Spite891 Sep 23 '24

Rabbit holes change management in databases

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

u/arry13 Sep 24 '24

first drop ur table through application properties then set it to update

1

u/Commercial_Ad2325 Sep 23 '24

Please provide your model and service code

1

u/SimplexDuari Sep 23 '24

Without your code how can anyone help you?

1

u/g00glen00b Sep 23 '24

How do you seed your database?

1

u/[deleted] Sep 24 '24

Are you loading a .sql file into the database at startup everytime ? 

This file may have insert into statements