-
Notifications
You must be signed in to change notification settings - Fork 346
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reformat code, switch to tabs. Accept property in DatabaseTypeMapping to provide more context to the type mapping component. Rename LiquibaseChangeSetGenerator to …Writer as we're writing a changeset and computing the contents is a consequence of writing a changeset. Refine naming to express what we're actually doing. Introduce setters for enhanced configuration of predicates. Reduce visibility of types to avoid unwanted public API where public access is not needed. Remove usused code, move methods around for improved grouping of code. Rename package to schema as the schema is being created and updated and not generated. Rename …Model classes to just their name as types are package-private and not visible externally. Refactor SchemaDiff to Java record. Use different overloads to write schema changes to avoid LiquibaseException leaking into cases where no diff is being used. Introduce SchemaFilter to filter unwanted mapped entities. Move code to JDBC module. Introduce comparator strategy to customize how table and column names are compared. See #1478 Original pull request: #1520
- Loading branch information
Showing
26 changed files
with
1,605 additions
and
789 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
...rc/main/java/org/springframework/data/jdbc/core/mapping/schema/DefaultSqlTypeMapping.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/* | ||
* Copyright 2023 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. | ||
* You may obtain a copy of the License at | ||
* | ||
* https://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
package org.springframework.data.jdbc.core.mapping.schema; | ||
|
||
import java.math.BigDecimal; | ||
import java.math.BigInteger; | ||
import java.time.LocalDate; | ||
import java.time.LocalDateTime; | ||
import java.time.LocalTime; | ||
import java.time.ZonedDateTime; | ||
import java.util.HashMap; | ||
import java.util.UUID; | ||
|
||
import org.springframework.data.relational.core.mapping.RelationalPersistentProperty; | ||
import org.springframework.util.ClassUtils; | ||
|
||
/** | ||
* Class that provides a default implementation of mapping Java type to a Database type. To customize the mapping an | ||
* instance of a class implementing {@link SqlTypeMapping} interface can be set on the {@link Tables} class | ||
* | ||
* @author Kurt Niemi | ||
* @since 3.2 | ||
*/ | ||
public class DefaultSqlTypeMapping implements SqlTypeMapping { | ||
|
||
private final HashMap<Class<?>, String> typeMap = new HashMap<>(); | ||
|
||
public DefaultSqlTypeMapping() { | ||
|
||
typeMap.put(String.class, "VARCHAR(255 BYTE)"); | ||
typeMap.put(Boolean.class, "TINYINT"); | ||
typeMap.put(Double.class, "DOUBLE"); | ||
typeMap.put(Float.class, "FLOAT"); | ||
typeMap.put(Integer.class, "INT"); | ||
typeMap.put(Long.class, "BIGINT"); | ||
|
||
typeMap.put(BigInteger.class, "BIGINT"); | ||
typeMap.put(BigDecimal.class, "NUMERIC"); | ||
|
||
typeMap.put(UUID.class, "UUID"); | ||
|
||
typeMap.put(LocalDate.class, "DATE"); | ||
typeMap.put(LocalTime.class, "TIME"); | ||
typeMap.put(LocalDateTime.class, "TIMESTAMP"); | ||
|
||
typeMap.put(ZonedDateTime.class, "TIMESTAMPTZ"); | ||
} | ||
|
||
@Override | ||
public String getColumnType(RelationalPersistentProperty property) { | ||
return typeMap.get(ClassUtils.resolvePrimitiveIfNecessary(property.getActualType())); | ||
} | ||
} |
Oops, something went wrong.