001: /*
002: * Copyright 2002-2006 the original author or authors.
003: *
004: * Licensed under the Apache License, Version 2.0 (the "License");
005: * you may not use this file except in compliance with the License.
006: * You may obtain a copy of the License at
007: *
008: * http://www.apache.org/licenses/LICENSE-2.0
009: *
010: * Unless required by applicable law or agreed to in writing, software
011: * distributed under the License is distributed on an "AS IS" BASIS,
012: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013: * See the License for the specific language governing permissions and
014: * limitations under the License.
015: */
016:
017: package org.springframework.orm.jpa.vendor;
018:
019: import javax.persistence.EntityManagerFactory;
020:
021: import org.springframework.orm.jpa.JpaVendorAdapter;
022:
023: /**
024: * Abstract JpaVendorAdapter implementation that defines common properties,
025: * to be translated into vendor-specific JPA properties by subclasses.
026: *
027: * @author Juergen Hoeller
028: * @author Rod Johnson
029: * @since 2.0
030: */
031: public abstract class AbstractJpaVendorAdapter implements
032: JpaVendorAdapter {
033:
034: private Database database = Database.DEFAULT;
035:
036: private String databasePlatform;
037:
038: private boolean generateDdl;
039:
040: private boolean showSql;
041:
042: /**
043: * Specify the target database to operate on, as a value
044: * of the <code>Database</code> enum:
045: * DB2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
046: */
047: public void setDatabase(Database database) {
048: this .database = database;
049: }
050:
051: /**
052: * Return the target database to operate on.
053: */
054: protected Database getDatabase() {
055: return database;
056: }
057:
058: /**
059: * Specify the name of the target database to operate on.
060: * The supported values are vendor-dependent platform identifiers.
061: */
062: public void setDatabasePlatform(String databasePlatform) {
063: this .databasePlatform = databasePlatform;
064: }
065:
066: /**
067: * Return the name of the target database to operate on.
068: */
069: protected String getDatabasePlatform() {
070: return databasePlatform;
071: }
072:
073: /**
074: * Set whether to generate DDL after the EntityManagerFactory has been initialized,
075: * creating/updating all relevant tables.
076: * <p>Note that the exact semantics of this flag depend on the underlying
077: * persistence provider. For any more advanced needs, specify the appropriate
078: * vendor-specific settings as "jpaProperties".
079: * @see org.springframework.orm.jpa.AbstractEntityManagerFactoryBean#setJpaProperties
080: */
081: public void setGenerateDdl(boolean generateDdl) {
082: this .generateDdl = generateDdl;
083: }
084:
085: /**
086: * Return whether to generate DDL after the EntityManagerFactory has been initialized
087: * creating/updating all relevant tables.
088: */
089: protected boolean isGenerateDdl() {
090: return generateDdl;
091: }
092:
093: /**
094: * Set whether to show SQL in the log (or in the console).
095: * <p>For more specific logging configuration, specify the appropriate
096: * vendor-specific settings as "jpaProperties".
097: * @see org.springframework.orm.jpa.AbstractEntityManagerFactoryBean#setJpaProperties
098: */
099: 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: * Post-process the EntityManagerFactory after it has been initialized.
112: * @param emf the EntityManagerFactory to process
113: */
114: public void postProcessEntityManagerFactory(EntityManagerFactory emf) {
115: }
116:
117: }
|