My question is how to get values from the database (PostgreSQL) by regex, BUT not using native SQL queries. The only way I found is to use Hibernate Criteria API:
criteria.add(Restrictions.sqlRestriction("name ~ '^(?!" + filter + ")'"));
But this method also uses SQL. Spring data has query creation functionality but regex search seems to be working only with MongoDb.
http://docs.spring.io/spring-data/jpa/docs/current/reference/html/#repository-query-keywords
My goal is not depending on native sql queries, use objects instead, and make my project portable for any other databases.
someObject.addRegex(String regex)means nothing. What you are looking for is not archievable: There is no portable that you can query data from different DBMS without SQL