List of usage examples for org.apache.commons.lang UnhandledException UnhandledException
public UnhandledException(Throwable cause)
From source file:org.tsm.concharto.model.geometry.GeometryUserType.java
/** * Write an instance of the mapped class to a prepared statement. Implementors * should handle possibility of null values. A multi-column type should be * written to parameters starting from <tt>index</tt>. * //from w ww . j ava 2 s. c o m * @param st a JDBC prepared statement * @param value the object to write * @param index statement parameter index * @throws HibernateException * @throws SQLException */ @SuppressWarnings("deprecation") public void nullSafeSet(PreparedStatement st, Object value, int index) throws HibernateException, SQLException { if (value == null) { st.setNull(index, Types.BLOB); } else { Geometry geom = (Geometry) value; ByteArrayOutputStream bos = new ByteArrayOutputStream(); int SRID = geom.getSRID(); try { byte[] buf = new byte[4]; ByteOrderValues.putInt(SRID, buf, ByteOrderValues.LITTLE_ENDIAN); bos.write(buf); WKBWriter writer = new WKBWriter(2, ByteOrderValues.LITTLE_ENDIAN); writer.write(geom, new OutputStreamOutStream(bos)); } catch (IOException e) { // should be impossible throw new UnhandledException(e); } st.setBytes(index, bos.toByteArray()); } }