JdbcInventory extends JdbcHelper implements Inventory { @Override public ObjectMessage getObject(InventoryVector vector) { try ( Connection connection = config.getConnection(); Statement stmt = connection.createStatement(); ResultSet rs = stmt.executeQuery("SELECT data, version FROM Inventory WHERE hash = X'" + vector + "'") ) { if (rs.next()) { Blob data = rs.getBlob("data"); return Factory.getObjectMessage(rs.getInt("version"), data.getBinaryStream(), (int) data.length()); } else { LOG.info("Object requested that we don't have. IV: " + vector); return null; } } catch (Exception e) { LOG.error(e.getMessage(), e); throw new ApplicationException(e); } } JdbcInventory(JdbcConfig config); @Override List<InventoryVector> getInventory(long... streams); @Override List<InventoryVector> getMissing(List<InventoryVector> offer, long... streams); @Override ObjectMessage getObject(InventoryVector vector); @Override List<ObjectMessage> getObjects(long stream, long version, ObjectType... types); @Override void storeObject(ObjectMessage object); @Override boolean contains(ObjectMessage object); @Override void cleanup();  }
@Test public void testGetObject() throws Exception { ObjectMessage object = inventory.getObject(inventoryVectorIgnore); assertNotNull(object); assertEquals(1, object.getStream()); assertEquals(inventoryVectorIgnore, object.getInventoryVector()); }