Code example for PreparedStatement

Methods: setBlob, setBytes

0
                ObjectOutputStream out = new ObjectOutputStream(bytes);
                out.writeObject(value);
                out.flush();
                 
                if (useHibernateBlob()) { 
                  st.setBlob(index, new BlobImpl(bytes.toByteArray()));
                } 
                else { 
                    st.setBytes(index, bytes.toByteArray());    
                } 
                 
                out.close();
            }  
            catch (IOException e) {
                throw new HibernateException(e);
            } 
        } 
        else { 
            st.setNull(index, Types.BLOB);
            //st.setBytes(index, null); 
        }