The following problem occurred:
I tried to create a simpel file upload function in grails. I just created a domain class with
byte[] rawFile
as a property. For me, Grails left everything else for me. It worked fine for the standard hsqldb in dev environment.
Then I deployed it to the server with oracle db (thin driver) installed. Everything except file uploads works great with oracle db. To download the file I get (as far as I remember)
SQLException: ORA-01461: can bind LONG value only for insertion into LONG
I tried several ways to fix it (including some collation of columns with blocks and using java.sql.blob instead of byte []), but nothing really worked, and I went in the direction where my code would no longer be db.
Google really didn't help me, and my books about the Grail don't help either.
Saving a file to disk is not a good solution. My opinion.
So here is my question:
How to create file upload in grails that works with oracle?
Update : additional information has appeared. I managed to reproduce the problem with the XE version of Oracle:
Hibernate creates a VARBINARY (255) column for rawFile. So I tried to upload a file of 4 bytes in size, and it worked.
Then I manually changed the column type to "blob" and worked with large files.
Then i added
static mapping = {
columns {
rawFile type:'blob'
}
}
for my domain class and it stops working:
Errors ERROR.GrailsExceptionResolver - [B cannot be added to java.sql.Blob java.lang.ClassCastException: [B cannot be added to java.sql.Blob
: - (