@Override
public boolean put(final RevObject object) {
checkNotNull(object, "argument object is null");
checkArgument(!object.getId().isNull(), "ObjectId is NULL %s", object);
checkWritable();
config.checkRepositoryExists();
final ObjectId id = object.getId();
final PGId pgid = PGId.valueOf(id);
final String tableName = tableNameForType(object.getType(), pgid);
final String sql = format("INSERT INTO %s (id, object) VALUES (ROW(?,?,?),?)", tableName);
try (Connection cx = PGStorage.newConnection(dataSource)) {
cx.setAutoCommit(true);
try (PreparedStatement ps = cx.prepareStatement(log(sql, LOG, id, object))) {
pgid.setArgs(ps, 1);
byte[] blob = encoder.encode(object);
ps.setBytes(4, blob);
final int updateCount = ps.executeUpdate();
boolean inserted = updateCount == 1;
return inserted;
}
} catch (SQLException e) {
throw propagate(e);
}
}