fix Postgres typing error by casting 2nd operator of like operator to text

This commit is contained in:
Michael Hoennig 2024-01-04 08:43:22 +01:00
parent ec53934f30
commit 378e1ec584
8 changed files with 18 additions and 18 deletions

View File

@ -14,7 +14,7 @@ public interface HsOfficeContactRepository extends Repository<HsOfficeContactEnt
@Query("""
SELECT c FROM HsOfficeContactEntity c
WHERE :label is null
OR c.label like concat(:label, '%')
OR c.label like concat(cast(:label as text), '%')
""")
List<HsOfficeContactEntity> findContactByOptionalLabelLike(String label);

View File

@ -23,11 +23,11 @@ public interface HsOfficeDebitorRepository extends Repository<HsOfficeDebitorEnt
JOIN HsOfficePersonEntity person ON person.uuid = partner.person.uuid
JOIN HsOfficeContactEntity contact ON contact.uuid = debitor.billingContact.uuid
WHERE :name is null
OR partner.details.birthName like concat(:name, '%')
OR person.tradeName like concat(:name, '%')
OR person.familyName like concat(:name, '%')
OR person.givenName like concat(:name, '%')
OR contact.label like concat(:name, '%')
OR partner.details.birthName like concat(cast(:name as text), '%')
OR person.tradeName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%')
""")
List<HsOfficeDebitorEntity> findDebitorByOptionalNameLike(String name);

View File

@ -16,11 +16,11 @@ public interface HsOfficePartnerRepository extends Repository<HsOfficePartnerEnt
JOIN HsOfficeContactEntity contact ON contact.uuid = partner.contact.uuid
JOIN HsOfficePersonEntity person ON person.uuid = partner.person.uuid
WHERE :name is null
OR partner.details.birthName like concat(:name, '%')
OR contact.label like concat(:name, '%')
OR person.tradeName like concat(:name, '%')
OR person.givenName like concat(:name, '%')
OR person.familyName like concat(:name, '%')
OR partner.details.birthName like concat(cast(:name as text), '%')
OR contact.label like concat(cast(:name as text), '%')
OR person.tradeName like concat(cast(:name as text), '%')
OR person.givenName like concat(cast(:name as text), '%')
OR person.familyName like concat(cast(:name as text), '%')
""")
List<HsOfficePartnerEntity> findPartnerByOptionalNameLike(String name);

View File

@ -14,9 +14,9 @@ public interface HsOfficePersonRepository extends Repository<HsOfficePersonEntit
@Query("""
SELECT p FROM HsOfficePersonEntity p
WHERE :name is null
OR p.tradeName like concat(:name, '%')
OR p.givenName like concat(:name, '%')
OR p.familyName like concat(:name, '%')
OR p.tradeName like concat(cast(:name as text), '%')
OR p.givenName like concat(cast(:name as text), '%')
OR p.familyName like concat(cast(:name as text), '%')
""")
List<HsOfficePersonEntity> findPersonByOptionalNameLike(String name);

View File

@ -14,7 +14,7 @@ public interface HsOfficeSepaMandateRepository extends Repository<HsOfficeSepaMa
@Query("""
SELECT mandate FROM HsOfficeSepaMandateEntity mandate
WHERE :iban is null
OR mandate.bankAccount.iban like concat(:iban, '%')
OR mandate.bankAccount.iban like concat(cast(:iban as text), '%')
ORDER BY mandate.bankAccount.iban
""")
List<HsOfficeSepaMandateEntity> findSepaMandateByOptionalIban(String iban);

View File

@ -11,7 +11,7 @@ public interface RbacUserRepository extends Repository<RbacUserEntity, UUID> {
@Query("""
select u from RbacUserEntity u
where :userName is null or u.name like concat(:userName, '%')
where :userName is null or u.name like concat(cast(:userName as text), '%')
order by u.name
""")
List<RbacUserEntity> findByOptionalNameLike(String userName);

View File

@ -12,7 +12,7 @@ public interface TestCustomerRepository extends Repository<TestCustomerEntity, U
Optional<TestCustomerEntity> findByUuid(UUID id);
@Query("SELECT c FROM TestCustomerEntity c WHERE :prefix is null or c.prefix like concat(:prefix, '%')")
@Query("SELECT c FROM TestCustomerEntity c WHERE :prefix is null or c.prefix like concat(cast(:prefix as text), '%')")
List<TestCustomerEntity> findCustomerByOptionalPrefixLike(String prefix);
TestCustomerEntity save(final TestCustomerEntity entity);

View File

@ -8,7 +8,7 @@ import java.util.UUID;
public interface TestPackageRepository extends Repository<TestPackageEntity, UUID> {
@Query("SELECT p FROM TestPackageEntity p WHERE :name is null or p.name like concat(:name, '%')")
@Query("SELECT p FROM TestPackageEntity p WHERE :name is null or p.name like concat(cast(:name as text), '%')")
List<TestPackageEntity> findAllByOptionalNameLike(final String name);
TestPackageEntity findByUuid(UUID packageUuid);