JAVA Side
Long insertID = Long.parseLong(sqlMap.insert("scope.ibatorgenerated_insert", scopeRecord).toString())
Ibatis Side
<selectKey resultClass="java.lang.Long" keyProperty="scopeId" >
SELECT nextval('scope_scope_id_seq')
</selectKey>
SELECT nextval('scope_scope_id_seq')
</selectKey>
AUTO inc.
CREATE TABLE tablename ( colname SERIAL );
實際上是這樣實作
CREATE SEQUENCE tablename_colname_seq; CREATE TABLE tablename ( colname integer DEFAULT nextval('tablename_colname_seq') NOT NULL );
Reference:http://www.postgresql.org/docs/8.1/interactive/datatype.html
沒有留言:
張貼留言