38
38
import org .springframework .data .jdbc .core .convert .IdGeneratingEntityCallback ;
39
39
import org .springframework .data .jdbc .repository .config .EnableJdbcRepositories ;
40
40
import org .springframework .data .jdbc .repository .support .SimpleJdbcRepository ;
41
+ import org .springframework .data .jdbc .testing .EnabledOnFeature ;
41
42
import org .springframework .data .jdbc .testing .IntegrationTest ;
42
43
import org .springframework .data .jdbc .testing .TestConfiguration ;
44
+ import org .springframework .data .jdbc .testing .TestDatabaseFeatures ;
43
45
import org .springframework .data .relational .core .conversion .MutableAggregateChange ;
44
46
import org .springframework .data .relational .core .mapping .NamingStrategy ;
45
47
import org .springframework .data .relational .core .mapping .Sequence ;
46
48
import org .springframework .data .relational .core .mapping .event .BeforeConvertCallback ;
47
49
import org .springframework .data .repository .CrudRepository ;
48
50
import org .springframework .data .repository .ListCrudRepository ;
49
- import org .springframework .test . context . jdbc . Sql ;
51
+ import org .springframework .jdbc . core . namedparam . NamedParameterJdbcOperations ;
50
52
51
53
/**
52
54
* Testing special cases for id generation with {@link SimpleJdbcRepository}.
59
61
@ IntegrationTest
60
62
class JdbcRepositoryIdGenerationIntegrationTests {
61
63
64
+ @ Autowired NamedParameterJdbcOperations operations ;
62
65
@ Autowired ReadOnlyIdEntityRepository readOnlyIdRepository ;
63
66
@ Autowired PrimitiveIdEntityRepository primitiveIdRepository ;
64
67
@ Autowired ImmutableWithManualIdEntityRepository immutableWithManualIdEntityRepository ;
@@ -123,9 +126,11 @@ void manuallyGeneratedIdForSaveAll() {
123
126
}
124
127
125
128
@ Test // DATAJDBC-2003
126
- @ Sql ( statements = "INSERT INTO SimpleSeq(id, name) VALUES(1, 'initial value');" )
129
+ @ EnabledOnFeature ( TestDatabaseFeatures . Feature . SUPPORTS_SEQUENCES )
127
130
void testUpdateAggregateWithSequence () {
128
131
132
+ operations .getJdbcOperations ().update ("INSERT INTO SimpleSeq(id, name) VALUES(1, 'initial value');" );
133
+
129
134
SimpleSeq entity = new SimpleSeq ();
130
135
entity .id = 1L ;
131
136
entity .name = "New name" ;
@@ -137,8 +142,8 @@ void testUpdateAggregateWithSequence() {
137
142
assertThat (afterCallback .join ().id ).isEqualTo (1L );
138
143
}
139
144
140
- @ Test
141
- // DATAJDBC-2003
145
+ @ Test // DATAJDBC-2003
146
+ @ EnabledOnFeature ( TestDatabaseFeatures . Feature . SUPPORTS_SEQUENCES )
142
147
void testInsertPersistableAggregateWithSequenceClientIdIsFavored () {
143
148
144
149
long initialId = 1L ;
@@ -153,6 +158,7 @@ void testInsertPersistableAggregateWithSequenceClientIdIsFavored() {
153
158
}
154
159
155
160
@ Test // DATAJDBC-2003
161
+ @ EnabledOnFeature (TestDatabaseFeatures .Feature .SUPPORTS_SEQUENCES )
156
162
void testInsertAggregateWithSequenceAndUnsetPrimitiveId () {
157
163
158
164
PrimitiveIdSeq entity = new PrimitiveIdSeq ();
0 commit comments