fix(search): handle null firstName in all search queries

Use COALESCE to convert null firstName to empty string in:
- PersonRepository.searchByName (JPQL)
- PersonRepository.searchWithDocumentCount (native SQL)
- PersonRepository.findCorrespondentsWithFilter (native SQL)
- DocumentSpecifications.hasText (Criteria API, sender + receiver)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-04-08 11:59:41 +02:00
parent 92f1a112f5
commit de2cc677a9
3 changed files with 30 additions and 8 deletions

View File

@@ -440,4 +440,26 @@ class PersonRepositoryTest {
assertThat(results).hasSize(1);
assertThat(results.get(0).getLastName()).isEqualTo("Cram");
}
// ─── null firstName handling ────────────────────────────────────────────
@Test
void searchByName_findsPersonWithNullFirstName() {
personRepository.save(Person.builder().lastName("Gesellschafter des Verlages").build());
List<Person> result = personRepository.searchByName("Gesellschafter");
assertThat(result).hasSize(1);
assertThat(result.get(0).getLastName()).isEqualTo("Gesellschafter des Verlages");
}
@Test
void searchWithDocumentCount_findsPersonWithNullFirstName() {
personRepository.save(Person.builder().lastName("Gesellschafter des Verlages").build());
List<PersonSummaryDTO> result = personRepository.searchWithDocumentCount("Gesellschafter");
assertThat(result).hasSize(1);
assertThat(result.get(0).getLastName()).isEqualTo("Gesellschafter des Verlages");
}
}