Skip to content

Commit a2216e0

Browse files
committed
Bring back original DataAccessStrategy#insert method signature to maintain backward compatibility.
+ Default implementation of original method will no longer work as expected when the id property of the instance is pre-populated. + Deprecate original method.
1 parent 9898c2e commit a2216e0

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

spring-data-jdbc/src/main/java/org/springframework/data/jdbc/core/convert/DataAccessStrategy.java

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,29 @@ public interface DataAccessStrategy extends RelationResolver {
4949
* @param identifier information about data that needs to be considered for the insert but which is not part of the
5050
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
5151
* {@link Map} or {@link List}.
52-
* @param includeId an indicator of whether the insert includes the id.
5352
* @return the id generated by the database if any.
5453
* @since 1.1
54+
* @deprecated since 2.4, use {@link #insert(T, Class, Identifier, boolean)}. This will no longer insert as expected
55+
* when the id property of the instance is pre-populated.
56+
*/
57+
@Nullable
58+
@Deprecated
59+
default <T> Object insert(T instance, Class<T> domainType, Identifier identifier) {
60+
return insert(instance, domainType, identifier, false);
61+
}
62+
63+
/**
64+
* Inserts the data of a single entity. Referenced entities don't get handled.
65+
*
66+
* @param <T> the type of the instance.
67+
* @param instance the instance to be stored. Must not be {@code null}.
68+
* @param domainType the type of the instance. Must not be {@code null}.
69+
* @param identifier information about data that needs to be considered for the insert but which is not part of the
70+
* entity. Namely references back to a parent entity and key/index columns for entities that are stored in a
71+
* {@link Map} or {@link List}.
72+
* @param includeId an indicator of whether the insert includes the id.
73+
* @return the id generated by the database if any.
74+
* @since 2.4
5575
*/
5676
@Nullable
5777
<T> Object insert(T instance, Class<T> domainType, Identifier identifier, boolean includeId);

0 commit comments

Comments
 (0)