java - Is there a way to use Postgresql copy (loading CSV in table) from Hibernate? -


in current application using hibernate + postgresql. particular case need use copy functionality available in postgres load data csv file. there way use copy using hibernate.

postgres version : 9.4 hibernate version : 5.0.6 

based on @a-horse-with-no-name comment, put following code session.dowork deprecated.

sessionfactory factory = hibernateutil.getsessionfactory(); session session = factory.opensession(); sessionimplementor sessimpl = (sessionimplementor) session; connection conn = null; conn = sessimpl.getjdbcconnectionaccess().obtainconnection(); copymanager copymanager = new copymanager((baseconnection) conn); file tf =file.createtempfile("temp-file", "tmp");  string temppath =tf.getparent(); file tempfile = new file(temppath + file.separator + filename); filereader filereader = new filereader(tempfile); copymanager.copyin("copy testdata (col1, col2, col3)  stdin csv", filereader ); 

hope helps readers.


Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -

Python Pig Latin Translator -