Can any one please suggest me the best way of retrieving the records in hibernate [closed]

Can any one please suggest me the best way of retrieving the records in hibernate [closed]



I am working on a batch application where I have to retreive millions of records and need toprocess it individually. We are using hibernate to connect to DB.



I have tried using HQL and Criteria API to fetch the records(using the query Select * from table_name).
But it is taking more than 5 min .Sometimes it is getting hanged.



Can anyone suggest me the best approach for the data retrieving.



Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.






In this case, I believe your question was closed as too broad, not because you wanted to both process and retrieve the records, but because there could be countless possible causes of this problem, and without code and an attempt to troubleshoot the problem, there's no way to figure out what the specific problem you're trying to solve is.

– divibisan
Sep 10 '18 at 20:10




1 Answer
1



You may want to employ cursors, and if your queries are as simple as you indicated, pure JDBC may be sufficient - like here: https://docs.oracle.com/javase/tutorial/jdbc/basics/retrieving.html



Also, consider adding the WHERE clause to eliminate rows that can be recognized as irrelevant for your purposes.


WHERE



And depending on your table and queries, adding an index may also help.



If you need to use hibernate, you can use ScrollableResults as mentioned here: https://stackoverflow.com/a/9891008/455449


ScrollableResults






Actually, I am using hibernate in our project for ORM purpose.But , in the scenario that I have mentioned , taking more time to fetch.Can I implement similar way in hibernate.

– Pesala Sairam
Sep 10 '18 at 18:40







for that case, I found a related answer and mentioned in my text, but I never tried this myself

– Petr Kozelka
Sep 10 '18 at 18:46

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)