@@ -17,9 +17,6 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -141,8 +138,6 @@ class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingInt
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Wither
|
||||
static class VersionedEntity {
|
||||
|
||||
@Id final long id;
|
||||
@@ -161,5 +156,29 @@ class AsyncOptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingInt
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public VersionedEntity withId(long id) {
|
||||
return new VersionedEntity(id, this.version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withVersion(long version) {
|
||||
return new VersionedEntity(this.id, version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withName(String name) {
|
||||
return new VersionedEntity(this.id, this.version, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,6 @@ import static org.assertj.core.api.Assumptions.assumeThat;
|
||||
import static org.junit.Assume.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
@@ -67,6 +64,7 @@ import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingInte
|
||||
import org.springframework.data.domain.Slice;
|
||||
import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.util.Version;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
import com.datastax.oss.driver.api.core.uuid.Uuids;
|
||||
@@ -208,8 +206,8 @@ class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
TypeWithCompositeKey loadedEntity = loaded.get(0);
|
||||
|
||||
assertThat(loadedEntity.getKey()).isNotNull();
|
||||
assertThat(loadedEntity.getKey().getFirstname()).isNotNull();
|
||||
assertThat(loadedEntity.getKey().getLastname()).isNull();
|
||||
assertThat(loadedEntity.getKey().firstname()).isNotNull();
|
||||
assertThat(loadedEntity.getKey().lastname()).isNull();
|
||||
assertThat(loadedEntity.getComment()).isNotNull();
|
||||
}
|
||||
|
||||
@@ -799,37 +797,87 @@ class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
template.update(Query.query(where("id").is("id-1")), update, WithMappedUdtList.class);
|
||||
|
||||
WithMappedUdtList updated = template.selectOne(Query.query(where("id").is("id-1")), WithMappedUdtList.class);
|
||||
assertThat(updated.getMappedUdts()).extracting(MappedUdt::getName).containsExactly("one", "replacement", "three");
|
||||
assertThat(updated.getMappedUdts()).extracting(MappedUdt::name).containsExactly("one", "replacement", "three");
|
||||
}
|
||||
|
||||
@Data
|
||||
@UserDefinedType
|
||||
static class MappedUdt {
|
||||
|
||||
final String name;
|
||||
record MappedUdt(String name) {
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class WithMappedUdtList {
|
||||
|
||||
@Id String id;
|
||||
|
||||
List<MappedUdt> mappedUdts;
|
||||
|
||||
public WithMappedUdtList() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<MappedUdt> getMappedUdts() {
|
||||
return this.mappedUdts;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setMappedUdts(List<MappedUdt> mappedUdts) {
|
||||
this.mappedUdts = mappedUdts;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class TimeClass {
|
||||
|
||||
@Id LocalTime id;
|
||||
LocalTime bar;
|
||||
|
||||
public TimeClass() {}
|
||||
|
||||
public LocalTime getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public LocalTime getBar() {
|
||||
return this.bar;
|
||||
}
|
||||
|
||||
public void setId(LocalTime id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setBar(LocalTime bar) {
|
||||
this.bar = bar;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class TypeWithCompositeKey {
|
||||
@PrimaryKey CompositeKey key;
|
||||
String comment;
|
||||
|
||||
public TypeWithCompositeKey(CompositeKey key, String comment) {
|
||||
this.key = key;
|
||||
this.comment = comment;
|
||||
}
|
||||
|
||||
public CompositeKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getComment() {
|
||||
return this.comment;
|
||||
}
|
||||
|
||||
public void setKey(CompositeKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
|
||||
public void setComment(String comment) {
|
||||
this.comment = comment;
|
||||
}
|
||||
}
|
||||
|
||||
interface WithCompositeKeyProjection {
|
||||
@@ -837,78 +885,349 @@ class CassandraTemplateIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
CompositeKey getKey();
|
||||
}
|
||||
|
||||
@Data
|
||||
@PrimaryKeyClass
|
||||
@AllArgsConstructor
|
||||
static class CompositeKey {
|
||||
record CompositeKey(
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String firstname,
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String lastname) {
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String firstname;
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED) String lastname;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public WithNullableEmbeddedType() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
WithNullableEmbeddedType that = (WithNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(nested, that.nested);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(nested);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithPrefixedNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
@Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public WithPrefixedNullableEmbeddedType() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
WithPrefixedNullableEmbeddedType that = (WithPrefixedNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(nested, that.nested);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(nested);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithEmptyEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
@Embedded.Empty EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public WithEmptyEmbeddedType() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EmbeddedWithSimpleTypes {
|
||||
|
||||
String firstname;
|
||||
Integer age;
|
||||
|
||||
public EmbeddedWithSimpleTypes() {}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
EmbeddedWithSimpleTypes that = (EmbeddedWithSimpleTypes) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(age, that.age);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(age);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class OuterWithNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
UDTWithNullableEmbeddedType udtValue;
|
||||
|
||||
public OuterWithNullableEmbeddedType() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public UDTWithNullableEmbeddedType getUdtValue() {
|
||||
return this.udtValue;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUdtValue(UDTWithNullableEmbeddedType udtValue) {
|
||||
this.udtValue = udtValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
OuterWithNullableEmbeddedType that = (OuterWithNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(udtValue, that.udtValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(udtValue);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class OuterWithPrefixedNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
UDTWithPrefixedNullableEmbeddedType udtValue;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
OuterWithPrefixedNullableEmbeddedType that = (OuterWithPrefixedNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(udtValue, that.udtValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(udtValue);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
static class UDTWithNullableEmbeddedType {
|
||||
|
||||
String value;
|
||||
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public UDTWithNullableEmbeddedType() {}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
UDTWithNullableEmbeddedType that = (UDTWithNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(value, that.value)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(nested, that.nested);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(value);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(nested);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
static class UDTWithPrefixedNullableEmbeddedType {
|
||||
|
||||
String value;
|
||||
|
||||
@Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public UDTWithPrefixedNullableEmbeddedType() {}
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
UDTWithPrefixedNullableEmbeddedType that = (UDTWithPrefixedNullableEmbeddedType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(value, that.value)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(nested, that.nested);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(value);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(nested);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -87,15 +85,31 @@ class ExecutableDeleteOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
assertThat(this.template.select(Query.empty(), Person.class)).isEmpty();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -28,6 +26,7 @@ import org.springframework.data.cassandra.core.convert.MappingCassandraConverter
|
||||
import org.springframework.data.cassandra.core.mapping.Indexed;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
|
||||
@@ -102,11 +101,62 @@ class ExecutableInsertOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
assertThat(template.selectOneById(han.id, Person.class)).isEqualTo(han);
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
@Indexed String lastname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(lastname, person.lastname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -38,6 +34,7 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.data.cassandra.repository.support.SchemaTestUtils;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ExecutableSelectOperationSupport}.
|
||||
@@ -126,8 +123,7 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void findAllByWithCollectionUsingMappingInformation() {
|
||||
|
||||
assertThat(this.template.query(Jedi.class).inTable("person").all())
|
||||
.isNotEmpty().hasOnlyElementsOfType(Jedi.class);
|
||||
assertThat(this.template.query(Jedi.class).inTable("person").all()).isNotEmpty().hasOnlyElementsOfType(Jedi.class);
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -138,8 +134,7 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void findAllByWithProjection() {
|
||||
|
||||
assertThat(this.template.query(Person.class).as(Jedi.class).all())
|
||||
.hasOnlyElementsOfType(Jedi.class).isNotEmpty();
|
||||
assertThat(this.template.query(Person.class).as(Jedi.class).all()).hasOnlyElementsOfType(Jedi.class).isNotEmpty();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -182,11 +177,8 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void findByReturningFirstValueAsClosedInterfaceProjection() {
|
||||
|
||||
PersonProjection result = this.template
|
||||
.query(Person.class)
|
||||
.as(PersonProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.firstValue();
|
||||
PersonProjection result = this.template.query(Person.class).as(PersonProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering()).firstValue();
|
||||
|
||||
assertThat(result).isInstanceOf(PersonProjection.class);
|
||||
assertThat(result.getFirstname()).isEqualTo("han");
|
||||
@@ -195,11 +187,8 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void findByReturningFirstValueAsOpenInterfaceProjection() {
|
||||
|
||||
PersonSpELProjection result = this.template
|
||||
.query(Person.class)
|
||||
.as(PersonSpELProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.firstValue();
|
||||
PersonSpELProjection result = this.template.query(Person.class).as(PersonSpELProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering()).firstValue();
|
||||
|
||||
assertThat(result).isInstanceOf(PersonSpELProjection.class);
|
||||
assertThat(result.getName()).isEqualTo("han");
|
||||
@@ -232,8 +221,7 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void streamAllReturningResultsAsClosedInterfaceProjection() {
|
||||
|
||||
TerminatingSelect<PersonProjection> operation =
|
||||
this.template.query(Person.class).as(PersonProjection.class);
|
||||
TerminatingSelect<PersonProjection> operation = this.template.query(Person.class).as(PersonProjection.class);
|
||||
|
||||
assertThat(operation.stream()) //
|
||||
.hasSize(2) //
|
||||
@@ -246,8 +234,8 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
@Test // DATACASS-485
|
||||
void streamAllReturningResultsAsOpenInterfaceProjection() {
|
||||
|
||||
TerminatingSelect<PersonSpELProjection> operation =
|
||||
this.template.query(Person.class).as(PersonSpELProjection.class);
|
||||
TerminatingSelect<PersonSpELProjection> operation = this.template.query(Person.class)
|
||||
.as(PersonSpELProjection.class);
|
||||
|
||||
assertThat(operation.stream()) //
|
||||
.hasSize(2) //
|
||||
@@ -277,8 +265,8 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
@Test // DATACASS-485
|
||||
void countShouldReturnNrOfElementsMatchingQuery() {
|
||||
assertThat(this.template.query(Person.class).matching(query(where("firstname").is(luke.getFirstname()))
|
||||
.withAllowFiltering()).count()).isEqualTo(1);
|
||||
assertThat(this.template.query(Person.class)
|
||||
.matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering()).count()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -319,12 +307,63 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
|
||||
private interface Contact {}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person implements Contact {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
@Indexed String lastname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(lastname, person.lastname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private interface PersonProjection {
|
||||
@@ -332,18 +371,24 @@ class ExecutableSelectOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
}
|
||||
|
||||
public interface PersonSpELProjection {
|
||||
@Value("#{target.firstname}") String getName();
|
||||
@Value("#{target.firstname}")
|
||||
String getName();
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Human {
|
||||
@Id String id;
|
||||
|
||||
public Human() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,8 +20,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
import static org.springframework.data.cassandra.core.query.Update.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -33,6 +31,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
|
||||
@@ -118,15 +117,53 @@ class ExecutableUpdateOperationSupportIntegrationTests extends AbstractKeyspaceC
|
||||
return query(where("id").is(person.getId()));
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(firstname, person.firstname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,9 +17,6 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Wither;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.dao.OptimisticLockingFailureException;
|
||||
@@ -127,8 +124,6 @@ class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
assertThat(loaded).isNotNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Wither
|
||||
static class VersionedEntity {
|
||||
|
||||
@Id final long id;
|
||||
@@ -147,5 +142,29 @@ class OptimisticLockingIntegrationTests extends AbstractKeyspaceCreatingIntegrat
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public VersionedEntity withId(long id) {
|
||||
return new VersionedEntity(id, this.version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withVersion(long version) {
|
||||
return new VersionedEntity(this.id, version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withName(String name) {
|
||||
return new VersionedEntity(this.id, this.version, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package org.springframework.data.cassandra.core;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
|
||||
import lombok.Data;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -34,6 +33,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
|
||||
@@ -59,8 +59,7 @@ class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
|
||||
admin.dropTable(true, CqlIdentifier.fromCql("person"));
|
||||
admin.createTable(true, CqlIdentifier.fromCql("person"),
|
||||
ExecutableInsertOperationSupportIntegrationTests.Person.class,
|
||||
Collections.emptyMap());
|
||||
ExecutableInsertOperationSupportIntegrationTests.Person.class, Collections.emptyMap());
|
||||
|
||||
han = new Person();
|
||||
han.firstname = "han";
|
||||
@@ -77,10 +76,7 @@ class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
@Test // DATACASS-485
|
||||
void removeAllMatching() {
|
||||
|
||||
Mono<WriteResult> writeResult = this.template
|
||||
.delete(Person.class)
|
||||
.matching(query(where("id").is(han.id)))
|
||||
.all();
|
||||
Mono<WriteResult> writeResult = this.template.delete(Person.class).matching(query(where("id").is(han.id))).all();
|
||||
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
}
|
||||
@@ -88,24 +84,60 @@ class ReactiveDeleteOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
@Test // DATACASS-485
|
||||
void removeAllMatchingWithAlternateDomainTypeAndCollection() {
|
||||
|
||||
Mono<WriteResult> writeResult = this.template
|
||||
.delete(Jedi.class).inTable("person")
|
||||
.matching(query(where("id").in(han.id, luke.id)))
|
||||
.all();
|
||||
Mono<WriteResult> writeResult = this.template.delete(Jedi.class).inTable("person")
|
||||
.matching(query(where("id").in(han.id, luke.id))).all();
|
||||
|
||||
writeResult.map(WriteResult::wasApplied).as(StepVerifier::create).expectNext(true).verifyComplete();
|
||||
template.select(Query.empty(), Person.class).as(StepVerifier::create).verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(firstname, person.firstname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -31,6 +30,7 @@ import org.springframework.data.cassandra.core.cql.session.DefaultBridgedReactiv
|
||||
import org.springframework.data.cassandra.core.mapping.Indexed;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
|
||||
@@ -114,11 +114,62 @@ class ReactiveInsertOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
template.selectOneById(han.id, Person.class).as(StepVerifier::create).expectNext(han).verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
@Indexed String lastname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(lastname, person.lastname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.core;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Wither;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -149,8 +147,6 @@ class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceCreating
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Data
|
||||
@Wither
|
||||
static class VersionedEntity {
|
||||
|
||||
@Id final long id;
|
||||
@@ -169,5 +165,29 @@ class ReactiveOptimisticLockingIntegrationTests extends AbstractKeyspaceCreating
|
||||
this.version = version;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public long getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public VersionedEntity withId(long id) {
|
||||
return new VersionedEntity(id, this.version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withVersion(long version) {
|
||||
return new VersionedEntity(this.id, version, this.name);
|
||||
}
|
||||
|
||||
public VersionedEntity withName(String name) {
|
||||
return new VersionedEntity(this.id, this.version, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import reactor.core.publisher.Flux;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
@@ -39,6 +36,7 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.data.cassandra.repository.support.SchemaTestUtils;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Integration tests for {@link ExecutableSelectOperationSupport}.
|
||||
@@ -105,9 +103,7 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<Person> result = this.template.query(Person.class).all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).containsExactlyInAnyOrder(han, luke)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).containsExactlyInAnyOrder(han, luke)).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -124,9 +120,7 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<Jedi> result = this.template.query(Person.class).as(Jedi.class).all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).hasOnlyElementsOfType(Jedi.class).hasSize(2)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).hasOnlyElementsOfType(Jedi.class).hasSize(2)).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -135,9 +129,8 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<PersonProjection> result = this.template.query(Person.class).as(PersonProjection.class).all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).hasOnlyElementsOfType(PersonProjection.class).hasSize(2)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).hasOnlyElementsOfType(PersonProjection.class).hasSize(2))
|
||||
.verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -154,9 +147,7 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<Jedi> result = this.template.query(Jedi.class).inTable("person").all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -173,9 +164,7 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<Jedi> result = this.template.query(Person.class).as(Jedi.class).all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).isNotEmpty().hasOnlyElementsOfType(Jedi.class)).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
@@ -215,19 +204,14 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
|
||||
Mono<Person> result = this.template.query(Person.class).first();
|
||||
|
||||
result.as(StepVerifier::create).assertNext(actual ->
|
||||
assertThat(actual).isIn(han, luke)
|
||||
).verifyComplete();
|
||||
result.as(StepVerifier::create).assertNext(actual -> assertThat(actual).isIn(han, luke)).verifyComplete();
|
||||
}
|
||||
|
||||
@Test // DATACASS-485
|
||||
void findByReturningFirstAsClosedInterfaceProjection() {
|
||||
|
||||
Mono<PersonProjection> result = this.template
|
||||
.query(Person.class)
|
||||
.as(PersonProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.first();
|
||||
Mono<PersonProjection> result = this.template.query(Person.class).as(PersonProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering()).first();
|
||||
|
||||
result.as(StepVerifier::create).assertNext(actual -> {
|
||||
assertThat(actual).isInstanceOf(PersonProjection.class);
|
||||
@@ -238,11 +222,8 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
@Test // DATACASS-485
|
||||
void findByReturningFirstAsOpenInterfaceProjection() {
|
||||
|
||||
Mono<PersonSpELProjection> result = this.template
|
||||
.query(Person.class)
|
||||
.as(PersonSpELProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering())
|
||||
.first();
|
||||
Mono<PersonSpELProjection> result = this.template.query(Person.class).as(PersonSpELProjection.class)
|
||||
.matching(query(where("firstname").is("han")).withAllowFiltering()).first();
|
||||
|
||||
result.as(StepVerifier::create).assertNext(actual -> {
|
||||
assertThat(actual).isInstanceOf(PersonSpELProjection.class);
|
||||
@@ -261,10 +242,8 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
@Test // DATACASS-485
|
||||
void countShouldReturnNrOfElementsMatchingQuery() {
|
||||
|
||||
Mono<Long> count = this.template
|
||||
.query(Person.class)
|
||||
.matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering())
|
||||
.count();
|
||||
Mono<Long> count = this.template.query(Person.class)
|
||||
.matching(query(where("firstname").is(luke.getFirstname())).withAllowFiltering()).count();
|
||||
|
||||
count.as(StepVerifier::create).expectNext(1L).verifyComplete();
|
||||
}
|
||||
@@ -309,9 +288,7 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
Flux<Contact> result = this.template.query(Person.class).as(Contact.class).all();
|
||||
|
||||
result.collectList().as(StepVerifier::create)
|
||||
.assertNext(actual ->
|
||||
assertThat(actual).allMatch(it -> it instanceof Person)
|
||||
).verifyComplete();
|
||||
.assertNext(actual -> assertThat(actual).allMatch(it -> it instanceof Person)).verifyComplete();
|
||||
}
|
||||
|
||||
private static Query queryLuke() {
|
||||
@@ -324,12 +301,63 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
|
||||
private interface Contact {}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person implements Contact {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
@Indexed String lastname;
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(lastname, person.lastname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
private interface PersonProjection {
|
||||
@@ -341,21 +369,27 @@ class ReactiveSelectOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
String getName();
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Human {
|
||||
@Id String id;
|
||||
|
||||
public Human() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Sith {
|
||||
String rank;
|
||||
|
||||
}
|
||||
|
||||
interface PlanetProjection {
|
||||
|
||||
@@ -20,7 +20,6 @@ import static org.springframework.data.cassandra.core.query.Criteria.*;
|
||||
import static org.springframework.data.cassandra.core.query.Query.*;
|
||||
import static org.springframework.data.cassandra.core.query.Update.*;
|
||||
|
||||
import lombok.Data;
|
||||
import reactor.core.publisher.Mono;
|
||||
import reactor.test.StepVerifier;
|
||||
|
||||
@@ -36,6 +35,7 @@ import org.springframework.data.cassandra.core.mapping.Indexed;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.query.Query;
|
||||
import org.springframework.data.cassandra.test.util.AbstractKeyspaceCreatingIntegrationTests;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
|
||||
@@ -115,15 +115,51 @@ class ReactiveUpdateOperationSupportIntegrationTests extends AbstractKeyspaceCre
|
||||
return query(where("id").is(han.getId()));
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
@Id String id;
|
||||
@Indexed String firstname;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, person.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(firstname, person.firstname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Jedi {
|
||||
@Column("firstname") String name;
|
||||
record Jedi(@Column("firstname") String name) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
@@ -512,7 +508,7 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
|
||||
|
||||
TimeEntity loaded = operations.selectOneById(id, TimeEntity.class);
|
||||
|
||||
assertThat(loaded.getTime()).isEqualTo(time);
|
||||
assertThat(loaded.time()).isEqualTo(time);
|
||||
}
|
||||
|
||||
@Test // DATACASS-296
|
||||
@@ -640,20 +636,64 @@ public class CassandraTypeMappingIntegrationTests extends AbstractKeyspaceCreati
|
||||
MINT
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
static class WithDuration {
|
||||
|
||||
@Id String id;
|
||||
Duration duration;
|
||||
CqlDuration cqlDuration;
|
||||
|
||||
public WithDuration(String id, Duration duration, CqlDuration cqlDuration) {
|
||||
this.id = id;
|
||||
this.duration = duration;
|
||||
this.cqlDuration = cqlDuration;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Duration getDuration() {
|
||||
return this.duration;
|
||||
}
|
||||
|
||||
public CqlDuration getCqlDuration() {
|
||||
return this.cqlDuration;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setDuration(Duration duration) {
|
||||
this.duration = duration;
|
||||
}
|
||||
|
||||
public void setCqlDuration(CqlDuration cqlDuration) {
|
||||
this.cqlDuration = cqlDuration;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
static class ListOfTuples {
|
||||
|
||||
@Id String id;
|
||||
List<TupleValue> tuples;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public List<TupleValue> getTuples() {
|
||||
return this.tuples;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setTuples(List<TupleValue> tuples) {
|
||||
this.tuples = tuples;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
@@ -28,11 +23,31 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class CounterEntity {
|
||||
|
||||
@PrimaryKey @NonNull private String id;
|
||||
@PrimaryKey private String id;
|
||||
@CassandraType(type = CassandraType.Name.COUNTER) private long count;
|
||||
|
||||
public CounterEntity(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public CounterEntity() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public long getCount() {
|
||||
return this.count;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setCount(long count) {
|
||||
this.count = count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -210,7 +206,6 @@ class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIntegrati
|
||||
return converter;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Employee {
|
||||
|
||||
@@ -219,15 +214,71 @@ class CustomConversionIntegrationTests extends AbstractKeyspaceCreatingIntegrati
|
||||
Person person;
|
||||
List<Person> friends;
|
||||
Set<Person> people;
|
||||
|
||||
public Employee() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Person getPerson() {
|
||||
return this.person;
|
||||
}
|
||||
|
||||
public List<Person> getFriends() {
|
||||
return this.friends;
|
||||
}
|
||||
|
||||
public Set<Person> getPeople() {
|
||||
return this.people;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setPerson(Person person) {
|
||||
this.person = person;
|
||||
}
|
||||
|
||||
public void setFriends(List<Person> friends) {
|
||||
this.friends = friends;
|
||||
}
|
||||
|
||||
public void setPeople(Set<Person> people) {
|
||||
this.people = people;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Person {
|
||||
|
||||
String firstname;
|
||||
String lastname;
|
||||
|
||||
public Person(String firstname, String lastname) {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.test.util.RowMockUtil.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -80,12 +77,12 @@ class MappingCassandraConverterMappedTupleUnitTests {
|
||||
Person person = this.mappingCassandraConverter.read(Person.class, rowMock);
|
||||
|
||||
assertThat(person).isNotNull();
|
||||
assertThat(person.getName()).isEqualTo("Jon Doe");
|
||||
assertThat(person.name()).isEqualTo("Jon Doe");
|
||||
|
||||
MappedTuple tuple = person.getTuple();
|
||||
MappedTuple tuple = person.tuple();
|
||||
|
||||
assertThat(tuple.getName()).isEqualTo("hello");
|
||||
assertThat(tuple.getPosition()).isEqualTo(1);
|
||||
assertThat(tuple.name()).isEqualTo("hello");
|
||||
assertThat(tuple.position()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test // DATACASS-523
|
||||
@@ -102,18 +99,12 @@ class MappingCassandraConverterMappedTupleUnitTests {
|
||||
assertThat(tupleValue.getFormattedContents()).contains("('hello',1)");
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Person {
|
||||
String name;
|
||||
MappedTuple tuple;
|
||||
record Person(String name, MappedTuple tuple) {
|
||||
|
||||
}
|
||||
|
||||
@Tuple
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class MappedTuple {
|
||||
@Element(0) String name;
|
||||
@Element(1) int position;
|
||||
record MappedTuple(@Element(0) String name, @Element(1) int position) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Currency;
|
||||
@@ -149,9 +147,7 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
|
||||
|
||||
person.setId("foo");
|
||||
|
||||
AddressUserType userType = new AddressUserType();
|
||||
|
||||
userType.setZip("myzip");
|
||||
AddressUserType userType = new AddressUserType("myzip");
|
||||
|
||||
MappedTuple tuple = new MappedTuple();
|
||||
|
||||
@@ -251,7 +247,6 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
|
||||
assertThat(mappedTuple.myName).isEqualTo("bar");
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
static class Person {
|
||||
|
||||
@@ -263,15 +258,94 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
|
||||
List<MappedTuple> mappedTuples;
|
||||
Map<String, MappedTuple> mapOfTuples;
|
||||
Map<String, TupleValue> mapOfTupleValues;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public TupleValue getTupleValue() {
|
||||
return this.tupleValue;
|
||||
}
|
||||
|
||||
public MappedTuple getMappedTuple() {
|
||||
return this.mappedTuple;
|
||||
}
|
||||
|
||||
public MappedTupleWithValue getMappedTupleWithValue() {
|
||||
return this.mappedTupleWithValue;
|
||||
}
|
||||
|
||||
public List<MappedTuple> getMappedTuples() {
|
||||
return this.mappedTuples;
|
||||
}
|
||||
|
||||
public Map<String, MappedTuple> getMapOfTuples() {
|
||||
return this.mapOfTuples;
|
||||
}
|
||||
|
||||
public Map<String, TupleValue> getMapOfTupleValues() {
|
||||
return this.mapOfTupleValues;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setTupleValue(TupleValue tupleValue) {
|
||||
this.tupleValue = tupleValue;
|
||||
}
|
||||
|
||||
public void setMappedTuple(MappedTuple mappedTuple) {
|
||||
this.mappedTuple = mappedTuple;
|
||||
}
|
||||
|
||||
public void setMappedTupleWithValue(MappedTupleWithValue mappedTupleWithValue) {
|
||||
this.mappedTupleWithValue = mappedTupleWithValue;
|
||||
}
|
||||
|
||||
public void setMappedTuples(List<MappedTuple> mappedTuples) {
|
||||
this.mappedTuples = mappedTuples;
|
||||
}
|
||||
|
||||
public void setMapOfTuples(Map<String, MappedTuple> mapOfTuples) {
|
||||
this.mapOfTuples = mapOfTuples;
|
||||
}
|
||||
|
||||
public void setMapOfTupleValues(Map<String, TupleValue> mapOfTupleValues) {
|
||||
this.mapOfTupleValues = mapOfTupleValues;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Tuple
|
||||
static class MappedTuple {
|
||||
|
||||
@Element(0) AddressUserType addressUserType;
|
||||
@Element(1) List<Currency> currency;
|
||||
@Element(2) String name;
|
||||
|
||||
public AddressUserType getAddressUserType() {
|
||||
return addressUserType;
|
||||
}
|
||||
|
||||
public void setAddressUserType(AddressUserType addressUserType) {
|
||||
this.addressUserType = addressUserType;
|
||||
}
|
||||
|
||||
public List<Currency> getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
public void setCurrency(List<Currency> currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Tuple
|
||||
@@ -290,9 +364,20 @@ public class MappingCassandraConverterTupleIntegrationTests extends AbstractSpri
|
||||
}
|
||||
|
||||
@UserDefinedType("address")
|
||||
@Data
|
||||
static class AddressUserType {
|
||||
String zip;
|
||||
|
||||
public AddressUserType(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public String getZip() {
|
||||
return zip;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
}
|
||||
|
||||
private static class StringToCurrencyConverter implements Converter<String, Currency> {
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Currency;
|
||||
import java.util.List;
|
||||
@@ -42,6 +38,7 @@ import org.springframework.data.cassandra.domain.AllPossibleTypes;
|
||||
import org.springframework.data.cassandra.repository.support.AbstractSpringDataEmbeddedCassandraIntegrationTest;
|
||||
import org.springframework.data.cassandra.repository.support.IntegrationTestConfig;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
import com.datastax.oss.driver.api.core.CqlSession;
|
||||
@@ -221,64 +218,163 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
|
||||
}
|
||||
|
||||
@Table
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Bank {
|
||||
|
||||
@Id String id;
|
||||
Currency currency;
|
||||
List<Currency> otherCurrencies;
|
||||
|
||||
public Bank(String id, Currency currency, List<Currency> otherCurrencies) {
|
||||
this.id = id;
|
||||
this.currency = currency;
|
||||
this.otherCurrencies = otherCurrencies;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public List<Currency> getOtherCurrencies() {
|
||||
return this.otherCurrencies;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class Money {
|
||||
@Id private Currency currency;
|
||||
|
||||
public Money() {}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public void setCurrency(Currency currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Table
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public static class MoneyTransfer {
|
||||
|
||||
@Id String id;
|
||||
|
||||
private Currency currency;
|
||||
|
||||
public MoneyTransfer(String id, Currency currency) {
|
||||
this.id = id;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Car {
|
||||
|
||||
@Id String id;
|
||||
Engine engine;
|
||||
|
||||
public Car(String id, Engine engine) {
|
||||
this.id = id;
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Engine getEngine() {
|
||||
return this.engine;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Engine {
|
||||
Manufacturer manufacturer;
|
||||
|
||||
public Engine(Manufacturer manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
public Manufacturer getManufacturer() {
|
||||
return this.manufacturer;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Manufacturer {
|
||||
String name;
|
||||
|
||||
public Manufacturer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Manufacturer that = (Manufacturer) o;
|
||||
|
||||
return ObjectUtils.nullSafeEquals(name, that.name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(name);
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Supplier {
|
||||
|
||||
@Id String id;
|
||||
Map<Manufacturer, List<Currency>> acceptedCurrencies;
|
||||
|
||||
public Supplier(String id, Map<Manufacturer, List<Currency>> acceptedCurrencies) {
|
||||
this.id = id;
|
||||
this.acceptedCurrencies = acceptedCurrencies;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Map<Manufacturer, List<Currency>> getAcceptedCurrencies() {
|
||||
return this.acceptedCurrencies;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAcceptedCurrencies(Map<Manufacturer, List<Currency>> acceptedCurrencies) {
|
||||
this.acceptedCurrencies = acceptedCurrencies;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class AddressBook {
|
||||
|
||||
@@ -287,28 +383,99 @@ public class MappingCassandraConverterUDTIntegrationTests extends AbstractSpring
|
||||
private AddressUserType currentaddress;
|
||||
private List<AddressUserType> previousaddresses;
|
||||
private UdtValue alternate;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public AddressUserType getCurrentaddress() {
|
||||
return this.currentaddress;
|
||||
}
|
||||
|
||||
public List<AddressUserType> getPreviousaddresses() {
|
||||
return this.previousaddresses;
|
||||
}
|
||||
|
||||
public UdtValue getAlternate() {
|
||||
return this.alternate;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setCurrentaddress(AddressUserType currentaddress) {
|
||||
this.currentaddress = currentaddress;
|
||||
}
|
||||
|
||||
public void setPreviousaddresses(List<AddressUserType> previousaddresses) {
|
||||
this.previousaddresses = previousaddresses;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithUdtId {
|
||||
@Id private UdtValue id;
|
||||
|
||||
public WithUdtId() {}
|
||||
|
||||
public UdtValue getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(UdtValue id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithMappedUdtId {
|
||||
@Id private AddressUserType id;
|
||||
|
||||
public AddressUserType getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AddressUserType id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@UserDefinedType("address")
|
||||
@Data
|
||||
public static class AddressUserType {
|
||||
|
||||
String zip;
|
||||
String city;
|
||||
|
||||
List<String> streetLines;
|
||||
|
||||
public String getZip() {
|
||||
return this.zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public List<String> getStreetLines() {
|
||||
return this.streetLines;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public void setStreetLines(List<String> streetLines) {
|
||||
this.streetLines = streetLines;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static class UDTToCurrencyConverter implements Converter<UdtValue, Currency> {
|
||||
|
||||
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.cassandra.test.util.RowMockUtil.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
@@ -47,6 +43,7 @@ import org.springframework.data.cassandra.core.cql.util.StatementBuilder;
|
||||
import org.springframework.data.cassandra.core.mapping.*;
|
||||
import org.springframework.data.cassandra.support.UserDefinedTypeBuilder;
|
||||
import org.springframework.data.cassandra.test.util.RowMockUtil;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
import com.datastax.oss.driver.api.core.cql.Row;
|
||||
@@ -67,8 +64,7 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
@Mock UserTypeResolver userTypeResolver;
|
||||
|
||||
private com.datastax.oss.driver.api.core.type.UserDefinedType manufacturer = UserDefinedTypeBuilder
|
||||
.forName("manufacturer")
|
||||
.withField("name", DataTypes.TEXT).withField("displayname", DataTypes.TEXT).build();
|
||||
.forName("manufacturer").withField("name", DataTypes.TEXT).withField("displayname", DataTypes.TEXT).build();
|
||||
|
||||
private com.datastax.oss.driver.api.core.type.UserDefinedType engine = UserDefinedTypeBuilder.forName("engine")
|
||||
.withField("manufacturer", manufacturer).build();
|
||||
@@ -323,6 +319,7 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
|
||||
assertThat(statement.getQuery()).isEqualTo("INSERT INTO bank (othercurrencies) VALUES ([{currency:'EUR'}])");
|
||||
}
|
||||
|
||||
@Test // DATACASS-487, DATACASS-623
|
||||
void shouldReadMappedUdtInMap() {
|
||||
|
||||
@@ -454,8 +451,7 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
rowMock = RowMockUtil.newRowMock(column("id", "id-1", DataTypes.TEXT),
|
||||
column("udtvalue", udtValue, withprefixednullableembeddedtype));
|
||||
|
||||
OuterWithPrefixedNullableEmbeddedType target = converter
|
||||
.read(OuterWithPrefixedNullableEmbeddedType.class, rowMock);
|
||||
OuterWithPrefixedNullableEmbeddedType target = converter.read(OuterWithPrefixedNullableEmbeddedType.class, rowMock);
|
||||
assertThat(target.getId()).isEqualTo("id-1");
|
||||
assertThat(target.udtValue).isNotNull();
|
||||
assertThat(target.udtValue.value).isEqualTo("value-string");
|
||||
@@ -493,85 +489,254 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
}
|
||||
|
||||
@Table
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Car {
|
||||
|
||||
@Id String id;
|
||||
Engine engine;
|
||||
|
||||
public Car(String id, Engine engine) {
|
||||
this.id = id;
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Engine getEngine() {
|
||||
return this.engine;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Engine {
|
||||
Manufacturer manufacturer;
|
||||
|
||||
public Engine(Manufacturer manufacturer) {
|
||||
this.manufacturer = manufacturer;
|
||||
}
|
||||
|
||||
public Manufacturer getManufacturer() {
|
||||
return this.manufacturer;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Manufacturer {
|
||||
String name;
|
||||
@ReadOnlyProperty String displayName;
|
||||
|
||||
public Manufacturer(String name, String displayName) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setDisplayName(String displayName) {
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Manufacturer that = (Manufacturer) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(name, that.name)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(displayName, that.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(name);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(displayName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Currency {
|
||||
String currency;
|
||||
|
||||
public Currency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public void setCurrency(String currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Currency currency1 = (Currency) o;
|
||||
|
||||
return ObjectUtils.nullSafeEquals(currency, currency1.currency);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(currency);
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
private static class Supplier {
|
||||
Map<Manufacturer, List<Currency>> acceptedCurrencies;
|
||||
|
||||
public Supplier(Map<Manufacturer, List<Currency>> acceptedCurrencies) {
|
||||
this.acceptedCurrencies = acceptedCurrencies;
|
||||
}
|
||||
|
||||
public Map<Manufacturer, List<Currency>> getAcceptedCurrencies() {
|
||||
return this.acceptedCurrencies;
|
||||
}
|
||||
|
||||
public void setAcceptedCurrencies(Map<Manufacturer, List<Currency>> acceptedCurrencies) {
|
||||
this.acceptedCurrencies = acceptedCurrencies;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class OuterWithNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
WithNullableEmbeddedType udtValue;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public WithNullableEmbeddedType getUdtValue() {
|
||||
return this.udtValue;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUdtValue(WithNullableEmbeddedType udtValue) {
|
||||
this.udtValue = udtValue;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class OuterWithPrefixedNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
WithPrefixedNullableEmbeddedType udtValue;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public WithPrefixedNullableEmbeddedType getUdtValue() {
|
||||
return this.udtValue;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setUdtValue(WithPrefixedNullableEmbeddedType udtValue) {
|
||||
this.udtValue = udtValue;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
static class WithNullableEmbeddedType {
|
||||
|
||||
String value;
|
||||
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
static class WithPrefixedNullableEmbeddedType {
|
||||
|
||||
String value;
|
||||
|
||||
@Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Data
|
||||
static class WithEmptyEmbeddedType {
|
||||
|
||||
String value;
|
||||
|
||||
@Embedded.Empty EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public String getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EmbeddedWithSimpleTypes {
|
||||
|
||||
String firstname;
|
||||
@@ -584,9 +749,16 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
public Integer getAge() {
|
||||
return age;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class AddressBook {
|
||||
|
||||
@@ -595,75 +767,223 @@ class MappingCassandraConverterUDTUnitTests {
|
||||
private AddressUserType currentaddress;
|
||||
private List<AddressUserType> previousaddresses;
|
||||
private UdtValue alternate;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public AddressUserType getCurrentaddress() {
|
||||
return this.currentaddress;
|
||||
}
|
||||
|
||||
public List<AddressUserType> getPreviousaddresses() {
|
||||
return this.previousaddresses;
|
||||
}
|
||||
|
||||
public UdtValue getAlternate() {
|
||||
return this.alternate;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setCurrentaddress(AddressUserType currentaddress) {
|
||||
this.currentaddress = currentaddress;
|
||||
}
|
||||
|
||||
public void setPreviousaddresses(List<AddressUserType> previousaddresses) {
|
||||
this.previousaddresses = previousaddresses;
|
||||
}
|
||||
|
||||
public void setAlternate(UdtValue alternate) {
|
||||
this.alternate = alternate;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithUdtId {
|
||||
@Id private UdtValue id;
|
||||
|
||||
public UdtValue getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(UdtValue id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithMappedUdtId {
|
||||
@Id private AddressUserType id;
|
||||
|
||||
public AddressUserType getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(AddressUserType id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType("address")
|
||||
@Data
|
||||
public static class AddressUserType {
|
||||
|
||||
String zip;
|
||||
String city;
|
||||
|
||||
List<String> streetLines;
|
||||
|
||||
public String getZip() {
|
||||
return this.zip;
|
||||
}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public List<String> getStreetLines() {
|
||||
return this.streetLines;
|
||||
}
|
||||
|
||||
public void setZip(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public void setStreetLines(List<String> streetLines) {
|
||||
this.streetLines = streetLines;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Bank {
|
||||
|
||||
@Id String id;
|
||||
Currency currency;
|
||||
List<Currency> otherCurrencies;
|
||||
|
||||
public Bank(String id, Currency currency, List<Currency> otherCurrencies) {
|
||||
this.id = id;
|
||||
this.currency = currency;
|
||||
this.otherCurrencies = otherCurrencies;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public List<Currency> getOtherCurrencies() {
|
||||
return this.otherCurrencies;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class Money {
|
||||
@Id private Currency currency;
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public void setCurrency(Currency currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithCompositePrimaryKey {
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String id;
|
||||
@PrimaryKeyColumn(ordinal = 1) AddressUserType addressUserType;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public AddressUserType getAddressUserType() {
|
||||
return this.addressUserType;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAddressUserType(AddressUserType addressUserType) {
|
||||
this.addressUserType = addressUserType;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
public static class WithCompositePrimaryKeyClassWithUdt {
|
||||
@PrimaryKey CompositePrimaryKeyClassWithUdt id;
|
||||
|
||||
public CompositePrimaryKeyClassWithUdt getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public void setId(CompositePrimaryKeyClassWithUdt id) {
|
||||
this.id = id;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@PrimaryKeyClass
|
||||
public static class CompositePrimaryKeyClassWithUdt {
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String id;
|
||||
@PrimaryKeyColumn(ordinal = 1) AddressUserType addressUserType;
|
||||
@PrimaryKeyColumn(ordinal = 2) Currency currency;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public AddressUserType getAddressUserType() {
|
||||
return this.addressUserType;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAddressUserType(AddressUserType addressUserType) {
|
||||
this.addressUserType = addressUserType;
|
||||
}
|
||||
|
||||
public void setCurrency(Currency currency) {
|
||||
this.currency = currency;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public static class MoneyTransfer {
|
||||
|
||||
@Id String id;
|
||||
|
||||
private Currency currency;
|
||||
|
||||
public MoneyTransfer(String id, Currency currency) {
|
||||
this.id = id;
|
||||
this.currency = currency;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Currency getCurrency() {
|
||||
return this.currency;
|
||||
}
|
||||
}
|
||||
|
||||
private static class UDTToCurrencyConverter implements Converter<UdtValue, Currency> {
|
||||
|
||||
@@ -19,13 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.cassandra.core.mapping.BasicMapId.*;
|
||||
import static org.springframework.data.cassandra.test.util.RowMockUtil.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
@@ -36,18 +29,7 @@ import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
@@ -60,19 +42,8 @@ import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.ReadOnlyProperty;
|
||||
import org.springframework.data.annotation.Transient;
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.BasicMapId;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraMappingContext;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraType;
|
||||
import org.springframework.data.cassandra.core.mapping.*;
|
||||
import org.springframework.data.cassandra.core.mapping.Column;
|
||||
import org.springframework.data.cassandra.core.mapping.Element;
|
||||
import org.springframework.data.cassandra.core.mapping.Embedded;
|
||||
import org.springframework.data.cassandra.core.mapping.MapId;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.data.cassandra.core.mapping.Tuple;
|
||||
import org.springframework.data.cassandra.core.mapping.UserDefinedType;
|
||||
import org.springframework.data.cassandra.domain.AllPossibleTypes;
|
||||
import org.springframework.data.cassandra.domain.CompositeKey;
|
||||
import org.springframework.data.cassandra.domain.TypeWithCompositeKey;
|
||||
@@ -85,6 +56,7 @@ import org.springframework.data.cassandra.test.util.RowMockUtil;
|
||||
import org.springframework.data.projection.EntityProjection;
|
||||
import org.springframework.data.projection.EntityProjectionIntrospector;
|
||||
import org.springframework.data.projection.SpelAwareProxyProjectionFactory;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
import com.datastax.oss.driver.api.core.cql.Row;
|
||||
@@ -981,8 +953,8 @@ public class MappingCassandraConverterUnitTests {
|
||||
|
||||
WithMappedTupleDtoProjection result = this.mappingCassandraConverter.project(projection, rowMock);
|
||||
|
||||
assertThat(result.getFirstname()).isEqualTo("Heisenberg");
|
||||
assertThat(result.getTuple().getOne()).isEqualTo("One");
|
||||
assertThat(result.firstname()).isEqualTo("Heisenberg");
|
||||
assertThat(result.tuple().getOne()).isEqualTo("One");
|
||||
}
|
||||
|
||||
@Test // GH-1202
|
||||
@@ -1007,9 +979,9 @@ public class MappingCassandraConverterUnitTests {
|
||||
|
||||
TupleAndNameProjection result = this.mappingCassandraConverter.project(projection, rowMock);
|
||||
|
||||
assertThat(result.getName().getFirstname()).isEqualTo("Heisenberg");
|
||||
assertThat(result.getTuple().zero).isEqualTo("Zero");
|
||||
assertThat(result.getTuple().one).isEqualTo("One");
|
||||
assertThat(result.name().firstname()).isEqualTo("Heisenberg");
|
||||
assertThat(result.tuple().zero).isEqualTo("Zero");
|
||||
assertThat(result.tuple().one).isEqualTo("One");
|
||||
}
|
||||
|
||||
private static List<Object> getValues(Map<CqlIdentifier, Object> statement) {
|
||||
@@ -1089,19 +1061,16 @@ public class MappingCassandraConverterUnitTests {
|
||||
}
|
||||
|
||||
@PrimaryKeyClass
|
||||
@RequiredArgsConstructor
|
||||
@lombok.Value
|
||||
public static class EnumAndDateCompositePrimaryKey implements Serializable {
|
||||
record EnumAndDateCompositePrimaryKey(
|
||||
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) Condition condition,
|
||||
@PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED) java.time.LocalDate localDate)
|
||||
implements
|
||||
Serializable {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private final Condition condition;
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 2, type = PrimaryKeyType.PARTITIONED) private final java.time.LocalDate localDate;
|
||||
}
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public static class TypeWithEnumAndLocalDateKey {
|
||||
record TypeWithEnumAndLocalDateKey(@PrimaryKey EnumAndDateCompositePrimaryKey id) {
|
||||
|
||||
@PrimaryKey private final EnumAndDateCompositePrimaryKey id;
|
||||
}
|
||||
|
||||
@Table
|
||||
@@ -1150,10 +1119,13 @@ public class MappingCassandraConverterUnitTests {
|
||||
}
|
||||
|
||||
@Table
|
||||
@RequiredArgsConstructor
|
||||
public static class TableWithCompositeKeyViaConstructor {
|
||||
|
||||
@PrimaryKey private final CompositeKeyWithPropertyAccessors key;
|
||||
|
||||
public TableWithCompositeKeyViaConstructor(CompositeKeyWithPropertyAccessors key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@@ -1169,15 +1141,19 @@ public class MappingCassandraConverterUnitTests {
|
||||
}
|
||||
|
||||
/**
|
||||
* Uses Cassandra's {@link Name#DATE} which maps by default to {@link LocalDate}
|
||||
* Uses Cassandra's {@link CassandraType.Name#DATE} which maps by default to {@link LocalDate}
|
||||
*/
|
||||
@Table
|
||||
@AllArgsConstructor
|
||||
public static class TypeWithLocalDateMappedToDate {
|
||||
|
||||
@PrimaryKey private String id;
|
||||
|
||||
@CassandraType(type = CassandraType.Name.DATE) java.time.LocalDate localDate;
|
||||
|
||||
public TypeWithLocalDateMappedToDate(String id, LocalDate localDate) {
|
||||
this.id = id;
|
||||
this.localDate = localDate;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
@@ -1256,27 +1232,18 @@ public class MappingCassandraConverterUnitTests {
|
||||
TupleWithElementAnnotationInConstructor tuple;
|
||||
}
|
||||
|
||||
@lombok.Value
|
||||
private static class Name {
|
||||
String firstname;
|
||||
private record Name(String firstname) {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
private static class WithMappedTupleDtoProjection {
|
||||
|
||||
String firstname;
|
||||
TupleProjection tuple;
|
||||
record WithMappedTupleDtoProjection(String firstname, TupleProjection tuple) {
|
||||
}
|
||||
|
||||
@lombok.Value
|
||||
private static class TupleAndNameProjection {
|
||||
private record TupleAndNameProjection(@Embedded.Nullable Name name, TupleWithElementAnnotationInConstructor tuple) {
|
||||
|
||||
@Embedded.Nullable Name name;
|
||||
|
||||
TupleWithElementAnnotationInConstructor tuple;
|
||||
}
|
||||
|
||||
private static interface TupleProjection {
|
||||
private interface TupleProjection {
|
||||
|
||||
String getZero();
|
||||
|
||||
@@ -1297,39 +1264,96 @@ public class MappingCassandraConverterUnitTests {
|
||||
}
|
||||
}
|
||||
|
||||
@ToString
|
||||
static class WithNullableEmbeddedType {
|
||||
|
||||
String id;
|
||||
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [id='").append(id).append('\'');
|
||||
sb.append(", nested=").append(nested);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ToString
|
||||
static class WithPrefixedNullableEmbeddedType {
|
||||
|
||||
String id;
|
||||
|
||||
@Embedded.Nullable("prefix") EmbeddedWithSimpleTypes nested;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [id='").append(id).append('\'');
|
||||
sb.append(", nested=").append(nested);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ToString
|
||||
static class WithEmptyEmbeddedType {
|
||||
|
||||
String id;
|
||||
|
||||
@Embedded.Empty EmbeddedWithSimpleTypes nested;
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [id='").append(id).append('\'');
|
||||
sb.append(", nested=").append(nested);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
static class EmbeddedWithSimpleTypes {
|
||||
|
||||
String firstname;
|
||||
Integer age;
|
||||
@Transient String displayName;
|
||||
|
||||
public EmbeddedWithSimpleTypes() {}
|
||||
|
||||
public EmbeddedWithSimpleTypes(String firstname, Integer age, String displayName) {
|
||||
this.firstname = firstname;
|
||||
this.age = age;
|
||||
this.displayName = displayName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
EmbeddedWithSimpleTypes that = (EmbeddedWithSimpleTypes) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(age, that.age)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(displayName, that.displayName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(age);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(displayName);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Test // DATACASS-167
|
||||
@@ -1500,7 +1524,6 @@ public class MappingCassandraConverterUnitTests {
|
||||
String getName();
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Book {
|
||||
|
||||
@Id String id;
|
||||
@@ -1509,9 +1532,31 @@ public class MappingCassandraConverterUnitTests {
|
||||
|
||||
Author author = new Author();
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public Author getAuthor() {
|
||||
return author;
|
||||
}
|
||||
|
||||
public void setAuthor(Author author) {
|
||||
this.author = author;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@UserDefinedType
|
||||
static class Author {
|
||||
|
||||
@@ -1521,5 +1566,28 @@ public class MappingCassandraConverterUnitTests {
|
||||
|
||||
String lastName;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstName() {
|
||||
return firstName;
|
||||
}
|
||||
|
||||
public void setFirstName(String firstName) {
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,9 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.domain.Sort.Order.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalTime;
|
||||
import java.util.Collection;
|
||||
@@ -82,18 +79,16 @@ public class QueryMapperUnitTests {
|
||||
|
||||
private QueryMapper queryMapper;
|
||||
|
||||
private final com.datastax.oss.driver.api.core.type.UserDefinedType userType =
|
||||
UserDefinedTypeBuilder.forName("address")
|
||||
.withField("street", DataTypes.TEXT)
|
||||
.build();
|
||||
private final com.datastax.oss.driver.api.core.type.UserDefinedType userType = UserDefinedTypeBuilder
|
||||
.forName("address").withField("street", DataTypes.TEXT).build();
|
||||
|
||||
@Mock UserTypeResolver userTypeResolver;
|
||||
|
||||
@BeforeEach
|
||||
void before() {
|
||||
|
||||
CassandraCustomConversions customConversions =
|
||||
new CassandraCustomConversions(Collections.singletonList(CurrencyConverter.INSTANCE));
|
||||
CassandraCustomConversions customConversions = new CassandraCustomConversions(
|
||||
Collections.singletonList(CurrencyConverter.INSTANCE));
|
||||
|
||||
when(userTypeResolver.resolveType(any(CqlIdentifier.class))).thenReturn(userType);
|
||||
|
||||
@@ -291,8 +286,8 @@ public class QueryMapperUnitTests {
|
||||
void shouldCreateSelectExpressionWithTTL() {
|
||||
|
||||
List<String> selectors = queryMapper
|
||||
.getMappedSelectors(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity)
|
||||
.stream().map(Selector::toString).collect(Collectors.toList());
|
||||
.getMappedSelectors(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity).stream()
|
||||
.map(Selector::toString).collect(Collectors.toList());
|
||||
|
||||
assertThat(selectors).contains("number").contains("foo").contains("TTL(first_name)");
|
||||
}
|
||||
@@ -300,8 +295,8 @@ public class QueryMapperUnitTests {
|
||||
@Test // DATACASS-343
|
||||
void shouldIncludeColumnsSelectExpressionWithTTL() {
|
||||
|
||||
List<CqlIdentifier> selectors =
|
||||
queryMapper.getMappedColumnNames(Columns.from("number", "foo").ttl("firstName"), personPersistentEntity);
|
||||
List<CqlIdentifier> selectors = queryMapper.getMappedColumnNames(Columns.from("number", "foo").ttl("firstName"),
|
||||
personPersistentEntity);
|
||||
|
||||
assertThat(selectors).contains(CqlIdentifier.fromCql("number"), CqlIdentifier.fromCql("foo")).hasSize(2);
|
||||
}
|
||||
@@ -377,16 +372,15 @@ public class QueryMapperUnitTests {
|
||||
|
||||
Filter filter = Filter.from(Criteria.where("localTime").gt(time));
|
||||
|
||||
Filter mappedFilter = this.queryMapper. getMappedObject(filter, this.personPersistentEntity);
|
||||
Filter mappedFilter = this.queryMapper.getMappedObject(filter, this.personPersistentEntity);
|
||||
|
||||
assertThat(mappedFilter).contains(Criteria.where("localtime").gt(time));
|
||||
}
|
||||
|
||||
@Test // DATACASS-523
|
||||
void referencingTupleElementsInQueryShouldFail() {
|
||||
assertThatIllegalArgumentException()
|
||||
.isThrownBy(() -> this.queryMapper.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")),
|
||||
this.personPersistentEntity));
|
||||
assertThatIllegalArgumentException().isThrownBy(() -> this.queryMapper
|
||||
.getMappedObject(Filter.from(Criteria.where("tuple.zip").is("123")), this.personPersistentEntity));
|
||||
}
|
||||
|
||||
@Test // DATACASS-167
|
||||
@@ -456,26 +450,21 @@ public class QueryMapperUnitTests {
|
||||
@PrimaryKeyColumn long foo;
|
||||
|
||||
@PrimaryKeyColumn long bar;
|
||||
|
||||
}
|
||||
|
||||
@Tuple
|
||||
@AllArgsConstructor
|
||||
static class MappedTuple {
|
||||
@Element(0) String zip;
|
||||
record MappedTuple(@Element(0) String zip) {
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@AllArgsConstructor
|
||||
static class Address {
|
||||
String street;
|
||||
record Address(String street) {
|
||||
|
||||
}
|
||||
|
||||
enum State {
|
||||
Active, Inactive
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
@@ -483,7 +472,6 @@ public class QueryMapperUnitTests {
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithPrefixedNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
@@ -491,10 +479,25 @@ public class QueryMapperUnitTests {
|
||||
@Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EmbeddedWithSimpleTypes {
|
||||
|
||||
String firstname;
|
||||
Integer age;
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,10 +20,6 @@ import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
import static org.springframework.data.cassandra.core.mapping.CassandraType.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
@@ -143,7 +139,8 @@ public class SchemaFactoryUnitTests {
|
||||
|
||||
this.mappingContext.setUserTypeResolver(typeName -> mappedudt);
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = this.mappingContext.getRequiredPersistentEntity(WithMapOfMixedTypes.class);
|
||||
CassandraPersistentEntity<?> persistentEntity = this.mappingContext
|
||||
.getRequiredPersistentEntity(WithMapOfMixedTypes.class);
|
||||
|
||||
CreateTableSpecification tableSpecification = schemaFactory.getCreateTableSpecificationFor(persistentEntity);
|
||||
|
||||
@@ -286,7 +283,8 @@ public class SchemaFactoryUnitTests {
|
||||
|
||||
private static class IndexedType {
|
||||
|
||||
@PrimaryKeyColumn("first_name") @Indexed("my_index") String firstname;
|
||||
@PrimaryKeyColumn("first_name")
|
||||
@Indexed("my_index") String firstname;
|
||||
|
||||
@Indexed List<String> phoneNumbers;
|
||||
}
|
||||
@@ -295,7 +293,8 @@ public class SchemaFactoryUnitTests {
|
||||
static class CompositeKeyWithIndex {
|
||||
|
||||
@PrimaryKeyColumn(value = "first_name", type = PrimaryKeyType.PARTITIONED) String firstname;
|
||||
@PrimaryKeyColumn("last_name") @Indexed("my_index") String lastname;
|
||||
@PrimaryKeyColumn("last_name")
|
||||
@Indexed("my_index") String lastname;
|
||||
}
|
||||
|
||||
private static class CompositeKeyEntity {
|
||||
@@ -311,18 +310,20 @@ public class SchemaFactoryUnitTests {
|
||||
@Test // DATACASS-506
|
||||
void shouldCreatedUserTypeSpecificationsWithAnnotatedTypeName() {
|
||||
|
||||
assertThat(schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(WithUdt.class)))
|
||||
.isNotNull();
|
||||
assertThat(schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(Nested.class)))
|
||||
.isNotNull();
|
||||
assertThat(
|
||||
schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(WithUdt.class)))
|
||||
.isNotNull();
|
||||
assertThat(
|
||||
schemaFactory.getCreateUserTypeSpecificationFor(mappingContext.getRequiredPersistentEntity(Nested.class)))
|
||||
.isNotNull();
|
||||
}
|
||||
|
||||
@Test // DATACASS-172
|
||||
void createTableForComplexPrimaryKeyShouldFail() {
|
||||
|
||||
try {
|
||||
schemaFactory
|
||||
.getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexPrimaryKeyColumn.class));
|
||||
schemaFactory.getCreateTableSpecificationFor(
|
||||
mappingContext.getRequiredPersistentEntity(EntityWithComplexPrimaryKeyColumn.class));
|
||||
fail("Missing MappingException");
|
||||
} catch (MappingException e) {
|
||||
assertThat(e).hasMessageContaining(
|
||||
@@ -330,7 +331,8 @@ public class SchemaFactoryUnitTests {
|
||||
}
|
||||
|
||||
try {
|
||||
schemaFactory.getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexId.class));
|
||||
schemaFactory
|
||||
.getCreateTableSpecificationFor(mappingContext.getRequiredPersistentEntity(EntityWithComplexId.class));
|
||||
fail("Missing MappingException");
|
||||
} catch (MappingException e) {
|
||||
assertThat(e).hasMessageContaining(
|
||||
@@ -606,7 +608,6 @@ public class SchemaFactoryUnitTests {
|
||||
String.format("Cannot find column '%s' amongst '%s'", columnName, specification.getColumns()));
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
private static class Employee {
|
||||
|
||||
@@ -620,7 +621,6 @@ public class SchemaFactoryUnitTests {
|
||||
@CassandraType(type = Name.SET, typeArguments = Name.BIGINT) List<Human> enemies;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
private static class WithMappedTuple {
|
||||
|
||||
@@ -633,11 +633,11 @@ public class SchemaFactoryUnitTests {
|
||||
private static class MappedTuple {
|
||||
|
||||
@Element(0) MappedUdt mappedUdt;
|
||||
@Element(1) @CassandraType(type = Name.UDT, userTypeName = "human_udt") UdtValue human;
|
||||
@Element(1)
|
||||
@CassandraType(type = Name.UDT, userTypeName = "human_udt") UdtValue human;
|
||||
@Element(2) String text;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
private static class WithUdtFields {
|
||||
|
||||
@@ -648,7 +648,6 @@ public class SchemaFactoryUnitTests {
|
||||
@CassandraType(type = Name.SET, typeArguments = Name.UDT, userTypeName = "peeps_udt") Set<UdtValue> people;
|
||||
}
|
||||
|
||||
@Data
|
||||
@Table
|
||||
private static class WithMappedUdtFields {
|
||||
|
||||
@@ -664,9 +663,6 @@ public class SchemaFactoryUnitTests {
|
||||
@org.springframework.data.cassandra.core.mapping.UserDefinedType
|
||||
private static class MappedUdt {}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class Human {
|
||||
|
||||
String firstname;
|
||||
@@ -796,16 +792,15 @@ public class SchemaFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
static class TypeWithEmbedded {
|
||||
|
||||
@Id String id;
|
||||
@Embedded.Nullable EmbeddedTpe name;
|
||||
@Embedded.Nullable(prefix = "a") EmbeddedTpe alias;
|
||||
@Indexed @Embedded.Nullable(prefix = "aego") EmbeddedTpe alterEgo;
|
||||
@Indexed
|
||||
@Embedded.Nullable(prefix = "aego") EmbeddedTpe alterEgo;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EmbeddedTpe {
|
||||
|
||||
@Indexed String firstname;
|
||||
@@ -852,7 +847,6 @@ public class SchemaFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
static class TypeWithStatic {
|
||||
|
||||
@Id String id;
|
||||
@@ -860,7 +854,6 @@ public class SchemaFactoryUnitTests {
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
static class TypeWithStaticTuple {
|
||||
|
||||
@Id String id;
|
||||
@@ -877,8 +870,7 @@ public class SchemaFactoryUnitTests {
|
||||
@Test // GH-978
|
||||
void createdTableSpecificationShouldConsiderStaticColumns() {
|
||||
|
||||
CassandraPersistentEntity<?> persistentEntity = mappingContext
|
||||
.getRequiredPersistentEntity(TypeWithStatic.class);
|
||||
CassandraPersistentEntity<?> persistentEntity = mappingContext.getRequiredPersistentEntity(TypeWithStatic.class);
|
||||
|
||||
CreateTableSpecification tableSpecification = schemaFactory.getCreateTableSpecificationFor(persistentEntity);
|
||||
|
||||
|
||||
@@ -15,11 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.core.convert;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
@@ -28,11 +23,6 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class TimeEntity {
|
||||
public record TimeEntity(@PrimaryKey String id, @CassandraType(type = CassandraType.Name.TIME) long time) {
|
||||
|
||||
@PrimaryKey @NonNull private String id;
|
||||
@CassandraType(type = CassandraType.Name.TIME) private long time;
|
||||
}
|
||||
|
||||
@@ -18,9 +18,6 @@ package org.springframework.data.cassandra.core.convert;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
@@ -409,40 +406,98 @@ class UpdateMapperUnitTests {
|
||||
}
|
||||
|
||||
@Tuple
|
||||
@AllArgsConstructor
|
||||
static class MappedTuple {
|
||||
@Element(0) String zip;
|
||||
|
||||
public MappedTuple(String zip) {
|
||||
this.zip = zip;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
@UserDefinedType
|
||||
@AllArgsConstructor
|
||||
static class Manufacturer {
|
||||
String name;
|
||||
|
||||
public Manufacturer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
@Embedded.Nullable EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class WithPrefixedNullableEmbeddedType {
|
||||
|
||||
@Id String id;
|
||||
|
||||
// @Indexed -> index for all properties of nested
|
||||
@Embedded.Nullable(prefix = "prefix") EmbeddedWithSimpleTypes nested;
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public EmbeddedWithSimpleTypes getNested() {
|
||||
return this.nested;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setNested(EmbeddedWithSimpleTypes nested) {
|
||||
this.nested = nested;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class EmbeddedWithSimpleTypes {
|
||||
|
||||
@Indexed String firstname;
|
||||
Integer age;
|
||||
|
||||
public @Indexed String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public Integer getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public void setFirstname(@Indexed String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setAge(Integer age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Date;
|
||||
@@ -32,6 +30,7 @@ import org.springframework.data.cassandra.core.cql.keyspace.ColumnSpecification;
|
||||
import org.springframework.data.cassandra.core.cql.keyspace.CreateTableSpecification;
|
||||
import org.springframework.data.mapping.model.Property;
|
||||
import org.springframework.data.util.TypeInformation;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.ReflectionUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.type.DataTypes;
|
||||
@@ -66,8 +65,7 @@ class CassandraCompositePrimaryKeyUnitTests {
|
||||
|
||||
Field field = ReflectionUtils.findField(TypeWithCompositeKey.class, "id");
|
||||
CassandraPersistentProperty property = new BasicCassandraPersistentProperty(
|
||||
Property.of(TypeInformation.of(TypeWithCompositeKey.class), field), entity,
|
||||
CassandraSimpleTypeHolder.HOLDER);
|
||||
Property.of(TypeInformation.of(TypeWithCompositeKey.class), field), entity, CassandraSimpleTypeHolder.HOLDER);
|
||||
assertThat(property.isIdProperty()).isTrue();
|
||||
assertThat(property.isCompositePrimaryKey()).isTrue();
|
||||
|
||||
@@ -89,7 +87,6 @@ class CassandraCompositePrimaryKeyUnitTests {
|
||||
}
|
||||
|
||||
@PrimaryKeyClass
|
||||
@EqualsAndHashCode
|
||||
static class CompositeKey implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -97,6 +94,28 @@ class CassandraCompositePrimaryKeyUnitTests {
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String z;
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.CLUSTERED) String a;
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
CompositeKey that = (CompositeKey) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(z, that.z)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(a, that.a);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(z);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(a);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Table
|
||||
|
||||
@@ -26,7 +26,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link CassandraMappingContext}.
|
||||
@@ -101,42 +101,30 @@ class CassandraPersistentEntityOrderPropertiesUnitTests {
|
||||
@PrimaryKeyColumn(ordinal = 1) private String key2;
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + ((key0 == null) ? 0 : key0.hashCode());
|
||||
result = prime * result + ((key1 == null) ? 0 : key1.hashCode());
|
||||
result = prime * result + ((key2 == null) ? 0 : key2.hashCode());
|
||||
return result;
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
CompositePK that = (CompositePK) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(key0, that.key0)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(key1, that.key1)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(key2, that.key2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
if (this == obj)
|
||||
return true;
|
||||
if (obj == null)
|
||||
return false;
|
||||
if (getClass() != obj.getClass())
|
||||
return false;
|
||||
CompositePK other = (CompositePK) obj;
|
||||
if (key0 == null) {
|
||||
if (other.key0 != null)
|
||||
return false;
|
||||
} else if (!key0.equals(other.key0))
|
||||
return false;
|
||||
if (key1 == null) {
|
||||
if (other.key1 != null)
|
||||
return false;
|
||||
} else if (!key1.equals(other.key1))
|
||||
return false;
|
||||
if (key2 == null) {
|
||||
if (other.key2 != null)
|
||||
return false;
|
||||
} else if (!key2.equals(other.key2))
|
||||
return false;
|
||||
return true;
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(key0);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(key1);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(key2);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Table
|
||||
|
||||
@@ -17,9 +17,6 @@ package org.springframework.data.cassandra.core.mapping;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -67,27 +64,55 @@ public class CreateUserTypeIntegrationTests extends AbstractSpringDataEmbeddedCa
|
||||
}
|
||||
|
||||
@Table
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Car {
|
||||
|
||||
@Id String id;
|
||||
Engine engine;
|
||||
|
||||
public Car(String id, Engine engine) {
|
||||
this.id = id;
|
||||
this.engine = engine;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Engine getEngine() {
|
||||
return this.engine;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Engine {
|
||||
Manufacturer manufacturer;
|
||||
List<Manufacturer> alternative;
|
||||
|
||||
public Engine(Manufacturer manufacturer, List<Manufacturer> alternative) {
|
||||
this.manufacturer = manufacturer;
|
||||
this.alternative = alternative;
|
||||
}
|
||||
|
||||
public Manufacturer getManufacturer() {
|
||||
return this.manufacturer;
|
||||
}
|
||||
|
||||
public List<Manufacturer> getAlternative() {
|
||||
return this.alternative;
|
||||
}
|
||||
}
|
||||
|
||||
@UserDefinedType
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
private static class Manufacturer {
|
||||
String name;
|
||||
|
||||
public Manufacturer(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,11 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
|
||||
@@ -106,9 +101,9 @@ class AuditingEntityCallbackUnitTests {
|
||||
@Test // DATACASS-4
|
||||
void propagatesChangedInstanceToEvent() {
|
||||
|
||||
ImmutableSample sample = new ImmutableSample();
|
||||
ImmutableSample sample = new ImmutableSample("a", null, null);
|
||||
|
||||
ImmutableSample newSample = new ImmutableSample();
|
||||
ImmutableSample newSample = new ImmutableSample("a", null, null);
|
||||
IsNewAwareAuditingHandler handler = mock(IsNewAwareAuditingHandler.class);
|
||||
doReturn(newSample).when(handler).markAudited(eq(sample));
|
||||
|
||||
@@ -125,14 +120,8 @@ class AuditingEntityCallbackUnitTests {
|
||||
@LastModifiedDate Date modified;
|
||||
}
|
||||
|
||||
@Value
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor(force = true)
|
||||
static class ImmutableSample {
|
||||
record ImmutableSample(
|
||||
|
||||
@Id String id;
|
||||
@CreatedDate Date created;
|
||||
@LastModifiedDate Date modified;
|
||||
@Id String id, @CreatedDate Date created, @LastModifiedDate Date modified) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,10 +19,6 @@ import static org.assertj.core.api.Assertions.*;
|
||||
import static org.mockito.ArgumentMatchers.*;
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Value;
|
||||
import lombok.With;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.util.Collections;
|
||||
@@ -107,9 +103,9 @@ class ReactiveAuditingEntityCallbackUnitTests {
|
||||
@Test // DATACASS-4, DATACASS-784
|
||||
void propagatesChangedInstanceToEvent() {
|
||||
|
||||
ImmutableSample sample = new ImmutableSample();
|
||||
ImmutableSample sample = new ImmutableSample("a", null, null);
|
||||
|
||||
ImmutableSample newSample = new ImmutableSample();
|
||||
ImmutableSample newSample = new ImmutableSample("a", null, null);
|
||||
ReactiveIsNewAwareAuditingHandler handler = mock(ReactiveIsNewAwareAuditingHandler.class);
|
||||
doReturn(Mono.just(newSample)).when(handler).markAudited(eq(sample));
|
||||
|
||||
@@ -126,14 +122,6 @@ class ReactiveAuditingEntityCallbackUnitTests {
|
||||
@LastModifiedDate Date modified;
|
||||
}
|
||||
|
||||
@Value
|
||||
@With
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor(force = true)
|
||||
static class ImmutableSample {
|
||||
|
||||
@Id String id;
|
||||
@CreatedDate Date created;
|
||||
@LastModifiedDate Date modified;
|
||||
record ImmutableSample(@Id String id, @CreatedDate Date created, @LastModifiedDate Date modified) {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,21 +15,60 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.UserDefinedType;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@UserDefinedType("address")
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class AddressType {
|
||||
|
||||
String city;
|
||||
String country;
|
||||
|
||||
public AddressType(String city, String country) {
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public AddressType() {}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
AddressType that = (AddressType) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(city, that.city)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(country, that.country);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(city);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(country);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,15 +17,15 @@ package org.springframework.data.cassandra.domain;
|
||||
|
||||
import static org.springframework.data.cassandra.core.mapping.CassandraType.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.NonNull;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.BigInteger;
|
||||
import java.net.InetAddress;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.time.Instant;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -36,6 +36,7 @@ import org.springframework.data.cassandra.core.convert.CassandraTypeMappingInteg
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.data.TupleValue;
|
||||
|
||||
@@ -43,12 +44,9 @@ import com.datastax.oss.driver.api.core.data.TupleValue;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
public class AllPossibleTypes {
|
||||
|
||||
@PrimaryKey @NonNull String id;
|
||||
@PrimaryKey String id;
|
||||
|
||||
InetAddress inet;
|
||||
|
||||
@@ -101,4 +99,426 @@ public class AllPossibleTypes {
|
||||
java.time.LocalDateTime localDateTime;
|
||||
java.time.ZoneId zoneId;
|
||||
|
||||
public AllPossibleTypes(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public AllPossibleTypes() {}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public InetAddress getInet() {
|
||||
return inet;
|
||||
}
|
||||
|
||||
public void setInet(InetAddress inet) {
|
||||
this.inet = inet;
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
public void setUuid(UUID uuid) {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
public Number getJustNumber() {
|
||||
return justNumber;
|
||||
}
|
||||
|
||||
public void setJustNumber(Number justNumber) {
|
||||
this.justNumber = justNumber;
|
||||
}
|
||||
|
||||
public Byte getBoxedByte() {
|
||||
return boxedByte;
|
||||
}
|
||||
|
||||
public void setBoxedByte(Byte boxedByte) {
|
||||
this.boxedByte = boxedByte;
|
||||
}
|
||||
|
||||
public byte getPrimitiveByte() {
|
||||
return primitiveByte;
|
||||
}
|
||||
|
||||
public void setPrimitiveByte(byte primitiveByte) {
|
||||
this.primitiveByte = primitiveByte;
|
||||
}
|
||||
|
||||
public Short getBoxedShort() {
|
||||
return boxedShort;
|
||||
}
|
||||
|
||||
public void setBoxedShort(Short boxedShort) {
|
||||
this.boxedShort = boxedShort;
|
||||
}
|
||||
|
||||
public short getPrimitiveShort() {
|
||||
return primitiveShort;
|
||||
}
|
||||
|
||||
public void setPrimitiveShort(short primitiveShort) {
|
||||
this.primitiveShort = primitiveShort;
|
||||
}
|
||||
|
||||
public Long getBoxedLong() {
|
||||
return boxedLong;
|
||||
}
|
||||
|
||||
public void setBoxedLong(Long boxedLong) {
|
||||
this.boxedLong = boxedLong;
|
||||
}
|
||||
|
||||
public long getPrimitiveLong() {
|
||||
return primitiveLong;
|
||||
}
|
||||
|
||||
public void setPrimitiveLong(long primitiveLong) {
|
||||
this.primitiveLong = primitiveLong;
|
||||
}
|
||||
|
||||
public Integer getBoxedInteger() {
|
||||
return boxedInteger;
|
||||
}
|
||||
|
||||
public void setBoxedInteger(Integer boxedInteger) {
|
||||
this.boxedInteger = boxedInteger;
|
||||
}
|
||||
|
||||
public int getPrimitiveInteger() {
|
||||
return primitiveInteger;
|
||||
}
|
||||
|
||||
public void setPrimitiveInteger(int primitiveInteger) {
|
||||
this.primitiveInteger = primitiveInteger;
|
||||
}
|
||||
|
||||
public Float getBoxedFloat() {
|
||||
return boxedFloat;
|
||||
}
|
||||
|
||||
public void setBoxedFloat(Float boxedFloat) {
|
||||
this.boxedFloat = boxedFloat;
|
||||
}
|
||||
|
||||
public float getPrimitiveFloat() {
|
||||
return primitiveFloat;
|
||||
}
|
||||
|
||||
public void setPrimitiveFloat(float primitiveFloat) {
|
||||
this.primitiveFloat = primitiveFloat;
|
||||
}
|
||||
|
||||
public Double getBoxedDouble() {
|
||||
return boxedDouble;
|
||||
}
|
||||
|
||||
public void setBoxedDouble(Double boxedDouble) {
|
||||
this.boxedDouble = boxedDouble;
|
||||
}
|
||||
|
||||
public double getPrimitiveDouble() {
|
||||
return primitiveDouble;
|
||||
}
|
||||
|
||||
public void setPrimitiveDouble(double primitiveDouble) {
|
||||
this.primitiveDouble = primitiveDouble;
|
||||
}
|
||||
|
||||
public Boolean getBoxedBoolean() {
|
||||
return boxedBoolean;
|
||||
}
|
||||
|
||||
public void setBoxedBoolean(Boolean boxedBoolean) {
|
||||
this.boxedBoolean = boxedBoolean;
|
||||
}
|
||||
|
||||
public boolean isPrimitiveBoolean() {
|
||||
return primitiveBoolean;
|
||||
}
|
||||
|
||||
public void setPrimitiveBoolean(boolean primitiveBoolean) {
|
||||
this.primitiveBoolean = primitiveBoolean;
|
||||
}
|
||||
|
||||
public Instant getInstant() {
|
||||
return instant;
|
||||
}
|
||||
|
||||
public void setInstant(Instant instant) {
|
||||
this.instant = instant;
|
||||
}
|
||||
|
||||
public LocalDate getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
public void setDate(LocalDate date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public LocalTime getTime() {
|
||||
return time;
|
||||
}
|
||||
|
||||
public void setTime(LocalTime time) {
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public Date getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Date timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public BigDecimal getBigDecimal() {
|
||||
return bigDecimal;
|
||||
}
|
||||
|
||||
public void setBigDecimal(BigDecimal bigDecimal) {
|
||||
this.bigDecimal = bigDecimal;
|
||||
}
|
||||
|
||||
public BigInteger getBigInteger() {
|
||||
return bigInteger;
|
||||
}
|
||||
|
||||
public void setBigInteger(BigInteger bigInteger) {
|
||||
this.bigInteger = bigInteger;
|
||||
}
|
||||
|
||||
public ByteBuffer getBlob() {
|
||||
return blob;
|
||||
}
|
||||
|
||||
public void setBlob(ByteBuffer blob) {
|
||||
this.blob = blob;
|
||||
}
|
||||
|
||||
public Set<String> getSetOfString() {
|
||||
return setOfString;
|
||||
}
|
||||
|
||||
public void setSetOfString(Set<String> setOfString) {
|
||||
this.setOfString = setOfString;
|
||||
}
|
||||
|
||||
public List<String> getListOfString() {
|
||||
return listOfString;
|
||||
}
|
||||
|
||||
public void setListOfString(List<String> listOfString) {
|
||||
this.listOfString = listOfString;
|
||||
}
|
||||
|
||||
public Map<String, String> getMapOfString() {
|
||||
return mapOfString;
|
||||
}
|
||||
|
||||
public void setMapOfString(Map<String, String> mapOfString) {
|
||||
this.mapOfString = mapOfString;
|
||||
}
|
||||
|
||||
public Condition getAnEnum() {
|
||||
return anEnum;
|
||||
}
|
||||
|
||||
public void setAnEnum(Condition anEnum) {
|
||||
this.anEnum = anEnum;
|
||||
}
|
||||
|
||||
public Set<Condition> getSetOfEnum() {
|
||||
return setOfEnum;
|
||||
}
|
||||
|
||||
public void setSetOfEnum(Set<Condition> setOfEnum) {
|
||||
this.setOfEnum = setOfEnum;
|
||||
}
|
||||
|
||||
public List<Condition> getListOfEnum() {
|
||||
return listOfEnum;
|
||||
}
|
||||
|
||||
public void setListOfEnum(List<Condition> listOfEnum) {
|
||||
this.listOfEnum = listOfEnum;
|
||||
}
|
||||
|
||||
public TupleValue getTupleValue() {
|
||||
return tupleValue;
|
||||
}
|
||||
|
||||
public void setTupleValue(TupleValue tupleValue) {
|
||||
this.tupleValue = tupleValue;
|
||||
}
|
||||
|
||||
public LocalDateTime getLocalDateTime() {
|
||||
return localDateTime;
|
||||
}
|
||||
|
||||
public void setLocalDateTime(LocalDateTime localDateTime) {
|
||||
this.localDateTime = localDateTime;
|
||||
}
|
||||
|
||||
public ZoneId getZoneId() {
|
||||
return zoneId;
|
||||
}
|
||||
|
||||
public void setZoneId(ZoneId zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
AllPossibleTypes that = (AllPossibleTypes) o;
|
||||
|
||||
if (primitiveByte != that.primitiveByte)
|
||||
return false;
|
||||
if (primitiveShort != that.primitiveShort)
|
||||
return false;
|
||||
if (primitiveLong != that.primitiveLong)
|
||||
return false;
|
||||
if (primitiveInteger != that.primitiveInteger)
|
||||
return false;
|
||||
if (primitiveFloat != that.primitiveFloat)
|
||||
return false;
|
||||
if (primitiveDouble != that.primitiveDouble)
|
||||
return false;
|
||||
if (primitiveBoolean != that.primitiveBoolean)
|
||||
return false;
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(inet, that.inet)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(uuid, that.uuid)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(justNumber, that.justNumber)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedByte, that.boxedByte)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedShort, that.boxedShort)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedLong, that.boxedLong)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedInteger, that.boxedInteger)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedFloat, that.boxedFloat)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedDouble, that.boxedDouble)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(boxedBoolean, that.boxedBoolean)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(instant, that.instant)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(date, that.date)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(time, that.time)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(timestamp, that.timestamp)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(bigDecimal, that.bigDecimal)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(bigInteger, that.bigInteger)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(blob, that.blob)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(setOfString, that.setOfString)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(listOfString, that.listOfString)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(mapOfString, that.mapOfString)) {
|
||||
return false;
|
||||
}
|
||||
if (anEnum != that.anEnum)
|
||||
return false;
|
||||
if (!ObjectUtils.nullSafeEquals(setOfEnum, that.setOfEnum)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(listOfEnum, that.listOfEnum)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(tupleValue, that.tupleValue)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(localDateTime, that.localDateTime)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(zoneId, that.zoneId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result;
|
||||
long temp;
|
||||
result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(inet);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(uuid);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(justNumber);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedByte);
|
||||
result = 31 * result + (int) primitiveByte;
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedShort);
|
||||
result = 31 * result + (int) primitiveShort;
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedLong);
|
||||
result = 31 * result + (int) (primitiveLong ^ (primitiveLong >>> 32));
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedInteger);
|
||||
result = 31 * result + primitiveInteger;
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedFloat);
|
||||
result = 31 * result + (primitiveFloat != +0.0f ? Float.floatToIntBits(primitiveFloat) : 0);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedDouble);
|
||||
temp = Double.doubleToLongBits(primitiveDouble);
|
||||
result = 31 * result + (int) (temp ^ (temp >>> 32));
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(boxedBoolean);
|
||||
result = 31 * result + (primitiveBoolean ? 1 : 0);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(instant);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(date);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(time);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(timestamp);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(bigDecimal);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(bigInteger);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(blob);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(setOfString);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(listOfString);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(mapOfString);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(anEnum);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(setOfEnum);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(listOfEnum);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(tupleValue);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(localDateTime);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(zoneId);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@@ -31,7 +30,6 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table("bookReference")
|
||||
@Data
|
||||
public class BookReference {
|
||||
|
||||
@PrimaryKey private String isbn;
|
||||
@@ -40,4 +38,44 @@ public class BookReference {
|
||||
private Set<String> references;
|
||||
private List<Integer> bookmarks;
|
||||
private Map<String, String> credits;
|
||||
|
||||
public String getIsbn() {
|
||||
return this.isbn;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
public Set<String> getReferences() {
|
||||
return this.references;
|
||||
}
|
||||
|
||||
public List<Integer> getBookmarks() {
|
||||
return this.bookmarks;
|
||||
}
|
||||
|
||||
public Map<String, String> getCredits() {
|
||||
return this.credits;
|
||||
}
|
||||
|
||||
public void setIsbn(String isbn) {
|
||||
this.isbn = isbn;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public void setReferences(Set<String> references) {
|
||||
this.references = references;
|
||||
}
|
||||
|
||||
public void setBookmarks(List<Integer> bookmarks) {
|
||||
this.bookmarks = bookmarks;
|
||||
}
|
||||
|
||||
public void setCredits(Map<String, String> credits) {
|
||||
this.credits = credits;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
@@ -29,11 +25,31 @@ import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@PrimaryKeyClass
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CompositeKey implements Serializable {
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1, name = "first_name") private String firstname;
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname;
|
||||
|
||||
public CompositeKey(String firstname, String lastname) {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public CompositeKey() {}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
@@ -27,7 +26,6 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling</a>
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
public class FlatGroup {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String groupname;
|
||||
@@ -42,4 +40,44 @@ public class FlatGroup {
|
||||
this.hashPrefix = hashPrefix;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getGroupname() {
|
||||
return this.groupname;
|
||||
}
|
||||
|
||||
public String getHashPrefix() {
|
||||
return this.hashPrefix;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public void setGroupname(String groupname) {
|
||||
this.groupname = groupname;
|
||||
}
|
||||
|
||||
public void setHashPrefix(String hashPrefix) {
|
||||
this.hashPrefix = hashPrefix;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,11 +15,10 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
@@ -27,8 +26,6 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling</a>
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
public class Group {
|
||||
|
||||
@PrimaryKey private GroupKey id;
|
||||
@@ -39,4 +36,55 @@ public class Group {
|
||||
public Group(GroupKey id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Group() {}
|
||||
|
||||
public GroupKey getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return this.email;
|
||||
}
|
||||
|
||||
public int getAge() {
|
||||
return this.age;
|
||||
}
|
||||
|
||||
public void setId(GroupKey id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setEmail(String email) {
|
||||
this.email = email;
|
||||
}
|
||||
|
||||
public void setAge(int age) {
|
||||
this.age = age;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Group group = (Group) o;
|
||||
|
||||
if (age != group.age)
|
||||
return false;
|
||||
if (!ObjectUtils.nullSafeEquals(id, group.id)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(email, group.email);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(email);
|
||||
result = 31 * result + age;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,15 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
@@ -31,12 +28,67 @@ import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
* "https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling">https://www.datastax.com/dev/blog/basic-rules-of-cassandra-data-modeling</a>
|
||||
*/
|
||||
@PrimaryKeyClass
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class GroupKey implements Serializable {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 1, type = PrimaryKeyType.PARTITIONED) private String groupname;
|
||||
@PrimaryKeyColumn(name = "hash_prefix", ordinal = 2, type = PrimaryKeyType.PARTITIONED) private String hashPrefix;
|
||||
@PrimaryKeyColumn(ordinal = 3, type = PrimaryKeyType.CLUSTERED) private String username;
|
||||
|
||||
public GroupKey(String groupname, String hashPrefix, String username) {
|
||||
this.groupname = groupname;
|
||||
this.hashPrefix = hashPrefix;
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public GroupKey() {}
|
||||
|
||||
public String getGroupname() {
|
||||
return this.groupname;
|
||||
}
|
||||
|
||||
public String getHashPrefix() {
|
||||
return this.hashPrefix;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public void setGroupname(String groupname) {
|
||||
this.groupname = groupname;
|
||||
}
|
||||
|
||||
public void setHashPrefix(String hashPrefix) {
|
||||
this.hashPrefix = hashPrefix;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
GroupKey groupKey = (GroupKey) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(groupname, groupKey.groupname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(hashPrefix, groupKey.hashPrefix)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(username, groupKey.username);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(groupname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(hashPrefix);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(username);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,10 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.ZoneId;
|
||||
import java.util.Date;
|
||||
@@ -27,14 +23,12 @@ import java.util.List;
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class Person {
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 0) private String lastname;
|
||||
@@ -57,4 +51,152 @@ public class Person {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public Person(String lastname, String firstname, String nickname, Date birthDate, int numberOfChildren, boolean cool,
|
||||
LocalDate createdDate, ZoneId zoneId, AddressType mainAddress, List<AddressType> alternativeAddresses) {
|
||||
this.lastname = lastname;
|
||||
this.firstname = firstname;
|
||||
this.nickname = nickname;
|
||||
this.birthDate = birthDate;
|
||||
this.numberOfChildren = numberOfChildren;
|
||||
this.cool = cool;
|
||||
this.createdDate = createdDate;
|
||||
this.zoneId = zoneId;
|
||||
this.mainAddress = mainAddress;
|
||||
this.alternativeAddresses = alternativeAddresses;
|
||||
}
|
||||
|
||||
public Person() {}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getNickname() {
|
||||
return this.nickname;
|
||||
}
|
||||
|
||||
public Date getBirthDate() {
|
||||
return this.birthDate;
|
||||
}
|
||||
|
||||
public int getNumberOfChildren() {
|
||||
return this.numberOfChildren;
|
||||
}
|
||||
|
||||
public boolean isCool() {
|
||||
return this.cool;
|
||||
}
|
||||
|
||||
public LocalDate getCreatedDate() {
|
||||
return this.createdDate;
|
||||
}
|
||||
|
||||
public ZoneId getZoneId() {
|
||||
return this.zoneId;
|
||||
}
|
||||
|
||||
public AddressType getMainAddress() {
|
||||
return this.mainAddress;
|
||||
}
|
||||
|
||||
public List<AddressType> getAlternativeAddresses() {
|
||||
return this.alternativeAddresses;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setNickname(String nickname) {
|
||||
this.nickname = nickname;
|
||||
}
|
||||
|
||||
public void setBirthDate(Date birthDate) {
|
||||
this.birthDate = birthDate;
|
||||
}
|
||||
|
||||
public void setNumberOfChildren(int numberOfChildren) {
|
||||
this.numberOfChildren = numberOfChildren;
|
||||
}
|
||||
|
||||
public void setCool(boolean cool) {
|
||||
this.cool = cool;
|
||||
}
|
||||
|
||||
public void setCreatedDate(LocalDate createdDate) {
|
||||
this.createdDate = createdDate;
|
||||
}
|
||||
|
||||
public void setZoneId(ZoneId zoneId) {
|
||||
this.zoneId = zoneId;
|
||||
}
|
||||
|
||||
public void setMainAddress(AddressType mainAddress) {
|
||||
this.mainAddress = mainAddress;
|
||||
}
|
||||
|
||||
public void setAlternativeAddresses(List<AddressType> alternativeAddresses) {
|
||||
this.alternativeAddresses = alternativeAddresses;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Person person = (Person) o;
|
||||
|
||||
if (numberOfChildren != person.numberOfChildren)
|
||||
return false;
|
||||
if (cool != person.cool)
|
||||
return false;
|
||||
if (!ObjectUtils.nullSafeEquals(lastname, person.lastname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, person.firstname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(nickname, person.nickname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(birthDate, person.birthDate)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(createdDate, person.createdDate)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(zoneId, person.zoneId)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(mainAddress, person.mainAddress)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(alternativeAddresses, person.alternativeAddresses);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(lastname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(nickname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(birthDate);
|
||||
result = 31 * result + numberOfChildren;
|
||||
result = 31 * result + (cool ? 1 : 0);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(createdDate);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(zoneId);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(mainAddress);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(alternativeAddresses);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
@@ -25,9 +23,24 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
public class TypeWithCompositeKey {
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1) private String firstname;
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname;
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
@@ -24,8 +23,15 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
public class TypeWithKeyClass {
|
||||
|
||||
@PrimaryKey CompositeKey key;
|
||||
|
||||
public CompositeKey getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public void setKey(CompositeKey key) {
|
||||
this.key = key;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.BasicMapId;
|
||||
import org.springframework.data.cassandra.core.mapping.MapId;
|
||||
@@ -28,12 +26,27 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
public class TypeWithMapId implements MapIdentifiable {
|
||||
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 1) private String firstname;
|
||||
@PrimaryKeyColumn(type = PrimaryKeyType.PARTITIONED, ordinal = 2) private String lastname;
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public MapId getMapId() {
|
||||
return BasicMapId.id("firstname", firstname).with("lastname", lastname);
|
||||
|
||||
@@ -15,9 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
import java.util.Objects;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
@@ -28,9 +26,6 @@ import org.springframework.data.cassandra.core.mapping.Table;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table("users")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(of = "id")
|
||||
public class User {
|
||||
|
||||
/*
|
||||
@@ -44,6 +39,8 @@ public class User {
|
||||
private String firstname;
|
||||
private String lastname;
|
||||
|
||||
public User() {}
|
||||
|
||||
@PersistenceConstructor
|
||||
public User(String id, String firstname, String lastname) {
|
||||
|
||||
@@ -51,4 +48,45 @@ public class User {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
User user = (User) o;
|
||||
|
||||
return Objects.equals(id, user.id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return id != null ? id.hashCode() : 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,20 +15,18 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.Column;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table("user_tokens")
|
||||
@Data
|
||||
public class UserToken {
|
||||
|
||||
@PrimaryKeyColumn(name = "user_id", type = PrimaryKeyType.PARTITIONED, ordinal = 0) private UUID userId;
|
||||
@@ -37,4 +35,65 @@ public class UserToken {
|
||||
@Column("user_comment") String userComment;
|
||||
String adminComment;
|
||||
|
||||
public UUID getUserId() {
|
||||
return userId;
|
||||
}
|
||||
|
||||
public void setUserId(UUID userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public UUID getToken() {
|
||||
return token;
|
||||
}
|
||||
|
||||
public void setToken(UUID token) {
|
||||
this.token = token;
|
||||
}
|
||||
|
||||
public String getUserComment() {
|
||||
return userComment;
|
||||
}
|
||||
|
||||
public void setUserComment(String userComment) {
|
||||
this.userComment = userComment;
|
||||
}
|
||||
|
||||
public String getAdminComment() {
|
||||
return adminComment;
|
||||
}
|
||||
|
||||
public void setAdminComment(String adminComment) {
|
||||
this.adminComment = adminComment;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
UserToken userToken = (UserToken) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(userId, userToken.userId)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(token, userToken.token)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(userComment, userToken.userComment)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(adminComment, userToken.adminComment);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(userId);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(token);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(userComment);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(adminComment);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,22 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.domain;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.annotation.PersistenceConstructor;
|
||||
import org.springframework.data.annotation.Version;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table("vusers")
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
@EqualsAndHashCode(of = "id")
|
||||
public class VersionedUser {
|
||||
|
||||
/*
|
||||
@@ -53,4 +47,68 @@ public class VersionedUser {
|
||||
this.firstname = firstname;
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
public VersionedUser() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Long getVersion() {
|
||||
return this.version;
|
||||
}
|
||||
|
||||
public String getFirstname() {
|
||||
return this.firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return this.lastname;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setVersion(Long version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
VersionedUser that = (VersionedUser) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(version, that.version)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, that.firstname)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(lastname, that.lastname);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(version);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,10 +18,6 @@ package org.springframework.data.cassandra.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
@@ -81,12 +77,23 @@ class BigIntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraInt
|
||||
* @author Pete Cable
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class BigThing {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private BigInteger number;
|
||||
|
||||
public BigThing(BigInteger number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public BigThing() {}
|
||||
|
||||
public BigInteger getNumber() {
|
||||
return this.number;
|
||||
}
|
||||
|
||||
public void setNumber(BigInteger number) {
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.cassandra.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.Set;
|
||||
@@ -80,12 +76,23 @@ class DateKeyIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegra
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class DateThing {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private Date date;
|
||||
|
||||
public DateThing(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
|
||||
public DateThing() {}
|
||||
|
||||
public Date getDate() {
|
||||
return this.date;
|
||||
}
|
||||
|
||||
public void setDate(Date date) {
|
||||
this.date = date;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,10 +17,6 @@ package org.springframework.data.cassandra.repository;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -78,12 +74,23 @@ class IntParamIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegr
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
static class IntThing {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) private int number;
|
||||
|
||||
public IntThing(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
public IntThing() {}
|
||||
|
||||
public int getNumber() {
|
||||
return this.number;
|
||||
}
|
||||
|
||||
public void setNumber(int number) {
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
|
||||
interface IntThingRepo extends MapIdCassandraRepository<IntThing> {
|
||||
|
||||
@@ -18,8 +18,6 @@ package org.springframework.data.cassandra.repository;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.junit.Assume.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -60,6 +58,7 @@ import org.springframework.data.domain.Sort;
|
||||
import org.springframework.data.util.Version;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlSession;
|
||||
|
||||
@@ -469,17 +468,99 @@ class QueryDerivationIntegrationTests extends AbstractSpringDataEmbeddedCassandr
|
||||
}
|
||||
|
||||
@Table
|
||||
@Data
|
||||
static class PersonWithEmbedded {
|
||||
|
||||
@Id String id;
|
||||
@Embedded.Nullable Name name;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Name getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public void setName(Name name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
PersonWithEmbedded that = (PersonWithEmbedded) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, that.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(name, that.name)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(name);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@Data
|
||||
static class Name {
|
||||
|
||||
@Indexed String firstname;
|
||||
String lastname;
|
||||
|
||||
public String getFirstname() {
|
||||
return firstname;
|
||||
}
|
||||
|
||||
public void setFirstname(String firstname) {
|
||||
this.firstname = firstname;
|
||||
}
|
||||
|
||||
public String getLastname() {
|
||||
return lastname;
|
||||
}
|
||||
|
||||
public void setLastname(String lastname) {
|
||||
this.lastname = lastname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Name name = (Name) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(firstname, name.firstname)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(lastname, name.lastname)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(firstname);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(lastname);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,18 +15,68 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.conversion;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
class Address {
|
||||
|
||||
String city;
|
||||
String country;
|
||||
|
||||
public Address(String city, String country) {
|
||||
this.city = city;
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
public Address() {}
|
||||
|
||||
public String getCity() {
|
||||
return this.city;
|
||||
}
|
||||
|
||||
public String getCountry() {
|
||||
return this.country;
|
||||
}
|
||||
|
||||
public void setCity(String city) {
|
||||
this.city = city;
|
||||
}
|
||||
|
||||
public void setCountry(String country) {
|
||||
this.country = country;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Address address = (Address) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(city, address.city)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(country, address.country);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(city);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(country);
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [city='").append(city).append('\'');
|
||||
sb.append(", country='").append(country).append('\'');
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,21 +17,17 @@ package org.springframework.data.cassandra.repository.conversion;
|
||||
|
||||
import static org.springframework.data.cassandra.core.mapping.CassandraType.*;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import org.springframework.data.annotation.Id;
|
||||
import org.springframework.data.cassandra.core.mapping.CassandraType;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Table
|
||||
@Data
|
||||
@NoArgsConstructor
|
||||
class Contact {
|
||||
|
||||
@Id String id;
|
||||
@@ -47,4 +43,81 @@ class Contact {
|
||||
public Contact(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Contact() {}
|
||||
|
||||
public String getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Address getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
public List<Address> getAddresses() {
|
||||
return this.addresses;
|
||||
}
|
||||
|
||||
public Phone getMainPhone() {
|
||||
return this.mainPhone;
|
||||
}
|
||||
|
||||
public List<Phone> getAlternativePhones() {
|
||||
return this.alternativePhones;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setAddress(Address address) {
|
||||
this.address = address;
|
||||
}
|
||||
|
||||
public void setAddresses(List<Address> addresses) {
|
||||
this.addresses = addresses;
|
||||
}
|
||||
|
||||
public void setMainPhone(Phone mainPhone) {
|
||||
this.mainPhone = mainPhone;
|
||||
}
|
||||
|
||||
public void setAlternativePhones(List<Phone> alternativePhones) {
|
||||
this.alternativePhones = alternativePhones;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Contact contact = (Contact) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(id, contact.id)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(address, contact.address)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(addresses, contact.addresses)) {
|
||||
return false;
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(mainPhone, contact.mainPhone)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(alternativePhones, contact.alternativePhones);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(id);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(address);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(addresses);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(mainPhone);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(alternativePhones);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -15,13 +15,37 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.conversion;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@Data
|
||||
class Phone {
|
||||
|
||||
String number;
|
||||
|
||||
public String getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(String number) {
|
||||
this.number = number;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
Phone phone = (Phone) o;
|
||||
|
||||
return ObjectUtils.nullSafeEquals(number, phone.number);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return ObjectUtils.nullSafeHashCode(number);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,7 +25,7 @@ import org.springframework.data.cassandra.core.mapping.PrimaryKey;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyClass;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Matthew T. Adams
|
||||
@@ -119,32 +119,36 @@ public class CorrelationEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof IdentityEntity))
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
IdentityEntity that = (IdentityEntity) o;
|
||||
|
||||
if (correlatedType != null ? !correlatedType.equals(that.correlatedType) : that.correlatedType != null)
|
||||
if (!ObjectUtils.nullSafeEquals(type, that.type)) {
|
||||
return false;
|
||||
if (correlatedValue != null ? !correlatedValue.equals(that.correlatedValue) : that.correlatedValue != null)
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(value, that.value)) {
|
||||
return false;
|
||||
if (ts != null ? !ts.equals(that.ts) : that.ts != null)
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(correlatedType, that.correlatedType)) {
|
||||
return false;
|
||||
if (!type.equals(that.type))
|
||||
}
|
||||
if (!ObjectUtils.nullSafeEquals(ts, that.ts)) {
|
||||
return false;
|
||||
return value.equals(that.value);
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(correlatedValue, that.correlatedValue);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = type.hashCode();
|
||||
result = 31 * result + value.hashCode();
|
||||
result = 31 * result + (correlatedType != null ? correlatedType.hashCode() : 0);
|
||||
result = 31 * result + (ts != null ? ts.hashCode() : 0);
|
||||
result = 31 * result + (correlatedValue != null ? correlatedValue.hashCode() : 0);
|
||||
int result = ObjectUtils.nullSafeHashCode(type);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(value);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(correlatedType);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(ts);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(correlatedValue);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -183,23 +187,24 @@ public class CorrelationEntity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object o) {
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (!(o instanceof CorrelationEntity))
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
CorrelationEntity that = (CorrelationEntity) o;
|
||||
|
||||
if (extra != null ? !extra.equals(that.extra) : that.extra != null)
|
||||
if (!ObjectUtils.nullSafeEquals(identityEntity, that.identityEntity)) {
|
||||
return false;
|
||||
return identityEntity.equals(that.identityEntity);
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(extra, that.extra);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = identityEntity.hashCode();
|
||||
result = 31 * result + (extra != null ? extra.hashCode() : 0);
|
||||
int result = ObjectUtils.nullSafeHashCode(identityEntity);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(extra);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,9 +57,7 @@ import com.datastax.oss.driver.api.core.CqlSession;
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@SpringJUnitConfig
|
||||
@SuppressWarnings("Since15")
|
||||
class RepositoryQueryMethodParameterTypesIntegrationTests
|
||||
extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
|
||||
class RepositoryQueryMethodParameterTypesIntegrationTests extends AbstractSpringDataEmbeddedCassandraIntegrationTest {
|
||||
|
||||
@Configuration
|
||||
@EnableCassandraRepositories(basePackageClasses = RepositoryQueryMethodParameterTypesIntegrationTests.class,
|
||||
|
||||
@@ -15,18 +15,16 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.repository.mapid;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import org.springframework.data.cassandra.core.cql.PrimaryKeyType;
|
||||
import org.springframework.data.cassandra.core.mapping.Column;
|
||||
import org.springframework.data.cassandra.core.mapping.PrimaryKeyColumn;
|
||||
import org.springframework.data.cassandra.core.mapping.Table;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
|
||||
/**
|
||||
* @author Matthew T. Adams
|
||||
*/
|
||||
@Table
|
||||
@EqualsAndHashCode
|
||||
public class SinglePrimaryKeyColumn {
|
||||
|
||||
@PrimaryKeyColumn(ordinal = 0, type = PrimaryKeyType.PARTITIONED) String key;
|
||||
@@ -52,4 +50,26 @@ public class SinglePrimaryKeyColumn {
|
||||
public void setValue(String value) {
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o)
|
||||
return true;
|
||||
if (o == null || getClass() != o.getClass())
|
||||
return false;
|
||||
|
||||
SinglePrimaryKeyColumn that = (SinglePrimaryKeyColumn) o;
|
||||
|
||||
if (!ObjectUtils.nullSafeEquals(key, that.key)) {
|
||||
return false;
|
||||
}
|
||||
return ObjectUtils.nullSafeEquals(value, that.value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = ObjectUtils.nullSafeHashCode(key);
|
||||
result = 31 * result + ObjectUtils.nullSafeHashCode(value);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,6 @@ package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
@@ -79,7 +77,7 @@ class SimpleCassandraRepositoryUnitTests {
|
||||
repository = new SimpleCassandraRepository<Object, String>(new MappingCassandraEntityInformation(entity, converter),
|
||||
cassandraOperations);
|
||||
|
||||
SimplePerson person = new SimplePerson();
|
||||
SimplePerson person = new SimplePerson(null);
|
||||
|
||||
when(cassandraOperations.insert(eq(person), any())).thenReturn(writeResult);
|
||||
when(writeResult.getEntity()).thenReturn(person);
|
||||
@@ -196,16 +194,29 @@ class SimpleCassandraRepositoryUnitTests {
|
||||
SimplePerson.class);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class SimplePerson {
|
||||
record SimplePerson(@Id String id) {
|
||||
|
||||
@Id String id;
|
||||
}
|
||||
|
||||
@Data
|
||||
static class VersionedPerson {
|
||||
|
||||
@Id String id;
|
||||
@Version long version;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,6 @@ package org.springframework.data.cassandra.repository.support;
|
||||
|
||||
import static org.mockito.Mockito.*;
|
||||
|
||||
import lombok.Data;
|
||||
import reactor.core.publisher.Mono;
|
||||
|
||||
import java.io.Serializable;
|
||||
@@ -100,10 +99,25 @@ class SimpleReactiveCassandraRepositoryUnitTests {
|
||||
verify(cassandraOperations).update(versionedPerson);
|
||||
}
|
||||
|
||||
@Data
|
||||
static class VersionedPerson {
|
||||
|
||||
@Id String id;
|
||||
@Version long version;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public long getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
public void setVersion(long version) {
|
||||
this.version = version;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,8 +15,6 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.support;
|
||||
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import org.springframework.data.util.Version;
|
||||
import org.springframework.util.Assert;
|
||||
|
||||
@@ -29,8 +27,7 @@ import com.datastax.oss.driver.api.core.cql.Row;
|
||||
*
|
||||
* @author Mark Paluch
|
||||
*/
|
||||
@UtilityClass
|
||||
public class CassandraVersion {
|
||||
public final class CassandraVersion {
|
||||
|
||||
/**
|
||||
* Retrieve the Cassandra release version.
|
||||
|
||||
@@ -15,8 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.cassandra.support;
|
||||
|
||||
import lombok.SneakyThrows;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
@@ -52,9 +51,12 @@ public class CqlDataSet {
|
||||
return getLines();
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
private List<String> getLines() {
|
||||
return Resources.readLines(location, Charset.defaultCharset());
|
||||
try {
|
||||
return Resources.readLines(location, Charset.defaultCharset());
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -17,15 +17,9 @@ package org.springframework.data.cassandra.support;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.lang.Nullable;
|
||||
|
||||
import com.datastax.oss.driver.api.core.CqlIdentifier;
|
||||
import com.datastax.oss.driver.api.core.data.UdtValue;
|
||||
import com.datastax.oss.driver.api.core.detach.AttachmentPoint;
|
||||
import com.datastax.oss.driver.api.core.type.DataType;
|
||||
import com.datastax.oss.driver.api.core.type.UserDefinedType;
|
||||
import com.datastax.oss.driver.internal.core.type.DefaultUserDefinedType;
|
||||
@@ -64,103 +58,4 @@ public class UserDefinedTypeBuilder {
|
||||
return type;
|
||||
}
|
||||
|
||||
private static class UserDefinedTypeWrapper implements UserDefinedType {
|
||||
private final UserDefinedType delegate;
|
||||
|
||||
private UserDefinedTypeWrapper(UserDefinedType delegate) {
|
||||
this.delegate = delegate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void attach(@NonNull AttachmentPoint attachmentPoint) {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public CqlIdentifier getKeyspace() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public CqlIdentifier getName() {
|
||||
return delegate.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFrozen() {
|
||||
return delegate.isFrozen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDetached() {
|
||||
return delegate.isDetached();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public List<CqlIdentifier> getFieldNames() {
|
||||
return delegate.getFieldNames();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int firstIndexOf(CqlIdentifier id) {
|
||||
return delegate.firstIndexOf(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int firstIndexOf(String name) {
|
||||
return delegate.firstIndexOf(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public List<DataType> getFieldTypes() {
|
||||
return delegate.getFieldTypes();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public UserDefinedType copy(boolean newFrozen) {
|
||||
return new UserDefinedTypeWrapper(delegate.copy(newFrozen));
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public UdtValue newValue() {
|
||||
return delegate.newValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public UdtValue newValue(@NonNull Object... fields) {
|
||||
return delegate.newValue(fields);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return delegate.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(@Nullable Object obj) {
|
||||
return super.equals(obj) || delegate.equals(obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public AttachmentPoint getAttachmentPoint() {
|
||||
return delegate.getAttachmentPoint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuffer sb = new StringBuffer();
|
||||
sb.append(getClass().getSimpleName());
|
||||
sb.append(" [delegate=").append(delegate);
|
||||
sb.append(']');
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user