How can I create a SqlQuery (with method session.createSqlQuery) from a .sql file located in src folder? My sql file is a simple select.
Asked
Active
Viewed 1,508 times
1 Answers
0
Read query from file
String queryString = new String(Files.readAllBytes(Paths.get(filePath)));
Create sql query
Query query = session.createSqlQuery(queryString);

Abylay Sabirgaliyev
- 726
- 9
- 18
-
I got this error java.nio.file.NoSuchFileException: /src/main/resources/QueryDetectionVSFixingGraph.sql – Ugo Giordano Jul 04 '14 at 14:03
-
what kind a project you have? P.S. try "src/main/resources/QueryDetectionVSFixingGraph.sql" – Abylay Sabirgaliyev Jul 04 '14 at 14:14
-
It doesn't work. I have a maven project and I also tried with two backslash but nothing. – Ugo Giordano Jul 04 '14 at 14:19
-
i mean architecture of your project. if it's web this will help you http://stackoverflow.com/questions/3160691/how-to-read-properties-file-in-web-application – Abylay Sabirgaliyev Jul 04 '14 at 14:37