Search code examples
javajpaeclipselinkblob

JPA, EclipseLink. Get progress whe upload a Blob field?


To improve the user experience. I would like to implement a progress bar, when the user commit a query with a Blob field. Now we are using EclipseLink and JPA in a Swing Client. But i don't know how can i get the progress as an ftp upload. Is it possible with JPA or EclipseLink? and/or Do it depend from the database driver?(Our case Oracle).

We take the decision to store in the database, 'cause this binaries has a certain grade of confidentiality.

Thanks in advance


Solution

  • To give a progress bar you would need to stream the write into the BLOB. For this you would need to use JDBC to update the BLOB field. You can use the unwrap(Connection.clas) API to get the JDBC Connection from a JPA EntityManager.

    How big is the BLOB? Check that streaming it takes a long time, if it doesn't, then there is no point to giving a progress bar. You could just give a progress bar in reading the file from the user into memory, then just write it to the database normally.

    You could also use a heuristic, but measuring/guessing the expected time for the write based on the size of the blob, then basing the process bar on this.