Code example for PreparedStatement

Methods: setDouble, setNull

0
            throws HibernateException, SQLException { 
 
        BoundingBox box = (BoundingBox) value;
        if (box == null) {
            //set to null 
            st.setDouble(index, 1);
            st.setDouble(index + 1, 1);
            st.setDouble(index + 2, -1);
            st.setDouble(index + 3, -1);
            st.setNull(index + 4, Types.VARCHAR);
            //st.setBlob(index + 4, (Blob) null); 
            return; 
        } 
 
        //TODO: check for isNull() and set the minx,maxx accordingly 
        st.setDouble(index, box.getMinX());
        st.setDouble(index + 1, box.getMinY());
        st.setDouble(index + 2, box.getMaxX());
        st.setDouble(index + 3, box.getMaxY());
 
        if (box.getCoordinateReferenceSystem() != null) {
            CoordinateReferenceSystem crs = box.getCoordinateReferenceSystem();
            if (storeCRSAsWKT) {
                st.setString(index+4, crs.toWKT());
            } 
            else { 
                try { 
                    st.setString(index+4, "EPSG:"+ CRS.lookupEpsgCode(crs, true));
                }  
                catch (FactoryException e) {
                    throw new RuntimeException(e);
                } 
            } 
            //st.setBlob(index + 4, Hibernate.createBlob(crs.toWKT().getBytes())); 
        } else { 
            st.setNull(index+4, Types.VARCHAR);
            //st.setBlob(index + 4, (Blob) null); 
        } 
    } 
 
    public Object replace(Object original, Object target, Object owner) throws HibernateException {