Skip to content

Commit 345af53

Browse files
authored
Pass source as parent when reading subobject. (#1222)
Closes #1221. Co-authored-by: mikereiche <michael.reiche@couchbase.com>
1 parent da3e8e0 commit 345af53

File tree

3 files changed

+21
-16
lines changed

3 files changed

+21
-16
lines changed

src/main/java/org/springframework/data/couchbase/core/convert/MappingCouchbaseConverter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -954,7 +954,7 @@ public <R> R getPropertyValue(final CouchbasePersistentProperty property) {
954954
return null;
955955
}
956956

957-
return readValue(value, property.getTypeInformation(), parent);
957+
return readValue(value, property.getTypeInformation(), source);
958958
}
959959
}
960960

src/test/java/org/springframework/data/couchbase/repository/CouchbaseRepositoryQueryIntegrationTests.java

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
import java.util.concurrent.Future;
4141
import java.util.stream.Collectors;
4242

43-
import org.junit.jupiter.api.BeforeEach;
4443
import org.junit.jupiter.api.Test;
4544
import org.springframework.beans.factory.annotation.Autowired;
4645
import org.springframework.context.annotation.Bean;
@@ -92,8 +91,6 @@
9291
import com.couchbase.client.java.kv.GetResult;
9392
import com.couchbase.client.java.kv.MutationState;
9493
import com.couchbase.client.java.kv.UpsertOptions;
95-
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
96-
import com.couchbase.client.java.manager.query.CreateQueryIndexOptions;
9794
import com.couchbase.client.java.query.QueryOptions;
9895
import com.couchbase.client.java.query.QueryScanConsistency;
9996

@@ -121,18 +118,6 @@ public class CouchbaseRepositoryQueryIntegrationTests extends ClusterAwareIntegr
121118
String scopeName = "_default";
122119
String collectionName = "_default";
123120

124-
@BeforeEach
125-
public void beforeEach() {
126-
clientFactory.getCluster().queryIndexes().createPrimaryIndex(bucketName(),
127-
CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions().ignoreIfExists(true));
128-
// this is for the N1qlJoin test
129-
List<String> fieldList = new ArrayList<>();
130-
fieldList.add("parentId");
131-
clientFactory.getCluster().queryIndexes().createIndex(bucketName(), "parent_idx", fieldList,
132-
CreateQueryIndexOptions.createQueryIndexOptions().ignoreIfExists(true));
133-
// .with("_class", "org.springframework.data.couchbase.domain.Address"));
134-
}
135-
136121
@Test
137122
void shouldSaveAndFindAll() {
138123
Airport vie = null;

src/test/java/org/springframework/data/couchbase/util/ClusterAwareIntegrationTests.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616
package org.springframework.data.couchbase.util;
1717

18+
import java.io.IOException;
1819
import java.lang.annotation.Annotation;
1920
import java.lang.reflect.InvocationTargetException;
2021
import java.lang.reflect.Method;
22+
import java.util.ArrayList;
23+
import java.util.List;
2124
import java.util.Optional;
2225
import java.util.Set;
2326
import java.util.stream.Collectors;
@@ -27,10 +30,14 @@
2730
import org.junit.jupiter.api.BeforeAll;
2831
import org.junit.jupiter.api.BeforeEach;
2932
import org.junit.jupiter.api.extension.ExtendWith;
33+
import org.springframework.data.couchbase.CouchbaseClientFactory;
34+
import org.springframework.data.couchbase.SimpleCouchbaseClientFactory;
3035

3136
import com.couchbase.client.core.env.Authenticator;
3237
import com.couchbase.client.core.env.PasswordAuthenticator;
3338
import com.couchbase.client.core.env.SeedNode;
39+
import com.couchbase.client.java.manager.query.CreatePrimaryQueryIndexOptions;
40+
import com.couchbase.client.java.manager.query.CreateQueryIndexOptions;
3441

3542
/**
3643
* Parent class which drives all dynamic integration tests based on the configured cluster setup.
@@ -45,6 +52,19 @@ public abstract class ClusterAwareIntegrationTests {
4552
@BeforeAll
4653
static void setup(TestClusterConfig config) {
4754
testClusterConfig = config;
55+
try (CouchbaseClientFactory couchbaseClientFactory = new SimpleCouchbaseClientFactory(connectionString(),
56+
authenticator(), bucketName())) {
57+
couchbaseClientFactory.getCluster().queryIndexes().createPrimaryIndex(bucketName(),
58+
CreatePrimaryQueryIndexOptions.createPrimaryQueryIndexOptions().ignoreIfExists(true));
59+
// this is for the N1qlJoin test
60+
List<String> fieldList = new ArrayList<>();
61+
fieldList.add("parentId");
62+
couchbaseClientFactory.getCluster().queryIndexes().createIndex(bucketName(), "parent_idx", fieldList,
63+
CreateQueryIndexOptions.createQueryIndexOptions().ignoreIfExists(true));
64+
// .with("_class", "org.springframework.data.couchbase.domain.Address"));
65+
} catch (IOException ioe) {
66+
throw new RuntimeException(ioe);
67+
}
4868
}
4969

5070
/**

0 commit comments

Comments
 (0)