KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > orm > jpa > vendor > AbstractJpaVendorAdapter


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.orm.jpa.vendor;
18
19 import javax.persistence.EntityManagerFactory;
20
21 import org.springframework.orm.jpa.JpaVendorAdapter;
22
23 /**
24  * Abstract JpaVendorAdapter implementation that defines common properties,
25  * to be translated into vendor-specific JPA properties by subclasses.
26  *
27  * @author Juergen Hoeller
28  * @author Rod Johnson
29  * @since 2.0
30  */

31 public abstract class AbstractJpaVendorAdapter implements JpaVendorAdapter {
32
33     private Database database = Database.DEFAULT;
34
35     private String JavaDoc databasePlatform;
36
37     private boolean generateDdl;
38
39     private boolean showSql;
40
41
42     /**
43      * Specify the target database to operate on, as a value
44      * of the <code>Database</code> enum:
45      * DB2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
46      */

47     public void setDatabase(Database database) {
48         this.database = database;
49     }
50
51     /**
52      * Return the target database to operate on.
53      */

54     protected Database getDatabase() {
55         return database;
56     }
57
58     /**
59      * Specify the name of the target database to operate on.
60      * The supported values are vendor-dependent platform identifiers.
61      */

62     public void setDatabasePlatform(String JavaDoc databasePlatform) {
63         this.databasePlatform = databasePlatform;
64     }
65
66     /**
67      * Return the name of the target database to operate on.
68      */

69     protected String JavaDoc getDatabasePlatform() {
70         return databasePlatform;
71     }
72
73     /**
74      * Set whether to generate DDL after the EntityManagerFactory has been initialized,
75      * creating/updating all relevant tables.
76      * <p>Note that the exact semantics of this flag depend on the underlying
77      * persistence provider. For any more advanced needs, specify the appropriate
78      * vendor-specific settings as "jpaProperties".
79      * @see org.springframework.orm.jpa.AbstractEntityManagerFactoryBean#setJpaProperties
80      */

81     public void setGenerateDdl(boolean generateDdl) {
82         this.generateDdl = generateDdl;
83     }
84
85     /**
86      * Return whether to generate DDL after the EntityManagerFactory has been initialized
87      * creating/updating all relevant tables.
88      */

89     protected boolean isGenerateDdl() {
90         return generateDdl;
91     }
92
93     /**
94      * Set whether to show SQL in the log (or in the console).
95      * <p>For more specific logging configuration, specify the appropriate
96      * vendor-specific settings as "jpaProperties".
97      * @see org.springframework.orm.jpa.AbstractEntityManagerFactoryBean#setJpaProperties
98      */

99     public void setShowSql(boolean showSql) {
100         this.showSql = showSql;
101     }
102
103     /**
104      * Return whether to show SQL in the log (or in the console).
105      */

106     protected boolean isShowSql() {
107         return showSql;
108     }
109
110
111     /**
112      * Post-process the EntityManagerFactory after it has been initialized.
113      * @param emf the EntityManagerFactory to process
114      */

115     public void postProcessEntityManagerFactory(EntityManagerFactory emf) {
116     }
117
118 }
119
Popular Tags