Cannot be cast to oracle.sql.BLOB #2

Open
seanleblanc opened this Issue Jan 14, 2014 · 2 comments

Comments

Projects
None yet
2 participants

I get this error upon trying to save when using Oracle as DB:

java.lang.ClassCastException: grails.plugin.lazylob.LazyBlob cannot be cast to oracle.sql.BLOB
at oracle.jdbc.driver.OraclePreparedStatement.setBlob(OraclePreparedStatement.java:6481)
at oracle.jdbc.driver.OraclePreparedStatementWrapper.setBlob(OraclePreparedStatementWrapper.java:126)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:184)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:184)
at org.apache.commons.dbcp.DelegatingPreparedStatement.setBlob(DelegatingPreparedStatement.java:184)
at grails.plugin.lazylob.LazyBlobType.nullSafeSet(LazyBlobType.java:25)

I'm using Grails 2.0.1.

sebDK commented May 12, 2014

I get exactly the same problem with grails-2.3.1.
Any workaround?

Thanks for your help.

sebDK commented May 15, 2014

Hi,

This is the workaround I used.
In LazyBlobType I changed

public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
BlobType.INSTANCE.nullSafeSet(st, value, index, getCurrentSession());
}

to

public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException {
BlobType.INSTANCE.nullSafeSet(st, ((LazyBlob)value).getBlob(), index, getCurrentSession());
}

and added the following into LazyBlob.java

public Blob getBlob() throws SQLException {
initialize();
return realLob;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment