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 add objects on eagerly fetched associations #55

Closed
mburak opened this issue Jun 26, 2017 · 2 comments
Closed

Cannot add objects on eagerly fetched associations #55

mburak opened this issue Jun 26, 2017 · 2 comments
Assignees

Comments

@mburak
Copy link
Contributor

mburak commented Jun 26, 2017

Having an association like this:

class Player extends AbstractGraphDomain {

    String name
    List<Club> formerClubs = []

    static hasMany = [formerClubs: Club]

    static mapping = {
        formerClubs lazy: false, fetch: "eager"
    }

}

when we try to add a new object to the association we get this:

java.lang.reflect.InvocationTargetException: null
        at org.grails.core.DefaultGrailsControllerClass$ReflectionInvoker.invoke(DefaultGrailsControllerClass.java:211)
        at org.grails.core.DefaultGrailsControllerClass.invoke(DefaultGrailsControllerClass.java:188)
        at org.grails.web.mapping.mvc.UrlMappingsInfoHandlerAdapter.handle(UrlMappingsInfoHandlerAdapter.groovy:90)
        at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:963)
        at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:897)
        at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:970)
        at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:861)
        at org.springframework.web.servlet.FrameworkServlet.service(FrameworkServlet.java:846)
        at org.springframework.boot.web.filter.ApplicationContextHeaderFilter.doFilterInternal(ApplicationContextHeaderFilter.java:55)
        at org.grails.web.servlet.mvc.GrailsWebRequestFilter.doFilterInternal(GrailsWebRequestFilter.java:77)
        at org.grails.web.filters.HiddenHttpMethodFilter.doFilterInternal(HiddenHttpMethodFilter.java:67)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
        at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsupportedOperationException: null
        at java.util.AbstractList.add(AbstractList.java:148)
        at java.util.AbstractList.add(AbstractList.java:108)
        at org.grails.datastore.mapping.dirty.checking.DirtyCheckingCollection.add(DirtyCheckingCollection.groovy:52)
        at org.grails.datastore.gorm.neo4j.collection.Neo4jList.add(Neo4jList.groovy:59)
        at org.sampleapp.core.PlayerController.$tt__updatePlayer4(PlayerController.groovy:68)
        at grails.transaction.GrailsTransactionTemplate$2.doInTransaction(GrailsTransactionTemplate.groovy:96)
        at org.springframework.transaction.support.TransactionTemplate.execute(TransactionTemplate.java:133)
        at grails.transaction.GrailsTransactionTemplate.execute(GrailsTransactionTemplate.groovy:93)
        ... 14 common frames omitted

You can reproduce this by downloading the project at https://github.com/mburak/sampleapp and checking out branch called 'assoc-error'.
#1. Start the project on an empty db
#2. Do an ajax call to http://localhost:8080/player/updatePlayer4

@mburak mburak changed the title Cannot add objects on eager associations Cannot add objects on eagerly fetched associations Jun 26, 2017
@jameskleeh
Copy link
Contributor

jameskleeh commented Aug 2, 2017

@mburak When I run your example application with an embedded neo4j, I get org.neo4j.driver.v1.exceptions.ClientException: Unable to convert org.sampleapp.core.Club to Neo4j Value.

Edit: That was because the club assocation on Player was commented out

@jameskleeh
Copy link
Contributor

@mburak I'm unable to reproduce the issue because the URL you indicated to execute returns 404. There are no controllers in the example application

@jameskleeh jameskleeh self-assigned this Aug 2, 2017
@graemerocher graemerocher self-assigned this Aug 14, 2017
graemerocher added a commit that referenced this issue Aug 14, 2017
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

3 participants