Skip to content
Advertisement

Spring boot delete object from database based on a OneToOne relationship

i’ve got an “appointment” entity object(table) AND dates_doctor_available entity build like this

JavaScript

AND

JavaScript

now i wish from a controller to remove the Database entry based on the “date_time_available_fk” Using “Appointment” object. For example something like

JavaScript

where inside service there is a data object access something like this(they are interfaces)

JavaScript

where id is the date_time_available_fk number i want to pass(i already have it from thymeleaf) to the Appointment object

i want to avoid using @Query if this can happen.

UPDATE i actually figured it out i will give the solution in the morning for future troublers.

Advertisement

Answer

The Solution i could not fetch the object information from database with above as i said in order to delete it afterwards so i did this(created new object Appointment)

JavaScript

that way i could retrieve the information then delete it like this.

JavaScript

after getting id from url request mapping

JavaScript

—————inside view thymeleaf————

JavaScript

——————-inside Services—————

—Service:—

JavaScript

—DAO:—–

JavaScript

—Service:—

JavaScript

—DAO:—–

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement