Polishing.

Refine assignment flow and use early returns where possible. Cache empty MapSqlParameterSource. Reduce dependency on RelationalMappingContext using a lower-level abstraction signature. Simplify names. Use default value check from Commons. Fix log warning message. Add missing since tags.

Remove superfluous annotations and redundant code. Tweak documentation wording.

Closes #2003
Original pull request: #2005
This commit is contained in:
Mark Paluch
2025-04-09 10:00:31 +02:00
parent 0fc3187916
commit d0e43be314
9 changed files with 252 additions and 200 deletions

View File

@@ -41,11 +41,6 @@ public class Db2Dialect extends AbstractDialect {
return false;
}
@Override
public boolean sequencesSupported() {
return true;
}
@Override
public String createSequenceQuery(SqlIdentifier sequenceName) {
/*

View File

@@ -18,7 +18,6 @@ package org.springframework.data.relational.core.dialect;
import java.util.Arrays;
import java.util.Collection;
import org.jetbrains.annotations.NotNull;
import org.springframework.data.relational.core.sql.IdentifierProcessing;
import org.springframework.data.relational.core.sql.IdentifierProcessing.LetterCasing;
import org.springframework.data.relational.core.sql.IdentifierProcessing.Quoting;
@@ -152,7 +151,7 @@ public class MySqlDialect extends AbstractDialect {
}
@Override
public String createSequenceQuery(@NotNull SqlIdentifier sequenceName) {
public String createSequenceQuery(SqlIdentifier sequenceName) {
throw new UnsupportedOperationException(
"Currently, there is no support for sequence generation for %s dialect. If you need it, please, submit a ticket"
.formatted(this.getClass().getSimpleName()));

View File

@@ -57,6 +57,8 @@ public interface RelationalPersistentEntity<T> extends MutablePersistentEntity<T
/**
* @return the target sequence that should be used for id generation
* @since 3.5
*/
Optional<SqlIdentifier> getIdSequence();
}

View File

@@ -9,9 +9,10 @@ import java.lang.annotation.Target;
import org.springframework.core.annotation.AliasFor;
/**
* Specify the sequence from which the value for the {@link org.springframework.data.annotation.Id} should be fetched
* Specify the sequence from which the value for the {@link org.springframework.data.annotation.Id} should be fetched.
*
* @author Mikhail Polivakha
* @since 3.5
*/
@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.FIELD)
@@ -31,14 +32,13 @@ public @interface Sequence {
String sequence() default "";
/**
* Schema where the sequence reside. Technically, this attribute is not necessarily the schema. It just represents the
* location/namespace, where the sequence resides. For instance, in Oracle databases the schema and user are often
* used interchangeably, so {@link #schema() schema} attribute may represent an Oracle user as well.
* Schema where the sequence resides. For instance, in Oracle databases the schema and user are often used
* interchangeably, so the {@code schema} attribute may represent an Oracle user as well.
* <p>
* The final name of the sequence to be queried for the next value will be constructed by the concatenation of schema
* and sequence :
*
* <pre>
* and sequence:
*
* <pre class="code">
* schema().sequence()
* </pre>
*/