spring-attic / grails-data-mapping

Grails Data Mapping Project
Apache License 2.0
151 stars 95 forks source link

hasMany doesn't support more than 20 records #135

Closed cwhd closed 10 years ago

cwhd commented 11 years ago

I have an object with a hasMany relationship to another object. When there are more than 20 of the child object and i try to save the object i get this error:

AWS Error Code: InvalidNumberValueTests, AWS Error Message: Too many value tests per predicate in the query expression.

i tried to set the batchSize to 20 like this: teamMembers lazy: false, batchSize: 15 but it doesn't seem to do anything.

and when i try to turn on SQL logging in the datasource.config i don't see any SQL in the logs so i'm not sure what is happening.

This seems to work fine on load, i'm only having the problem on save. I think it's trying to create a giant IN statement but i'm not sure how to get around that.

rstepanenko commented 11 years ago

Hi,

I think this is exactly what is happening.

There is no sql logging because this is NoSQL and there is no logging library that we use in the grails-data plugins (I suspect in order not to impose any on the end user)

Unfortunately I can't find time to investigate this issue. Can you split your data in two or more collections instead of one?

cwhd commented 11 years ago

i ended up getting around the issue by doing a query instead of relying on the relationship between objects. If you can point me to the code i can try to get in a pull request for you.

sonnerj commented 10 years ago

I ran into this issue too..

There is a clever workaround to increase the maximum comparisons per IN predicate ('hasMany' relationships) to 400 described here: http://stackoverflow.com/questions/3420360/amazon-simpledb-query-to-find-post-by-friends

Here is a stacktrace: Caused by: com.amazonaws.services.simpledb.model.InvalidNumberValueTestsException: Status Code: 400, AWS Service: AmazonSimpleDB, AWS Request ID: ***, AWS Error Code: InvalidNumberValueTests, AWS Error Message: Too many value tests per predicate in the query expression. at com.amazonaws.http.AmazonHttpClient.handleErrorResponse(AmazonHttpClient.java:767) ~[aws-java-sdk-1.6.12.jar:na] at com.amazonaws.http.AmazonHttpClient.executeHelper(AmazonHttpClient.java:414) ~[aws-java-sdk-1.6.12.jar:na] at com.amazonaws.http.AmazonHttpClient.execute(AmazonHttpClient.java:228) ~[aws-java-sdk-1.6.12.jar:na] at com.amazonaws.services.simpledb.AmazonSimpleDBClient.invoke(AmazonSimpleDBClient.java:925) ~[aws-java-sdk-1.6.12.jar:na] at com.amazonaws.services.simpledb.AmazonSimpleDBClient.select(AmazonSimpleDBClient.java:291) ~[aws-java-sdk-1.6.12.jar:na] at org.grails.datastore.mapping.simpledb.util.SimpleDBTemplateImpl.queryInternal(SimpleDBTemplateImpl.java:252) ~[grails-datastore-simpledb-0.5.jar:na] at org.grails.datastore.mapping.simpledb.util.SimpleDBTemplateImpl.query(SimpleDBTemplateImpl.java:246) ~[grails-datastore-simpledb-0.5.jar:na] at org.grails.datastore.mapping.simpledb.query.SimpleDBQuery.executeQuery(SimpleDBQuery.java:210) ~[grails-datastore-simpledb-0.5.jar:na] at org.grails.datastore.mapping.query.Query.list(Query.java:509) ~[grails-datastore-core-1.1.8.RELEASE.jar:na] at org.grails.datastore.mapping.simpledb.engine.SimpleDBEntityPersister.retrieveAllEntities(SimpleDBEntityPersister.java:115) ~[grails-datastore-simpledb-0.5.jar:na] at org.grails.datastore.mapping.engine.EntityPersister.retrieveAll(EntityPersister.java:140) ~[grails-datastore-core-1.1.8.RELEASE.jar:na] at org.grails.datastore.mapping.core.AbstractSession.retrieveAll(AbstractSession.java:670) ~[grails-datastore-core-1.1.8.RELEASE.jar:na] at org.grails.datastore.mapping.collection.AbstractPersistentCollection.initialize(AbstractPersistentCollection.java:213) ~[grails-datastore-core-1.1.8.RELEASE.jar:na] at org.grails.datastore.mapping.collection.AbstractPersistentCollection.toArray(AbstractPersistentCollection.java:155) ~[grails-datastore-core-1.1.8.RELEASE.jar:na] at java.util.Collections.sort(Collections.java:216) ~[na:1.7.0_45]