Spring Framework SimpleJdbcInsert - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Spring Framework SimpleJdbcInsert class.

This code example shows how to use the following methods:
	private SimpleJdbcInsert insertGame;
 
	@Override 
	protected void initDao() throws Exception {
		super.initDao(); 
		insertGame = new SimpleJdbcInsert(getDataSource()).withTableName("GAMES").usingColumns("player_id", "year_no",
				"team", "week", "opponent", " completes", "attempts", "passing_yards", "passing_td", "interceptions", 
				"rushes", "rush_yards", "receptions", "receptions_yards", "total_td"); 
	} 
 
	@Override 
	public void write(List<? extends Game> games) {
 
		for (Game game : games) {
 
			SqlParameterSource values = new MapSqlParameterSource().addValue("player_id", game.getId()).addValue(
					"year_no", game.getYear()).addValue("team", game.getTeam()).addValue("week", game.getWeek())
					.addValue("opponent", game.getOpponent()).addValue("completes", game.getCompletes()).addValue(
							"attempts", game.getAttempts()).addValue("passing_yards", game.getPassingYards()).addValue(
							"passing_td", game.getPassingTd()).addValue("interceptions", game.getInterceptions())
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
   private SimpleJdbcInsert bookInsert; 
 
   @Autowired(required = true) 
   public void initialize(final DataSource dataSource) { 
      this.jdbcTemplate = new SimpleJdbcTemplate(dataSource); 
      this.bookInsert = new SimpleJdbcInsert(dataSource).withTableName("books") 
            .usingGeneratedKeyColumns("id"); 
   } 
 
   /** 
    * <p> 
    * Look up and return the {@code Book} identified by the supplied {@code bookId}. By annotating 
    * this method with {@code @Cacheable(value = "books", key = "#bookId")} we achieve the 
    * following: 
    * <ol> 
    * <li> 
    * {@code Book} instances returned from this method will be cached in a named 
    * {@link org.springframework.cache.Cache <code>Cache</code>} &quot;books&quot;</li> 
    * <li> 
    * The key used to cache {@code Book} instances will be the supplied {@code bookId}.</li> 
5
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        this.tableName = tableName;
    } 
 
    @Override 
    public void afterPropertiesSet() throws Exception {
        this.insert = new SimpleJdbcInsert(jt).withTableName(tableName).usingGeneratedKeyColumns("id");
    } 
 
    @Override 
    public long create(final T object) {
        return insert.executeAndReturnKey(toInsertData(object)).longValue();
    } 
 
    protected abstract SqlParameterSource toInsertData(T object);
} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:withTableName
    private SimpleJdbcInsert simpleInsert; 
 
    @Autowired 
	public void init(DataSource dataSource) { 
		this.simpleJdbcTemplate = new SimpleJdbcTemplate(dataSource); 
        this.simpleInsert = new SimpleJdbcInsert(dataSource); 
        this.simpleInsert.withTableName("contacts").usingGeneratedKeyColumns("id"); 
	} 
 
    @Override 
    @Transactional(readOnly = true) 
    public Contact findById(Integer id) { 
 
        Contact contact; 
		try { 
			contact = this.simpleJdbcTemplate.queryForObject( 
					SQL_SELECT + "WHERE id=?", 
					BeanPropertyRowMapper.newInstance(Contact.class), 
					id); 
		} 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    } 
     
    @Override 
    public void afterPropertiesSet() throws Exception {
        super.afterPropertiesSet(); 
        this.memberInsert = new SimpleJdbcInsert(this.jt).withTableName(MEMBER_TABLE_NAME);
    } 
     
    @Override 
    public long create(QNameFilter filter) {
        Long id = super.create(filter);
        filter.setId( id );
        insertQnames(filter);
        return id;
    } 
 
    private void insertQnames(QNameFilter filter) {
        if ( filter.getQNames().size() > 0 ) {
            final List<SqlParameterSource> batch = new ArrayList<SqlParameterSource>();
            for ( Name qname : filter.getQNames()) {
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
        String sql = "SELECT * FROM tables WHERE checksum = ?"; 
        List<Table> tables = getJdbcTemplate().query(sql, new TableMapper(), table.getChecksum());         
        if (!tables.isEmpty()) { 
            throw new RecoverableDataAccessException("An identical table has already been uploaded."); 
        } else { 
            this.insertActor = new SimpleJdbcInsert(getDataSource()).withTableName("tables").usingGeneratedKeyColumns("tableId"); 
            SqlParameterSource parameters = new BeanPropertySqlParameterSource(table); 
            Number newTableId = insertActor.executeAndReturnKey(parameters); 
            table.setTableId(newTableId.intValue()); 
        }                 
    } 
 
    /** 
     * Saves changes made to an existing table.  
     *  
     * @param table   The existing table with changes that needs to be saved.  
     * @throws RecoverableDataAccessException  If unable to find the table to update.  
     */ 
    public void updateTable(Table table) { 
        String sql = "UPDATE tables SET title = ?, description = ?, localVersion = ?, center= ?, subCenter= ?, tableType = ?, dateModified = ? WHERE tableId = ?"; 
4
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    return note.getNoteId(); 
  } 
 
  public long saveProjectOverviewNote(ProjectOverview overview, Note note) throws IOException { 
    long noteId = save(note); 
    SimpleJdbcInsert pInsert = new SimpleJdbcInsert(template) 
            .withTableName("ProjectOverview_Note"); 
 
    MapSqlParameterSource poParams = new MapSqlParameterSource(); 
    poParams.addValue("overview_overviewId", overview.getOverviewId()) 
            .addValue("notes_noteId", noteId); 
 
    try { 
      pInsert.execute(poParams); 
    } 
    catch(DuplicateKeyException se) { 
      //ignore 
    } 
    return note.getNoteId(); 
  } 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
		accountParameters.put("subdomain", "");
		Number accountId = accountJdbcInsert
				.executeAndReturnKey(accountParameters);
 
		LOG.debug("Insert default users"); 
		SimpleJdbcInsert userJdbcInsert = new SimpleJdbcInsert(jdbcTemplate)
				.withTableName("s_user").usingColumns("username", "firstname",
						"lastname", "email", "status", "registeredTime", 
						"password", "timezone"); 
 
		Map<String, Object> userParameters = new HashMap<String, Object>();
		userParameters.put("username", "admin@mycollab.com");
		userParameters.put("firstname", "");
		userParameters.put("lastname", "admin");
		userParameters.put("email", "admin@mycollab.com");
		userParameters.put("status", "Active");
		userParameters.put("registeredTime", new Date());
		userParameters.put("password",
				PasswordEncryptHelper.encryptSaltPassword("admin123")); 
		userParameters.put("timezone",
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
    return userid; 
  } 
 
  private int createTag(String tagName) { 
    SimpleJdbcInsert insert = 
            new SimpleJdbcInsert(jdbcTemplate) 
            .withTableName("tags_values") 
            .usingGeneratedKeyColumns("id"); 
 
    return insert.executeAndReturnKey(ImmutableMap.<String, Object>of("value", tagName)).intValue(); 
 } 
 
  @Before 
  public void prepareTestData() { 
    user1Id = createUser("UserTagDaoIntegrationTest_user1"); 
    user2Id = createUser("UserTagDaoIntegrationTest_user2"); 
 
    tag1Id = createTag("UserTagDaoIntegrationTest_tag1"); 
    tag2Id = createTag("UserTagDaoIntegrationTest_tag2"); 
    tag3Id = createTag("UserTagDaoIntegrationTest_tag3"); 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
This code example shows how to use the following methods:
            .addValue("instrumentModel", platform.getInstrumentModel()) 
            .addValue("description", platform.getDescription()) 
            .addValue("numContainers", platform.getNumContainers()); 
 
    if (platform.getPlatformId() == null) { 
      SimpleJdbcInsert insert = new SimpleJdbcInsert(template) 
              .withTableName(TABLE_NAME) 
              .usingGeneratedKeyColumns("platformId"); 
      Number newId = insert.executeAndReturnKey(params); 
      platform.setPlatformId(newId.longValue()); 
    } 
    else { 
      params.addValue("platformId", platform.getPlatformId()); 
      NamedParameterJdbcTemplate namedTemplate = new NamedParameterJdbcTemplate(template); 
      namedTemplate.update(PLATFORM_UPDATE, params); 
    } 
     
    return platform.getPlatformId(); 
  } 
 
3
CodeRank
Contextual code suggestions in your IDE  Get Codota for Java
See Code Examples for Spring Framework SimpleJdbcInsert Methods: