/** * {@inheritDoc} */ @Override public void addToBagFromQuery(ObjectStoreBag osb, Query query) throws ObjectStoreException { List<QuerySelectable> select = query.getSelect(); if (select.size() != 1) { throw new IllegalArgumentException("Query has incorrect number of SELECT elements."); } Class<?> type = select.get(0).getType(); if (!(Integer.class.equals(type) || InterMineObject.class.isAssignableFrom(type))) { throw new IllegalArgumentException("The type of the result colum (" + type.getName() + ") is not an Integer or InterMineObject"); } try { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(query, getSchema()); readTables.add(INT_BAG_TABLE_NAME); batch.flush(c, readTables); addToBagFromQueryWithConnection(c, osb, query); } finally { releaseConnection(c); } } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } }
/** * {@inheritDoc} */ @Override public void addToBagFromQuery(ObjectStoreBag osb, Query query) throws ObjectStoreException { List<QuerySelectable> select = query.getSelect(); if (select.size() != 1) { throw new IllegalArgumentException("Query has incorrect number of SELECT elements."); } Class<?> type = select.get(0).getType(); if (!(Integer.class.equals(type) || InterMineObject.class.isAssignableFrom(type))) { throw new IllegalArgumentException("The type of the result colum (" + type.getName() + ") is not an Integer or InterMineObject"); } try { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(query, getSchema()); readTables.add(INT_BAG_TABLE_NAME); batch.flush(c, readTables); addToBagFromQueryWithConnection(c, osb, query); } finally { releaseConnection(c); } } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } }
throw new ObjectStoreException("Cannot delete by query from " + qc.getType()); String tableName = DatabaseUtil.getTableName(getSchema().getModel() .getClassDescriptorByName(qc.getType().getName())); batch.flush(con, Collections.singleton(tableName)); if (c != null) { sql.append(" WHERE "); SqlGenerator.constraintToString(null, sql, c, null, getSchema(), SqlGenerator.SAFENESS_SAFE, true);
throw new ObjectStoreException("Cannot delete by query from " + qc.getType()); String tableName = DatabaseUtil.getTableName(getSchema().getModel() .getClassDescriptorByName(qc.getType().getName())); batch.flush(con, Collections.singleton(tableName)); if (c != null) { sql.append(" WHERE "); SqlGenerator.constraintToString(null, sql, c, null, getSchema(), SqlGenerator.SAFENESS_SAFE, true);
/** * {@inheritDoc} * * This method is overridden in order to flush batches properly before the read. */ @Override public int count(Query q, Map<Object, Integer> sequence) throws ObjectStoreException { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(q, getSchema()); batch.flush(c, readTables); return countWithConnection(c, q, sequence); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }
/** * {@inheritDoc} * * This method is overridden in order to flush batches properly before the read. */ @Override public List<ResultsRow<Object>> execute(Query q, int start, int limit, boolean optimise, boolean explain, Map<Object, Integer> sequence) throws ObjectStoreException { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(q, getSchema()); batch.flush(c, readTables); return executeWithConnection(c, q, start, limit, optimise, explain, sequence); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }
/** * {@inheritDoc} * * This method is overridden in order to flush matches properly before the read. */ @Override protected InterMineObject internalGetObjectById(Integer id, Class<? extends InterMineObject> clazz) throws ObjectStoreException { if (schema.isFlatMode(clazz)) { return super.internalGetObjectById(id, clazz); } Connection c = null; try { c = getConnection(); String readTable = SqlGenerator.tableNameForId(clazz, getSchema()); batch.flush(c, Collections.singleton(readTable)); return internalGetObjectByIdWithConnection(c, id, clazz); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }
/** * {@inheritDoc} * * This method is overridden in order to flush batches properly before the read. */ @Override public int count(Query q, Map<Object, Integer> sequence) throws ObjectStoreException { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(q, getSchema()); batch.flush(c, readTables); return countWithConnection(c, q, sequence); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }
/** * {@inheritDoc} * * This method is overridden in order to flush matches properly before the read. */ @Override protected InterMineObject internalGetObjectById(Integer id, Class<? extends InterMineObject> clazz) throws ObjectStoreException { if (schema.isFlatMode(clazz)) { return super.internalGetObjectById(id, clazz); } Connection c = null; try { c = getConnection(); String readTable = SqlGenerator.tableNameForId(clazz, getSchema()); batch.flush(c, Collections.singleton(readTable)); return internalGetObjectByIdWithConnection(c, id, clazz); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }
/** * {@inheritDoc} * * This method is overridden in order to flush batches properly before the read. */ @Override public List<ResultsRow<Object>> execute(Query q, int start, int limit, boolean optimise, boolean explain, Map<Object, Integer> sequence) throws ObjectStoreException { Connection c = null; try { c = getConnection(); Set<String> readTables = SqlGenerator.findTableNames(q, getSchema()); batch.flush(c, readTables); return executeWithConnection(c, q, start, limit, optimise, explain, sequence); } catch (SQLException e) { throw new ObjectStoreException("Could not get connection to database", e); } finally { releaseConnection(c); } }