<p>I am using <a href="http://www.hibernate.org/" rel="noreferrer">Hibernate</a> in a Java application to access my Database and it works pretty well with MS-SQL and MySQL. But some of the data I have to show on some forms has to come from Text files, and by Text files I mean Human-Readable files, they can be CSV, Tab-Delimited, or even a key, value pair, per line since my data is as simple as this, but my preference of course is XML files.</p>

<p>My question is: Can I use hibernate to read those files using HQL, Query , EntityManager and all those resources Hibernate provides me to access files. Which file format should I use and How I configure My persistence.xml file to recognize files as Tables?</p>

[{'answer_id': 33516, 'author': 'erickson', 'author_id': 3474, 'author_profile': 'https://Stackoverflow.com/users/3474', 'pm_score': 4, 'selected': True, 'text': "<p>Hibernate is written against the JDBC API. So, you need a JDBC driver that works with the file format you are interested in. Obviously, even for read-only access, this isn't going to perform well, but it might still be useful if that's not a high priority. On a Windows system, you can set up ODBC datasources for delimited text files, Excel files, etc. Then you can set up the JdbcOdbcDriver in your Java application to use this data source.</p>\n\n<p>For most of the applications I work on, I would not consider this approach; I would use an import/export mechanism to convert from a real database (even if it's an in-process database like Berkeley DB or Derby) to the text files. Yes, it's an extra step, but it could be automated, and the performance isn't likely to be much worse than trying to use the text files directly (it will likely be much better, overall), and it will be more robust and easy to develop.</p>\n"}, {'answer_id': 33668, 'author': 'Damien B', 'author_id': 3069, 'author_profile': 'https://Stackoverflow.com/users/3069', 'pm_score': 0, 'selected': False, 'text': '<p>Like erickson said, your only hope is in finding a JDBC driver for that task. There is maybe <del><a href="https://xlsql.dev.java.net/" rel="nofollow noreferrer">xlsql</a></del> (CSV, XML and Excel driver) which could fit the task. After that, you just have to either find or write the most simple Hibernate Dialect which fits your driver.</p>\n'}, {'answer_id': 34265, 'author': 'toolkit', 'author_id': 3295, 'author_profile': 'https://Stackoverflow.com/users/3295', 'pm_score': 3, 'selected': False, 'text': '<p>A quick google came up with</p>\n\n<ul>\n<li><a href="http://sourceforge.net/projects/csvjdbc" rel="noreferrer">JDBC driver for csv files</a></li>\n<li><a href="http://www.csv-jdbc.com/stels_xml_jdbc.htm" rel="noreferrer">JDBC driver for XML files</a></li>\n</ul>\n\n<p>Hope this might provide some inspiration?</p>\n'}]
['https://Stackoverflow.com/questions/33438', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2274/']