March 20, 2013

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 ID......