Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot use Map with 7.0.0-pr6 #3096

Open
manosbatsis opened this issue Oct 18, 2023 · 2 comments
Open

Cannot use Map with 7.0.0-pr6 #3096

manosbatsis opened this issue Oct 18, 2023 · 2 comments

Comments

@manosbatsis
Copy link

This works (kotlin):


@OneToMany(mappedBy = "account")
 val reserves: List<Reserve> = emptyList()

But this:

@MapKey(name = "currency")
@OneToMany(mappedBy = "account")
val reserves: MutableMap<String, Reserve> = mutableMapOf()

Results in error:

java.lang.IllegalArgumentException: Unbound Entity ClassType{cls=class java.lang.String}
        at com.yahoo.elide.core.dictionary.EntityDictionary.lookupEntityClass(EntityDictionary.java:1363) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.core.dictionary.EntityDictionary.getEntityBinding(EntityDictionary.java:288) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.core.dictionary.EntityDictionary.getJsonAliasFor(EntityDictionary.java:330) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.core.RequestScope.getExpressionForRelation(RequestScope.java:306) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.jsonapi.EntityProjectionMaker.lambda$getSparseRelationships$11(EntityProjectionMaker.java:394) ~[elide-core-7.0.0-pr6.jar:na]
        at java.base/java.util.stream.Collectors.lambda$uniqKeysMapAccumulator$1(Collectors.java:180) ~[na:na]
        at java.base/java.util.stream.ReduceOps$3ReducingSink.accept(ReduceOps.java:169) ~[na:na]
        at java.base/java.util.Iterator.forEachRemaining(Iterator.java:133) ~[na:na]
        at java.base/java.util.Spliterators$IteratorSpliterator.forEachRemaining(Spliterators.java:1845) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:509) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:499) ~[na:na]
        at java.base/java.util.stream.ReduceOps$ReduceOp.evaluateSequential(ReduceOps.java:921) ~[na:na]
        at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
        at java.base/java.util.stream.ReferencePipeline.collect(ReferencePipeline.java:682) ~[na:na]
        at com.yahoo.elide.jsonapi.EntityProjectionMaker.getSparseRelationships(EntityProjectionMaker.java:391) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.jsonapi.EntityProjectionMaker.getRequiredRelationships(EntityProjectionMaker.java:421) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.jsonapi.EntityProjectionMaker.lambda$visitTerminalCollection$6(EntityProjectionMaker.java:290) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.jsonapi.EntityProjectionMaker.parsePath(EntityProjectionMaker.java:74) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.Elide.lambda$post$2(Elide.java:329) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.Elide.handleRequest(Elide.java:596) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.Elide.post(Elide.java:324) ~[elide-core-7.0.0-pr6.jar:na]
        at com.yahoo.elide.spring.controllers.JsonApiController$2.call(JsonApiController.java:107) ~[elide-spring-boot-autoconfigure-7.0.0-pr6.jar:na]
        at com.yahoo.elide.spring.controllers.JsonApiController$2.call(JsonApiController.java:104) ~[elide-spring-boot-autoconfigure-7.0.0-pr6.jar:na]
  • Elide version used: Elide 7.0.0-pr6 (spring boot starter)
  • Environment name and version:
    - OpenJDK Runtime Environment (build 17.0.8.1+1-Ubuntu-0ubuntu122.04)
    - Kotlin 1.8.10
    - Spring 6.0.9
    - Spring Boot 3.1.0
@aklish
Copy link
Member

aklish commented Nov 10, 2023

Elide doesn't support maps as relationships because JSON-API doesn't have a similar concept.

@manosbatsis
Copy link
Author

Hey @aklish , thanks for the reply. Actually when a @MapKey is present, Elide can simply treat the example as if it where:

@OneToMany(mappedBy = "account")
val reserves: MutableList<Reserve> = mutableListOf()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants