Skip to content

Instantly share code, notes, and snippets.

@bdarfler
Last active May 23, 2018 11:30
Show Gist options
  • Save bdarfler/1cca45cfabc42a6782babb011428fbdf to your computer and use it in GitHub Desktop.
Save bdarfler/1cca45cfabc42a6782babb011428fbdf to your computer and use it in GitHub Desktop.
// Get Datasource from Spring Context
SimpleJdbcInsert jdbcInsert = new SimpleJdbcInsert( dataSource ).withTableName( dbObj.getTableName() ).usingGeneratedKeyColumns( "id" );
final int id = jdbcInsert.executeAndReturnKey( new BeanPropertySqlParameterSource( dbObj ) ).intValue();
dbObj.setId( id );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment