01: /*
02: * Copyright 2006 Le Duc Bao, Ralf Joachim
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License"); you may not
05: * use this file except in compliance with the License. You may obtain a copy of
06: * the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12: * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13: * License for the specific language governing permissions and limitations under
14: * the License.
15: */
16: package org.castor.ddlgen.keygenerator;
17:
18: import org.castor.ddlgen.DDLWriter;
19: import org.castor.ddlgen.schemaobject.KeyGenerator;
20: import org.exolab.castor.mapping.xml.KeyGeneratorDef;
21:
22: /**
23: * IDENTITY key generator can be used only with autoincrement primary key columns
24: * (identities) with Sybase ASE/ASA, MS SQL Server, MySQL and Hypersonic SQL.
25: * After the insert the key generator selects system variable @@identity which
26: * contains the last identity value for the current database connection. In the case
27: * of MySQL and Hypersonic SQL the system functions LAST_INSERT_ID() and IDENTITY()
28: * are called, respectively.
29: *
30: * @author <a href="mailto:leducbao AT gmail DOT com">Le Duc Bao</a>
31: * @author <a href="mailto:ralf DOT joachim AT syscon DOT eu">Ralf Joachim</a>
32: * @version $Revision: 5951 $ $Date: 2006-04-25 16:09:10 -0600 (Tue, 25 Apr 2006) $
33: * @since 1.1
34: */
35: public final class IdentityKeyGenerator extends KeyGenerator {
36: //--------------------------------------------------------------------------
37:
38: /** Name of key generator algorithm. */
39: public static final String ALGORITHM_NAME = "IDENTITY";
40:
41: //--------------------------------------------------------------------------
42:
43: /**
44: * Constructor for default IDENTITY key generator.
45: */
46: public IdentityKeyGenerator() {
47: super (ALGORITHM_NAME, ALGORITHM_NAME);
48: }
49:
50: /**
51: * Constructor for IDENTITY key generator specified by given defintion.
52: *
53: * @param definition Key generator definition.
54: */
55: public IdentityKeyGenerator(final KeyGeneratorDef definition) {
56: super (ALGORITHM_NAME, definition.getAlias());
57: }
58:
59: //--------------------------------------------------------------------------
60:
61: /**
62: * {@inheritDoc}
63: */
64: public void toCreateDDL(final DDLWriter writer) {
65: }
66:
67: /**
68: * {@inheritDoc}
69: */
70: public void toDropDDL(final DDLWriter writer) {
71: }
72:
73: //--------------------------------------------------------------------------
74: }
|