public Profissional insert(Profissional profissional) {
PreparedStatementCreator psc = connection -> {
PreparedStatement ps = connection.prepareStatement("insert into profissional(texto) values(?)",
new String[] { "id" });
ps.setString(1, profissional.getDsNomeProfissional());
return ps;
};
KeyHolder keyHolder = new GeneratedKeyHolder();
this.jdbc.update(psc, keyHolder);
profissional.setIdProfissional(keyHolder.getKey().longValue());
return profissional;
}
and is working and returning the Id
generated by the bank, but in this line id
to profissional.setIdProfissional(keyHolder.getKey().longValue());
is warning me that IDE
can return null, and I'm worried about this but also with doubts because Spring Docs is saying that this is the right way, Is this really possible? If yes, can someone explain to me if there is any other way to do this code without danger of returning% n of% null?
(Note: this is a more informative question if someone else has this same doubt as me.)