I have a FILE table within my application (using postgreSQL) which stores off the full path of a file I have on my OS.
When I try and do a 'like' query, I keep getting zero results when I know there is data saved.
Here's the query in question:
public List<MyFile> getDirectoryFiles(Path path) {
Query query = em.createQuery("from MyFile f WHERE f.path LIKE :path");
query.setParameter("path", "////data////myData////.settings% ESCAPE '//'"); // hard coded the path for testing
return query.getResultList();
}
@Override
public void deleteDirectoryFiles(Path path) {
for(MyFile file : this.getDirectoryFiles(path)){
this.delete(file);
}
}
// in some other method I am deleting the files from a directory
Foo.deleteDirectoryFiles(this); // points to '/data/myData/.settings'
Not sure why this is happening. When I take what hibernate is producing and plugin the absolute path, I do see the returned tuples within my database.
Has anyone ever dealt with this issue? If so, how did you solve the problem? I've tried hardcoding my ':path' variable to be "'/data/myData/.settings%'", "%/data/myData/.settings%", "//data//myData//.settings%" and still nothing is being returned. There are no errors, but I cannot figure out why there are no results.