/** * {@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 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); } }
public void testInvalidClassForGetById() throws Exception { try { SqlGenerator.generateQueryForId(new Integer(5), SqlGeneratorTest.class, getSchema()); fail("Expected: ObjectStoreException"); } catch (ObjectStoreException e) { assertEquals("class org.intermine.objectstore.intermine.SqlGeneratorTest is not in the model", e.getMessage()); } try { SqlGenerator.tableNameForId(SqlGeneratorTest.class, getSchema()); fail("Expected: ObjectStoreException"); } catch (ObjectStoreException e) { assertEquals("class org.intermine.objectstore.intermine.SqlGeneratorTest is not in the model", e.getMessage()); } } }
public void testInvalidClassForGetById() throws Exception { try { SqlGenerator.generateQueryForId(new Integer(5), SqlGeneratorTest.class, getSchema()); fail("Expected: ObjectStoreException"); } catch (ObjectStoreException e) { assertEquals("class org.intermine.objectstore.intermine.SqlGeneratorTest is not in the model", e.getMessage()); } try { SqlGenerator.tableNameForId(SqlGeneratorTest.class, getSchema()); fail("Expected: ObjectStoreException"); } catch (ObjectStoreException e) { assertEquals("class org.intermine.objectstore.intermine.SqlGeneratorTest is not in the model", e.getMessage()); } } }