Getting auto-generated key from row insertion in spring 3 / PostgreSQL 8.4.9

KeyHolder holder = new GeneratedKeyHolder(); getJdbcTemplate().update(new PreparedStatementCreator() { @Override public PreparedStatement createPreparedStatement(Connection connection) throws SQLException { PreparedStatement ps = connection.prepareStatement(sql.toString(), Statement.RETURN_GENERATED_KEYS); ps.setString(1, person.getUsername()); ps.setString(2, person.getPassword()); ps.setString(3, person.getEmail()); ps.setLong(4, person.getRole().getId()); return ps; } }, holder); Long newPersonId = holder.getKey().longValue(); Note that in newer versions of Postgres you need to use connection.prepareStatement(sql.toString(), new String[] { “idcompte” /* … Read more

Any reason to write the “private” keyword in C#?

AFAIK, private is the default everywhere in C# (meaning that if I don’t write public, protected, internal, etc. it will be private by default). (please correct me if wrong). This is not true. Types defined within a namespace (classes, structs, interfaces, etc) will be internal by default. Also, members within different types have different default … Read more