@ -54,6 +54,7 @@ import org.springframework.data.annotation.PersistenceConstructor;
@@ -54,6 +54,7 @@ import org.springframework.data.annotation.PersistenceConstructor;
import org.springframework.data.annotation.ReadOnlyProperty ;
import org.springframework.data.annotation.Version ;
import org.springframework.data.domain.PageRequest ;
import org.springframework.data.domain.Persistable ;
import org.springframework.data.domain.Sort ;
import org.springframework.data.jdbc.core.convert.DataAccessStrategy ;
import org.springframework.data.jdbc.core.convert.JdbcConverter ;
@ -278,7 +279,8 @@ class JdbcAggregateTemplateIntegrationTests {
@@ -278,7 +279,8 @@ class JdbcAggregateTemplateIntegrationTests {
template . save ( createLegoSet ( "Star" ) ) ;
template . save ( createLegoSet ( "Frozen" ) ) ;
final Sort sort = Sort . by ( new Sort . Order ( Sort . Direction . ASC , "name" , Sort . NullHandling . NULLS_LAST ) ) ;
final Sort sort =
Sort . by ( new Sort . Order ( Sort . Direction . ASC , "name" , Sort . NullHandling . NULLS_LAST ) ) ;
Iterable < LegoSet > reloadedLegoSets = template . findAll ( LegoSet . class , sort ) ;
assertThat ( reloadedLegoSets ) //
@ -923,6 +925,16 @@ class JdbcAggregateTemplateIntegrationTests {
@@ -923,6 +925,16 @@ class JdbcAggregateTemplateIntegrationTests {
saveAndUpdateAggregateWithPrimitiveVersion ( new AggregateWithPrimitiveShortVersion ( ) , Number : : shortValue ) ;
}
@Test // GH-1254
void saveAndUpdateAggregateWithIdAndNullVersion ( ) {
PersistableVersionedAggregate aggregate = new PersistableVersionedAggregate ( ) ;
aggregate . setVersion ( null ) ;
aggregate . setId ( 23L ) ;
assertThatThrownBy ( ( ) - > template . save ( aggregate ) ) . isInstanceOf ( DbActionExecutionException . class ) ;
}
@Test // DATAJDBC-462
@EnabledOnFeature ( SUPPORTS_QUOTED_IDS )
void resavingAnUnversionedEntity ( ) {
@ -1115,18 +1127,15 @@ class JdbcAggregateTemplateIntegrationTests {
@@ -1115,18 +1127,15 @@ class JdbcAggregateTemplateIntegrationTests {
@Column ( "id4" ) @Id private Long id ;
String name ;
@MappedCollection ( idColumn = "LIST_PARENT" )
List < ElementNoId > content = new ArrayList < > ( ) ;
@MappedCollection ( idColumn = "LIST_PARENT" ) List < ElementNoId > content = new ArrayList < > ( ) ;
}
@Table ( "LIST_PARENT" )
static class ListParentAllArgs {
@Column ( "id4" ) @Id
private final Long id ;
@Column ( "id4" ) @Id private final Long id ;
private final String name ;
@MappedCollection ( idColumn = "LIST_PARENT" )
private final List < ElementNoId > content = new ArrayList < > ( ) ;
@MappedCollection ( idColumn = "LIST_PARENT" ) private final List < ElementNoId > content = new ArrayList < > ( ) ;
@PersistenceConstructor
ListParentAllArgs ( Long id , String name , List < ElementNoId > content ) {
@ -1287,6 +1296,20 @@ class JdbcAggregateTemplateIntegrationTests {
@@ -1287,6 +1296,20 @@ class JdbcAggregateTemplateIntegrationTests {
abstract void setVersion ( Number newVersion ) ;
}
@Data
@Table ( "VERSIONED_AGGREGATE" )
static class PersistableVersionedAggregate implements Persistable < Long > {
@Id private Long id ;
@Version Long version ;
@Override
public boolean isNew ( ) {
return getId ( ) = = null ;
}
}
@Value
@With
@Table ( "VERSIONED_AGGREGATE" )