01: package simpleorm.core;
02:
03: /**
04: * Generator using seperate SEQUENCE objects for databases that support them.
05: * Common method for Oracle.
06: */
07: public class SGeneratorSequence extends SGenerator {
08:
09: public SGeneratorSequence(SRecordMeta record) {
10: super (record);
11: }
12:
13: protected long generateKey(SRecordMeta meta, SFieldMeta keyField) {
14: SConnection scon = SConnection.getBegunConnection();
15: long key = scon.sDriver.generateKeySequence(meta, keyField);
16: return key;
17: }
18:
19: private String sequenceName() {
20: SFieldMeta keyField = (SFieldMeta) record.keySFieldMetas.get(0);
21: String name = keyField.getString(SCon.SSEQUENCE_NAME);
22: return name;
23: }
24:
25: public String createDDL() {
26: SConnection scon = SConnection.getBegunConnection();
27: return scon.sDriver.createSequenceDDL(sequenceName());
28: }
29:
30: public String dropDDL() {
31: SConnection scon = SConnection.getBegunConnection();
32: return scon.sDriver.dropSequenceDDL(sequenceName());
33: }
34: }
|