I'm trying to delete an entity "study" that extends "entry". The inheritance strategy is InheritanceType.JOINED.
There is a study table and an entry table (with common fields).
Two repositories are defined:
EntryRepository extends CrudRepository<Entry, String>
StudyRepository extends CrudRepository<Study, String>
These two repositories extends the spring data org.springframework.data.repository.CrudRepository.
The problem is: the delete method for these two repository is not working. No error, no effect. For other entities (without inheritance), it works well.
Here is my test code:
System.out.println("entity exist?: " + entryRepository.existsById(entry.getId()));
System.out.println("before delete parent: " + entryRepository.count());
entryRepository.delete(entry);
System.out.println("after delete parent: " + entryRepository.count());
System.out.println("entity exist?: " + studyRepository.existsById(entry.getId()));
System.out.println("before delete child1: " + studyRepository.count());
studyRepository.delete((Study)entry);
System.out.println("after delete child1: " + studyRepository.count());
The log results:
Hibernate: select count(*) as col_0_0_ from entry entry0_ where entry0_."ID"=?
entity exist?: true
Hibernate: select count(*) as col_0_0_ from entry entry0_
before delete parent: 6
Hibernate: select count(*) as col_0_0_ from entry entry0_
after delete parent: 6
Hibernate: select count(*) as col_0_0_ from study study0_ inner join entry study0_1_ on study0_."ID"=study0_1_."ID" where study0_."ID"=?
entity exist?: true
Hibernate: select count(*) as col_0_0_ from study study0_ inner join entry study0_1_ on study0_."ID"=study0_1_."ID"
before delete child1: 3
Hibernate: select count(*) as col_0_0_ from study study0_ inner join entry study0_1_ on study0_."ID"=study0_1_."ID"
after delete child1: 3
So...no delete in log, no error,... :-/ Any idea on how to get that working or how to get the origin of this problem?
Thanks!