eclipse / jnosql

Eclipse JNoSQL is a framework which has the goal to help Java developers to create Jakarta EE applications with NoSQL.
Other
231 stars 72 forks source link

[BUG] Embeddable list of nested object cannot be saved #460

Closed m4ttek closed 11 months ago

m4ttek commented 11 months ago

Which JNoSQL project the issue refers to?

JNoSQL (Core)

Bug description

There seems to be a problem with a list of nested objects in an Entity; image

A list is treated as a single document? It worked well on 1.0.2 version.

JNoSQL Version

1.0.3

Steps To Reproduce

  1. Create an entity
  2. Create an embeddable entity
  3. Use an embeddable entity in main entity within a collection of objects.
  4. Try to save this entity.

Expected Results

No response

Code example, screenshot, or link to a repository

No response

otaviojava commented 11 months ago

@m4ttek could you give an entity sample to test and create a test scenario? I don't remember that we changed that part, but with test, we can guarantee the regression.

m4ttek commented 11 months ago

Yes, it isn't even a test scenario, but a test initialization ;)

There is a main entity which contains nested availableTransitions:

import com.arangodb.serde.InternalId;
import com.arangodb.serde.InternalKey;
import jakarta.annotation.Nullable;
import jakarta.nosql.Column;
import jakarta.nosql.Entity;
import jakarta.nosql.Id;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import pl.sages.ssop.workflow.domain.component.ComponentType;
import pl.sages.ssop.workflow.domain.transition.Transition;
import pl.sages.ssop.workflow.infrastructure.database.index.Index;

@Builder
@Entity(COLLECTION_NAME)
@Data
@NoArgsConstructor
@AllArgsConstructor
public final class WorkflowStep {

    public static final String COLLECTION_NAME = "workflow_steps";

    @InternalId
    @Id
    private String id;
    @InternalKey
    @Column("_key")
    private String key;

    @Column
    @NotNull
    @Index
    private String workflowSchemaKey;

    @Column
    @NotNull
    private String stepName;

    @Column
    @NotNull
    private MainStepType mainStepType;

    @Column
    @Nullable
    private Integer stepNo;

    @Column
    @Nullable
    private ComponentType componentName;

    @Column
    @Nullable
    @Index
    private String componentConfigurationKey;

    @Column
    @Nullable
    @Index
    private String relationTypeKey;

    @Column
    @Nullable
    private List<Transition> availableTransitions;
}

There is a Transition embeddable entity:

import jakarta.annotation.Nullable;
import jakarta.nosql.Column;
import jakarta.validation.constraints.NotNull;
import java.util.List;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.eclipse.jnosql.mapping.Embeddable;

@Embeddable
@Data
@NoArgsConstructor
@AllArgsConstructor
public final class Transition {

    @Column
    @NotNull
    private String targetWorkflowStepKey;
    @Column
    @NotNull
    private StepTransitionReason stepTransitionReason;
    @Column
    @Nullable
    private String mailTemplateKey;
    @Column
    @NotNull
    private List<String> restrictedRoleGroups;
}

and there is my method which tries to initalize collection with example entity:

    @BeforeEach
    void saveTestingStep(SeContainer seContainer) {
        var workflowStep = WorkflowStep.builder()
                .key(TEST_WORKFLOW_STEP_KEY)
                .workflowSchemaKey(TEST_WORKFLOW_SCHEMA_KEY)
                .mainStepType(MainStepType.ENTRY)
                .stepNo(1)
                .availableTransitions(List.of(new Transition(TEST_WORKFLOW_STEP_KEY, REPEAT, null, List.of("ADMIN"))))
                .build();
        this.testWorkflowStep = seContainer.select(WorkflowStepRepository.class).get().save(workflowStep);
    }
otaviojava commented 11 months ago

hum, that might be related with allow null values. Anyway I will work on it.

otaviojava commented 11 months ago

@m4ttek could you give the stack trace?

I also created the entity for the test: Could you check if that is your entity: https://github.com/eclipse/jnosql/pull/461

I cannot reproduce your issues.

m4ttek commented 11 months ago

It looks quite the same. I've implemented my own Index annotation for the sake of creating indexes in arango as Jakarta Data does not provide one similar to JPA Index annotation.

Additionally, I'm using Bean Validation dependency:

implementation("io.helidon.microprofile.bean-validation:helidon-microprofile-bean-validation")

The stack trace I get is as follows:

java.lang.NullPointerException
    at java.base/java.util.Objects.requireNonNull(Objects.java:233)
    at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180)
    at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at org.eclipse.jnosql.databases.arangodb.communication.ArangoDBUtil.getMap(ArangoDBUtil.java:154)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1708)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682)
    at org.eclipse.jnosql.databases.arangodb.communication.ArangoDBUtil.convert(ArangoDBUtil.java:147)
    at org.eclipse.jnosql.databases.arangodb.communication.ArangoDBUtil.getBaseDocument(ArangoDBUtil.java:105)
    at org.eclipse.jnosql.databases.arangodb.communication.DefaultArangoDBDocumentManager.insert(DefaultArangoDBDocumentManager.java:66)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.lambda$new$0(AbstractDocumentTemplate.java:65)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.persist(AbstractDocumentTemplate.java:271)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.insert(AbstractDocumentTemplate.java:82)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
    at org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBTemplate$_$$_WeldClientProxy.insert(Unknown Source)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepository.save(AbstractDocumentRepository.java:56)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.lambda$invoke$0(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.unwrapInvocationTargetException(AbstractDocumentRepositoryProxy.java:100)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.invoke(AbstractDocumentRepositoryProxy.java:51)
    at jdk.proxy3/jdk.proxy3.$Proxy159.save(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.lambda$invoke$0(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.unwrapInvocationTargetException(AbstractDocumentRepositoryProxy.java:100)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.invoke(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBDocumentRepositoryProxy.invoke(ArangoDBDocumentRepositoryProxy.java:106)
    at jdk.proxy3/jdk.proxy3.$Proxy159.save(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
    at pl.sages.ssop.workflow.infrastructure.repositories.WorkflowStepRepository$_$$_WeldClientProxy.save(Unknown Source)
    at pl.sages.ssop.workflow.application.api.step.WorkflowStepResourceTest.saveTestingStep(WorkflowStepResourceTest.java:236)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.junit.platform.commons.util.ReflectionUtils.invokeMethod(ReflectionUtils.java:727)
    at org.junit.jupiter.engine.execution.MethodInvocation.proceed(MethodInvocation.java:60)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$ValidatingInvocation.proceed(InvocationInterceptorChain.java:131)
    at org.junit.jupiter.api.extension.InvocationInterceptor.interceptBeforeEachMethod(InvocationInterceptor.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.extension.TimeoutExtension.intercept(TimeoutExtension.java:156)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptLifecycleMethod(TimeoutExtension.java:128)
    at org.junit.jupiter.engine.extension.TimeoutExtension.interceptBeforeEachMethod(TimeoutExtension.java:78)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker$ReflectiveInterceptorCall.lambda$ofVoidMethod$0(InterceptingExecutableInvoker.java:103)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.lambda$invoke$0(InterceptingExecutableInvoker.java:93)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain$InterceptedInvocation.proceed(InvocationInterceptorChain.java:106)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.proceed(InvocationInterceptorChain.java:64)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.chainAndInvoke(InvocationInterceptorChain.java:45)
    at org.junit.jupiter.engine.execution.InvocationInterceptorChain.invoke(InvocationInterceptorChain.java:37)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:92)
    at org.junit.jupiter.engine.execution.InterceptingExecutableInvoker.invoke(InterceptingExecutableInvoker.java:86)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.invokeMethodInExtensionContext(ClassBasedTestDescriptor.java:520)
    at org.junit.jupiter.engine.descriptor.ClassBasedTestDescriptor.lambda$synthesizeBeforeEachMethodAdapter$23(ClassBasedTestDescriptor.java:505)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachMethods$3(TestMethodTestDescriptor.java:174)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:202)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:202)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachMethods(TestMethodTestDescriptor.java:171)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:134)
    at org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:68)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.invokeAll(SameThreadHierarchicalTestExecutorService.java:41)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at org.junit.platform.engine.support.hierarchical.SameThreadHierarchicalTestExecutorService.submit(SameThreadHierarchicalTestExecutorService.java:35)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestExecutor.execute(HierarchicalTestExecutor.java:57)
    at org.junit.platform.engine.support.hierarchical.HierarchicalTestEngine.execute(HierarchicalTestEngine.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:107)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:88)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.lambda$execute$0(EngineExecutionOrchestrator.java:54)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.withInterceptedStreams(EngineExecutionOrchestrator.java:67)
    at org.junit.platform.launcher.core.EngineExecutionOrchestrator.execute(EngineExecutionOrchestrator.java:52)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:114)
    at org.junit.platform.launcher.core.DefaultLauncher.execute(DefaultLauncher.java:86)
    at org.junit.platform.launcher.core.DefaultLauncherSession$DelegatingLauncher.execute(DefaultLauncherSession.java:86)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.processAllTestClasses(JUnitPlatformTestClassProcessor.java:119)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor$CollectAllTestClassesExecutor.access$000(JUnitPlatformTestClassProcessor.java:94)
    at org.gradle.api.internal.tasks.testing.junitplatform.JUnitPlatformTestClassProcessor.stop(JUnitPlatformTestClassProcessor.java:89)
    at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.stop(SuiteTestClassProcessor.java:62)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:36)
    at org.gradle.internal.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
    at org.gradle.internal.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:33)
    at org.gradle.internal.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:94)
    at jdk.proxy1/jdk.proxy1.$Proxy2.stop(Unknown Source)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker$3.run(TestWorker.java:193)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.executeAndMaintainThreadName(TestWorker.java:129)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:100)
    at org.gradle.api.internal.tasks.testing.worker.TestWorker.execute(TestWorker.java:60)
    at org.gradle.process.internal.worker.child.ActionExecutionWorker.execute(ActionExecutionWorker.java:56)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:113)
    at org.gradle.process.internal.worker.child.SystemApplicationClassLoaderWorker.call(SystemApplicationClassLoaderWorker.java:65)
otaviojava commented 11 months ago

Thank you, this is at the arangoDB driver side, I will create a code to that side.

otaviojava commented 11 months ago

Thank you. I updated the structure to allow null values,; we can use it:

https://github.com/eclipse/jnosql-databases/pull/255/files

otaviojava commented 11 months ago

This seams a critical bug, @m4ttek could you test the snapshot version? If yes, I will release a new version with this fix.

m4ttek commented 11 months ago

Ok, unfortunately, there is another test case failing:

        var secondWorkflowStep = WorkflowStep.builder()
                .workflowSchemaKey(TEST_WORKFLOW_SCHEMA_KEY)
                .stepName("Second testing step")
                .stepNo(null)
                .mainStepType(MainStepType.IN_PROGRESS)
                .build();
        secondWorkflowStep = workflowStepRepository.save(secondWorkflowStep);

It looks like it doesn't handle nullable embeddable lists properly:

WARNING: Internal server error
java.lang.NullPointerException: Cannot invoke "java.util.List.iterator()" because "embeddable" is null
    at org.eclipse.jnosql.mapping.document.FieldConverter$3.convert(FieldConverter.java:89)
    at org.eclipse.jnosql.mapping.document.DocumentEntityConverter.lambda$feedObject$5(DocumentEntityConverter.java:158)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:184)
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:179)
    at java.base/java.util.HashMap$KeySpliterator.forEachRemaining(HashMap.java:1715)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:596)
    at org.eclipse.jnosql.mapping.document.DocumentEntityConverter.convertEntity(DocumentEntityConverter.java:221)
    at org.eclipse.jnosql.mapping.document.DocumentEntityConverter.toEntity(DocumentEntityConverter.java:106)
    at org.eclipse.jnosql.mapping.document.DefaultDocumentEntityConverter$Proxy$_$$_WeldClientProxy.toEntity(Unknown Source)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.lambda$persist$8(AbstractDocumentTemplate.java:269)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.persist(AbstractDocumentTemplate.java:271)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.insert(AbstractDocumentTemplate.java:82)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
otaviojava commented 11 months ago

Yeap, now we need to whole cases for nullable values.

otaviojava commented 11 months ago

Thank you, @m4ttek please test and give me more cases.

m4ttek commented 11 months ago

@otaviojava I've tested the new version, and now we have another problem. It seems like I cannot insert a new record without providing the key explicitly.

Test case is the same:

        var secondWorkflowStep = WorkflowStep.builder()
                .workflowSchemaKey(TEST_WORKFLOW_SCHEMA_KEY)
                .stepName("Second testing step")
                .stepNo(null)
                .mainStepType(MainStepType.IN_PROGRESS)
                .build();
        secondWorkflowStep = workflowStepRepository.save(secondWorkflowStep);

And it ends with the following exception and stack trace:

com.arangodb.ArangoDBException: Response: 400, Error: 1221 - illegal document key
    at com.arangodb.ArangoDBException.of(ArangoDBException.java:137)
    at com.arangodb.ArangoDBException.of(ArangoDBException.java:111)
    at com.arangodb.ArangoDBException.of(ArangoDBException.java:107)
    at com.arangodb.internal.net.CommunicationProtocol.execute(CommunicationProtocol.java:43)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:55)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:43)
    at com.arangodb.internal.ArangoExecutorSync.execute(ArangoExecutorSync.java:39)
    at com.arangodb.internal.ArangoCollectionImpl.insertDocument(ArangoCollectionImpl.java:55)
    at org.eclipse.jnosql.databases.arangodb.communication.DefaultArangoDBDocumentManager.insert(DefaultArangoDBDocumentManager.java:68)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.lambda$new$0(AbstractDocumentTemplate.java:65)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:197)
    at java.base/java.util.stream.Streams$StreamBuilderImpl.tryAdvance(Streams.java:397)
    at java.base/java.util.stream.ReferencePipeline.forEachWithCancel(ReferencePipeline.java:129)
    at java.base/java.util.stream.AbstractPipeline.copyIntoWithCancel(AbstractPipeline.java:527)
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:513)
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499)
    at java.base/java.util.stream.FindOps$FindOp.evaluateSequential(FindOps.java:150)
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
    at java.base/java.util.stream.ReferencePipeline.findFirst(ReferencePipeline.java:647)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.persist(AbstractDocumentTemplate.java:271)
    at org.eclipse.jnosql.mapping.document.AbstractDocumentTemplate.insert(AbstractDocumentTemplate.java:82)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
    at org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBTemplate$_$$_WeldClientProxy.insert(Unknown Source)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepository.save(AbstractDocumentRepository.java:56)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.lambda$invoke$0(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.unwrapInvocationTargetException(AbstractDocumentRepositoryProxy.java:100)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.invoke(AbstractDocumentRepositoryProxy.java:51)
    at jdk.proxy3/jdk.proxy3.$Proxy159.save(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.lambda$invoke$0(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.unwrapInvocationTargetException(AbstractDocumentRepositoryProxy.java:100)
    at org.eclipse.jnosql.mapping.document.query.AbstractDocumentRepositoryProxy.invoke(AbstractDocumentRepositoryProxy.java:51)
    at org.eclipse.jnosql.databases.arangodb.mapping.ArangoDBDocumentRepositoryProxy.invoke(ArangoDBDocumentRepositoryProxy.java:106)
    at jdk.proxy3/jdk.proxy3.$Proxy159.save(Unknown Source)
    at java.base/jdk.internal.reflect.DirectMethodHandleAccessor.invoke(DirectMethodHandleAccessor.java:103)
    at java.base/java.lang.reflect.Method.invoke(Method.java:580)
    at org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:38)
    at org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:106)
    at pl.sages.ssop.workflow.infrastructure.repositories.WorkflowStepRepository$_$$_WeldClientProxy.save(Unknown Source)
otaviojava commented 11 months ago

Thank you, please, check if there is any more null variation to break your code.

m4ttek commented 11 months ago

@otaviojava I've checked the latest version and it seems to be working now :)

otaviojava commented 11 months ago

Thank you!!!

otaviojava commented 11 months ago

Closing once we fixed this one.