Posted on 2006-03-02 21:01
killvin 阅读(566)
评论(2) 编辑 收藏 所属分类:
osworkflow
早上的时间被该死的WorkflwoStore里的主键生成策略("主键生成策略"来源于Hibernate文档),该死的Sequence,从文档资料上看到DB2是支持Sequence的,按照db2的文档我执行了如下的语句:
create sequence seq_os_wfentry start with 10 increment by 10;
create sequence seq_os_currentsteps;
执行-ok
可是我以前不太了解Sequence的概念,这片资料倒是很有价值
http://www-128.ibm.com/developerworks/db2/library/techarticle/dm-0407zhang/
不过我以为查询Sequence就只需要执行SELECT NEXT VALUE FOR seq_os_wfentry 就ok了,可是谁知道总是报错?!在比较仔细的看了这片文章之后发现,其实根本就无法执行这条SQL!而需要这样
INSERT INTO EMPLOYEE ( SERIALNUMBER, FIRSTNAME, LASTNAME,
SALARY) VALUES(NEXTVAL FOR EMPSERIAL, 'Martin', 'Wong', 1000.00)
可是看看JDBCWorkflowStore的实现,这里是JDBCWorkflowStore的主键生成策略!
protected long getNextEntrySequence(Connection c) throws SQLException {
if (log.isDebugEnabled()) {
log.debug("Executing SQL statement: " + entrySequence);
}
PreparedStatement stmt = null;
ResultSet rset = null;
try {
stmt = c.prepareStatement(entrySequence);
rset = stmt.executeQuery();
rset.next();
long id = rset.getLong(1);
return id;
} finally {
cleanup(null, stmt, rset);
}
}
c.prepareStatement(entrySequence) - 其实执行了一条SQL语句,所以看来JDBCWorkflow根本不支持Sequence生成策略!!
该死的实现方式,看来我要重载其实现方式,不过说真的JDBCWorkflow的编码人员其实水平不匝地!