|
|
|
@ -54,6 +54,7 @@ import org.springframework.data.annotation.PersistenceConstructor; |
|
|
|
import org.springframework.data.annotation.ReadOnlyProperty; |
|
|
|
import org.springframework.data.annotation.ReadOnlyProperty; |
|
|
|
import org.springframework.data.annotation.Version; |
|
|
|
import org.springframework.data.annotation.Version; |
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
import org.springframework.data.domain.PageRequest; |
|
|
|
|
|
|
|
import org.springframework.data.domain.Persistable; |
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
import org.springframework.data.domain.Sort; |
|
|
|
import org.springframework.data.jdbc.core.convert.DataAccessStrategy; |
|
|
|
import org.springframework.data.jdbc.core.convert.DataAccessStrategy; |
|
|
|
import org.springframework.data.jdbc.core.convert.JdbcConverter; |
|
|
|
import org.springframework.data.jdbc.core.convert.JdbcConverter; |
|
|
|
@ -278,7 +279,8 @@ class JdbcAggregateTemplateIntegrationTests { |
|
|
|
template.save(createLegoSet("Star")); |
|
|
|
template.save(createLegoSet("Star")); |
|
|
|
template.save(createLegoSet("Frozen")); |
|
|
|
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); |
|
|
|
Iterable<LegoSet> reloadedLegoSets = template.findAll(LegoSet.class, sort); |
|
|
|
|
|
|
|
|
|
|
|
assertThat(reloadedLegoSets) //
|
|
|
|
assertThat(reloadedLegoSets) //
|
|
|
|
@ -923,6 +925,16 @@ class JdbcAggregateTemplateIntegrationTests { |
|
|
|
saveAndUpdateAggregateWithPrimitiveVersion(new AggregateWithPrimitiveShortVersion(), Number::shortValue); |
|
|
|
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
|
|
|
|
@Test // DATAJDBC-462
|
|
|
|
@EnabledOnFeature(SUPPORTS_QUOTED_IDS) |
|
|
|
@EnabledOnFeature(SUPPORTS_QUOTED_IDS) |
|
|
|
void resavingAnUnversionedEntity() { |
|
|
|
void resavingAnUnversionedEntity() { |
|
|
|
@ -1115,18 +1127,15 @@ class JdbcAggregateTemplateIntegrationTests { |
|
|
|
|
|
|
|
|
|
|
|
@Column("id4") @Id private Long id; |
|
|
|
@Column("id4") @Id private Long id; |
|
|
|
String name; |
|
|
|
String name; |
|
|
|
@MappedCollection(idColumn = "LIST_PARENT") |
|
|
|
@MappedCollection(idColumn = "LIST_PARENT") List<ElementNoId> content = new ArrayList<>(); |
|
|
|
List<ElementNoId> content = new ArrayList<>(); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Table("LIST_PARENT") |
|
|
|
@Table("LIST_PARENT") |
|
|
|
static class ListParentAllArgs { |
|
|
|
static class ListParentAllArgs { |
|
|
|
|
|
|
|
|
|
|
|
@Column("id4") @Id |
|
|
|
@Column("id4") @Id private final Long id; |
|
|
|
private final Long id; |
|
|
|
|
|
|
|
private final String name; |
|
|
|
private final String name; |
|
|
|
@MappedCollection(idColumn = "LIST_PARENT") |
|
|
|
@MappedCollection(idColumn = "LIST_PARENT") private final List<ElementNoId> content = new ArrayList<>(); |
|
|
|
private final List<ElementNoId> content = new ArrayList<>(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@PersistenceConstructor |
|
|
|
@PersistenceConstructor |
|
|
|
ListParentAllArgs(Long id, String name, List<ElementNoId> content) { |
|
|
|
ListParentAllArgs(Long id, String name, List<ElementNoId> content) { |
|
|
|
@ -1287,6 +1296,20 @@ class JdbcAggregateTemplateIntegrationTests { |
|
|
|
abstract void setVersion(Number newVersion); |
|
|
|
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 |
|
|
|
@Value |
|
|
|
@With |
|
|
|
@With |
|
|
|
@Table("VERSIONED_AGGREGATE") |
|
|
|
@Table("VERSIONED_AGGREGATE") |
|
|
|
|