myBATIS and Auto-Increment ID (Identity) on DB2

DDL:

CREATE TABLE TEST (
PID INTEGER GENERATED ALWAYS AS IDENTITY,
PNAME VARCHAR(6)
)

Your Object:

package com.mybusiness;
public class Test {
private long pid;
private String pname;

// setter and getters

}

And your SqlMap:

INSERT INTO TEST (PNAME) VALUES(#pname#)
SELECT IDENTITY_VAL_LOCAL() FROM SYSIBM.SYSDUMMY1

Ref: http://www.jroller.com/amin/entry/ibatis_and_auto_increment_id

2013-03-20 10:50418myBatisDB2Identity