KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cayenne > dba > PkGenerator


1 /*****************************************************************
2  * Licensed to the Apache Software Foundation (ASF) under one
3  * or more contributor license agreements. See the NOTICE file
4  * distributed with this work for additional information
5  * regarding copyright ownership. The ASF licenses this file
6  * to you under the Apache License, Version 2.0 (the
7  * "License"); you may not use this file except in compliance
8  * with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  ****************************************************************/

19
20
21 package org.apache.cayenne.dba;
22
23 import java.util.List JavaDoc;
24
25 import org.apache.cayenne.access.DataNode;
26 import org.apache.cayenne.map.DbEntity;
27
28 /**
29  * Defines methods to support automatic primary key generation.
30  *
31  * @author Andrus Adamchik
32  */

33 public interface PkGenerator {
34
35     /**
36      * Generates necessary database objects to provide automatic primary key support.
37      *
38      * @param node node that provides access to a DataSource.
39      * @param dbEntities a list of entities that require primary key autogeneration
40      * support
41      */

42     void createAutoPk(DataNode node, List JavaDoc dbEntities) throws Exception JavaDoc;
43
44     /**
45      * Returns a list of SQL strings needed to generates database objects to provide
46      * automatic primary support for the list of entities. No actual database operations
47      * are performed.
48      */

49     List JavaDoc createAutoPkStatements(List JavaDoc dbEntities);
50
51     /**
52      * Drops any common database objects associated with automatic primary key generation
53      * process. This may be lookup tables, special stored procedures or sequences.
54      *
55      * @param node node that provides access to a DataSource.
56      * @param dbEntities a list of entities whose primary key autogeneration support
57      * should be dropped.
58      */

59     void dropAutoPk(DataNode node, List JavaDoc dbEntities) throws Exception JavaDoc;
60
61     /**
62      * Returns SQL string needed to drop database objects associated with automatic
63      * primary key generation. No actual database operations are performed.
64      */

65     List JavaDoc dropAutoPkStatements(List JavaDoc dbEntities);
66
67     /**
68      * Generates new (unique and non-repeating) primary key for specified DbEntity.
69      *
70      * @param ent DbEntity for which automatic PK is generated.
71      */

72     Object JavaDoc generatePkForDbEntity(DataNode dataNode, DbEntity ent) throws Exception JavaDoc;
73
74     /**
75      * Resets any cached primary keys forcing generator to go to the database next time id
76      * generation is requested. May not be applicable for all generator implementations.
77      */

78     void reset();
79 }
80
Popular Tags