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 HSQL sequence.
07: * Thanks to Guillaume Bilodeau for the suggestion!
08: *
09: * NOTE: This is an alternative to using a regular table to support generating unique keys that
10: * was necessary in previous versions of HSQL.
11: *
12: * @author Thomas Risberg
13: * @see org.springframework.jdbc.support.incrementer.HsqlMaxValueIncrementer
14: */
15: public class HsqlSequenceMaxValueIncrementer extends
16: AbstractSequenceMaxValueIncrementer {
17:
18: /**
19: * Default constructor.
20: **/
21: public HsqlSequenceMaxValueIncrementer() {
22: }
23:
24: /**
25: * Convenience constructor.
26: * @param ds the DataSource to use
27: * @param incrementerName the name of the sequence to use
28: */
29: public HsqlSequenceMaxValueIncrementer(DataSource ds,
30: String incrementerName) {
31: setDataSource(ds);
32: setIncrementerName(incrementerName);
33: afterPropertiesSet();
34: }
35:
36: protected String getSequenceQuery() {
37: return "call next value for " + getIncrementerName();
38: }
39:
40: }
|