Skip to content

Commit 0acafe7

Browse files
committed
oops, I forgot to add the object wrapper around serialized json from the pojo facade
1 parent b90e802 commit 0acafe7

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

src/main/java/com/marklogic/client/impl/PojoPageImpl.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
import java.util.Iterator;
44

5+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
6+
import com.fasterxml.jackson.databind.ObjectMapper;
57
import com.marklogic.client.Page;
68
import com.marklogic.client.impl.BasicPage;
79
import com.marklogic.client.io.JacksonPojoHandle;
@@ -34,7 +36,9 @@ public boolean hasNext() {
3436

3537
@Override
3638
public T next() {
37-
return docPage.nextContent(new JacksonPojoHandle<T>(entityClass)).get();
39+
JacksonPojoHandle<T> handle = new JacksonPojoHandle<T>(entityClass);
40+
handle.getMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
41+
return docPage.nextContent(handle).get();
3842
}
3943

4044
@Override

src/main/java/com/marklogic/client/impl/PojoRepositoryImpl.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
import com.marklogic.client.query.QueryManager.QueryView;
2020
import com.marklogic.client.query.StructuredQueryDefinition;
2121

22+
import com.fasterxml.jackson.annotation.JsonTypeInfo;
23+
import com.fasterxml.jackson.databind.ObjectMapper;
24+
2225
import java.io.Serializable;
2326
import java.io.UnsupportedEncodingException;
2427
import java.lang.reflect.Method;
@@ -73,6 +76,7 @@ public void write(T entity, Transaction transaction) {
7376
public void write(T entity, Transaction transaction, String... collections) {
7477
if ( entity == null ) return;
7578
JacksonPojoHandle contentHandle = new JacksonPojoHandle(entity);
79+
contentHandle.getMapper().enableDefaultTyping(ObjectMapper.DefaultTyping.NON_FINAL, JsonTypeInfo.As.WRAPPER_OBJECT);
7680
DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
7781
metadataHandle = metadataHandle.withCollections(entityClass.getName());
7882
if ( collections != null && collections.length > 0 ) {

0 commit comments

Comments
 (0)