01: /*
02: * Copyright 2002 (C) TJDO.
03: * All rights reserved.
04: *
05: * This software is distributed under the terms of the TJDO License version 1.0.
06: * See the terms of the TJDO License in the documentation provided with this software.
07: *
08: * $Id: ForeignKeyIdentifier.java,v 1.4 2003/02/26 00:22:47 jackknifebarber Exp $
09: */
10:
11: package com.triactive.jdo.store;
12:
13: class ForeignKeyIdentifier extends SQLIdentifier {
14: public static final int MAX_FOREIGN_KEYS = 36;
15:
16: public ForeignKeyIdentifier(BaseTable table, int seq) {
17: super (table.getStoreManager().getDatabaseAdapter());
18:
19: this .javaName = null;
20:
21: char suffix;
22:
23: if (seq < 10)
24: suffix = (char) ('0' + seq);
25: else if (seq < MAX_FOREIGN_KEYS)
26: suffix = (char) ('A' + seq);
27: else
28: throw new TooManyForeignKeysException(table);
29:
30: String baseID = truncate(table.getName().getSQLIdentifier(),
31: getMaxLength() - 4);
32:
33: setSQLIdentifier(baseID + "_FK" + suffix);
34: }
35:
36: protected int getMaxLength() {
37: return dba.getMaxConstraintNameLength();
38: }
39: }
|