01: package org.springframework.jdbc.support.incrementer;
02:
03: import javax.sql.DataSource;
04:
05: /**
06: * DataFieldMaxValueIncrementer that retrieves the next value of a given H2 Database sequence.
07: *
08: * @author Thomas Risberg
09: */
10: public class H2SequenceMaxValueIncrementer extends
11: AbstractSequenceMaxValueIncrementer {
12:
13: /**
14: * Default constructor.
15: **/
16: public H2SequenceMaxValueIncrementer() {
17: }
18:
19: /**
20: * Convenience constructor.
21: * @param ds the DataSource to use
22: * @param incrementerName the name of the sequence to use
23: */
24: public H2SequenceMaxValueIncrementer(DataSource ds,
25: String incrementerName) {
26: setDataSource(ds);
27: setIncrementerName(incrementerName);
28: afterPropertiesSet();
29: }
30:
31: protected String getSequenceQuery() {
32: return "select " + getIncrementerName() + ".nextval from dual";
33: }
34:
35: }
|