Skip to content

Instantly share code, notes, and snippets.

@delphym
Created February 9, 2022 03:10
Show Gist options
  • Save delphym/1a45d020efa3a1f8ca62acbc5d08fa71 to your computer and use it in GitHub Desktop.
Save delphym/1a45d020efa3a1f8ca62acbc5d08fa71 to your computer and use it in GitHub Desktop.
To demonstrate how to run simple SELECT statement and get result back as a list of defined object models.
@SpringBootTest
class DBquerryAsListTest {
@Autowired
@Qualifier("testSetupDataSource")
DataSource testSetupDataSource;
JdbcTemplate jdbcTemplate;
@Test
void runSelectQuerryTest() {
jdbcTemplate = new JdbcTemplate(testSetupDataSource);
List<TestDataResponseModel> dataResponses = jdbcTemplate.query("SELECT * FROM vw_subscriptions WHERE instanceId in (?, ?);", new LiteDBBeanPropertyRowMapper<>(TestDataResponseModel.class), instanceId, upgradeInstanceId);
assertTrue(dataResponses.size() > 0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment