خرید بک لینک

Vote count: 0

I use spring framework, and would like to insert a row to DB in order to have its ID, which is needed for further processing. Inserting query is given below, it's a simple query, without parameters. But it's even worse, cause how to construct working call using executeAndRetuKey from SimpleJdbcInsert? This is an SQL query for insert. But I don't know whether is possible to use it within simpleJdbcInsert instance.

insert into sdc_import_run(id_import_run, create_date)
values(nextval('seq_import_run'),now())

I tried

Number genId = simpleJdbcInsert.withTableName("sdc_import_run")
            .usingGeneratedKeyColumns("id_import_run")
            .executeAndRetuKey(new MapSqlParameterSource());

It doesn't work, the thing is, they want all parameters for the table, but I dont want any of them, I want to insert only auto-generated: id_import_run (primary key) and create_date. As a result I want to have the inserted ID in a variable. How would you do that?

asked 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: چهارشنبه 1 ارديبهشت 1395 ساعت: 18:40

صفحه بندی