Skip to content
Advertisement

Tag: spring-data-jpa

Who should be parent in spring JPA relationship

I have 3 tables book, publisher, author. Here author and publisher can refer to same record in book therefore I decided to make book as relationship parent. However I also want to make it so that if a publisherA is deleted, all the book record related to publisherA also get deleted. same goes for author. I tried using cascade, but

Why spring-boot-starter-data-jpa 2.5.0 can not init data by the cause “table not found”?

I have 2 projects using the same H2 configurations: The first project used spring-boot-starter-data-jpa 1.5.8.RELEASE which can init data successfully. But the second one used spring-boot-starter-data-jpa 2.5.0 CAN NOT init data: Trace the log I have seen that the init data sql is run before the db structure generated. Spring team! Please help to fix this issue to save time

Understanding JPA sequence generator

I’m using spring data JPA’s sequence generator to assign primary keys to entities. Model contains: The corresponding sequence definition(for SQL Server DB): Since I wanted to start the ids from 100 instead of 1, so I updated the sql script to And then I encountered the problem as mentioned here. I fixed it by the solution mentioned there. This made

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 AND 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 where inside service there is a data object access something like this(they are interfaces) where id is the date_time_available_fk number i want to pass(i already

Spring Data JPA: delete OneToMany child without going through the parent

My application has a Project entity that has set of Resource entities like this: The Resource entities may be referenced by several projects, and I’m wondering how to delete a Resource from the database easily without first removing it from the resources list of each parent Project. Trying to delete the resource directly using the repository’s deleteById method results in

JPA query to filter before, after and between optional start and end dates

I’d like to write a JPA Repository query that can findBy with two optional query parameters, startDate and endDate: startDate endDate Return null null All null endDate Before End startDate null After Start startDate endDate Between Start and End How can this be implemented concisely? For example, using a single JPA @Query method with a SQL statement that can handle

Advertisement