@Test @Sql(scripts = {"/sql/clearAccountEntity.sql", "/sql/insertAccountEntity.sql"}) public void test_find_by_id() { AccountEntityEntity accountEntityEntity = AccountEntityEntity.builder().id("1").build(); accountEntityEntity.setTenantId("default"); AccountEntityEntity result = accountEntityJdbcRepository.findById(accountEntityEntity); assertThat(result.getId()).isEqualTo("1"); assertThat(result.getName()).isEqualTo("name"); assertThat(result.getCode()).isEqualTo("code"); }
public AccountEntityEntity findById(AccountEntityEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<AccountEntityEntity> accountentities = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(AccountEntityEntity.class)); if (accountentities.isEmpty()) { return null; } else { return accountentities.get(0); } }
AccountEntityJdbcRepository extends JdbcRepository { public AccountEntityEntity findById(AccountEntityEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<AccountEntityEntity> accountentities = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(AccountEntityEntity.class)); if (accountentities.isEmpty()) { return null; } else { return accountentities.get(0); } } }
AccountEntityJdbcRepository extends JdbcRepository { public AccountEntityEntity findById(AccountEntityEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<AccountEntityEntity> accountentities = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(AccountEntityEntity.class)); if (accountentities.isEmpty()) { return null; } else { return accountentities.get(0); } } AccountEntityJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); }
AccountEntityJdbcRepository extends JdbcRepository { public AccountEntityEntity findById(AccountEntityEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<AccountEntityEntity> accountentities = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(AccountEntityEntity.class)); if (accountentities.isEmpty()) { return null; } else { return accountentities.get(0); } } AccountEntityJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); AccountEntityEntity create(AccountEntityEntity entity); AccountEntityEntity update(AccountEntityEntity entity); Pagination<AccountEntity> search(AccountEntitySearch domain); AccountEntityEntity findById(AccountEntityEntity entity); }
AccountEntityJdbcRepository extends JdbcRepository { public AccountEntityEntity findById(AccountEntityEntity entity) { List<String> list = allIdentitiferFields.get(entity.getClass().getSimpleName()); Map<String, Object> paramValues = new HashMap<>(); for (String s : list) { paramValues.put(s, getValue(getField(entity, s), entity)); } List<AccountEntityEntity> accountentities = namedParameterJdbcTemplate.query( getByIdQuery.get(entity.getClass().getSimpleName()).toString(), paramValues, new BeanPropertyRowMapper(AccountEntityEntity.class)); if (accountentities.isEmpty()) { return null; } else { return accountentities.get(0); } } AccountEntityJdbcRepository(NamedParameterJdbcTemplate namedParameterJdbcTemplate); AccountEntityEntity create(AccountEntityEntity entity); AccountEntityEntity update(AccountEntityEntity entity); Pagination<AccountEntity> search(AccountEntitySearch domain); AccountEntityEntity findById(AccountEntityEntity entity);  }