How to search into database having encrypted columns

Viewed 373

I am developing a healthcare application using Spring Boot with mysql database. I have to encrypt some tables having PHI (protected health information) data. Now I want to have searching functionality which would search for all matching terms over the encrypted columns addresses, phone numbers of patients in the db table for a given search term.

I am using jasypt as a encryption provider.

I understand that since the columns are encrypted, its not directly possible to search on those columns using derived query methods or HQL or Native Queries. However findByColumnName(value) works and fetches records for given value. But I wanted to have ability to search using pattern with contains, like, startsWith, endsWith etc where I can pass on hospital name / patient name/ patient number etc and results would be populated.

So far I have tried

findByColumnNameStartsWith findByColumnNameEndsWith findByColumnNameCotains etc derived queries in my JPA repository.

I have also tried using Specification from org.springframework.data.jpa.domain and used criteriaBuilder.like() to create predicates but its not giving out any search results.

Is there anything that I am missing here?

Question can be naive, please bear with me :)

0 Answers
Related