01: package com.technoetic.xplanner.db.hibernate;
02:
03: import java.util.Properties;
04:
05: import net.sf.hibernate.dialect.Dialect;
06: import net.sf.hibernate.id.TableHiLoGenerator;
07: import net.sf.hibernate.type.Type;
08:
09: public class HibernateIdentityGenerator extends TableHiLoGenerator {
10: public static final String TABLE_NAME = "identifier";
11: public static final String NEXT_ID_COL = "nextId";
12: public static final String SET_NEXT_ID_QUERY = "update "
13: + TABLE_NAME + " set " + NEXT_ID_COL + " = ?";
14: public static final String SET_NEXT_ID_ATOMIC_QUERY = SET_NEXT_ID_QUERY
15: + " where " + NEXT_ID_COL + " = ?";
16: public static final String GET_NEXT_ID_QUERY = "select "
17: + NEXT_ID_COL + " from " + TABLE_NAME;
18:
19: public void configure(Type type, Properties params, Dialect d) {
20: if (!params.containsKey(TABLE)) {
21: params.setProperty(TABLE, TABLE_NAME);
22: }
23: if (!params.containsKey(COLUMN)) {
24: params.setProperty(COLUMN, NEXT_ID_COL);
25: }
26: if (!params.containsKey(MAX_LO)) {
27: params.setProperty(MAX_LO, "10");
28: }
29: super .configure(type, params, d);
30: }
31:
32: public Object generatorKey() {
33:
34: return super.generatorKey();
35: }
36: }
|