Nullability fine-tuning around bean properties

Issue: SPR-15720
Issue: SPR-15792
This commit is contained in:
Juergen Hoeller
2017-07-19 11:43:58 +02:00
parent 06fc092be2
commit 9fc4fb10b0
31 changed files with 243 additions and 206 deletions

View File

@@ -36,6 +36,7 @@ public abstract class AbstractJpaVendorAdapter implements JpaVendorAdapter {
private Database database = Database.DEFAULT;
@Nullable
private String databasePlatform;
private boolean generateDdl = false;
@@ -47,14 +48,13 @@ public abstract class AbstractJpaVendorAdapter implements JpaVendorAdapter {
* Specify the target database to operate on, as a value of the {@code Database} enum:
* DB2, DERBY, H2, HSQL, INFORMIX, MYSQL, ORACLE, POSTGRESQL, SQL_SERVER, SYBASE
*/
public void setDatabase(@Nullable Database database) {
public void setDatabase(Database database) {
this.database = database;
}
/**
* Return the target database to operate on.
*/
@Nullable
protected Database getDatabase() {
return this.database;
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,7 +65,7 @@ public class EclipseLinkJpaVendorAdapter extends AbstractJpaVendorAdapter {
if (getDatabasePlatform() != null) {
jpaProperties.put(PersistenceUnitProperties.TARGET_DATABASE, getDatabasePlatform());
}
else if (getDatabase() != null) {
else {
String targetDatabase = determineTargetDatabaseName(getDatabase());
if (targetDatabase != null) {
jpaProperties.put(PersistenceUnitProperties.TARGET_DATABASE, targetDatabase);

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2016 the original author or authors.
* Copyright 2002-2017 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,7 +18,6 @@ package org.springframework.orm.jpa.vendor;
import java.util.HashMap;
import java.util.Map;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.spi.PersistenceProvider;
@@ -117,7 +116,7 @@ public class HibernateJpaVendorAdapter extends AbstractJpaVendorAdapter {
if (getDatabasePlatform() != null) {
jpaProperties.put(AvailableSettings.DIALECT, getDatabasePlatform());
}
else if (getDatabase() != null) {
else {
Class<?> databaseDialectClass = determineDatabaseDialectClass(getDatabase());
if (databaseDialectClass != null) {
jpaProperties.put(AvailableSettings.DIALECT, databaseDialectClass.getName());