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

RuntimeException for query methods with fields declaration and Pageable parameters [DATAMONGO-1500] #2412

Closed
spring-projects-issues opened this issue Sep 28, 2016 · 0 comments
Assignees
Labels
in: mapping in: repository type: bug

Comments

@spring-projects-issues
Copy link

@spring-projects-issues spring-projects-issues commented Sep 28, 2016

yami.veranes opened DATAMONGO-1500 and commented

When I upgrade from version 1.8.4.RELEASE to 1.9.3.RELEASE, I have some problems with serialization of DBRef and Enum

@Query(fields = "{ 'text' : 0, 'statistics' : 0}")
Page<DocumentManualRevision> findByRevisor(User revisor, Pageable p);

the execution of the previous function (where revisor is a dbref of other collection) return the following exception

java.lang.RuntimeException: json can't serialize type : class database.models.security.User
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79)
	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:323)
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:82)
	at com.mongodb.util.JSON.serialize(JSON.java:53)
	at com.mongodb.util.JSON.serialize(JSON.java:39)
	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:196)
	at org.springframework.data.mongodb.repository.query.PartTreeMongoQuery.createQuery(PartTreeMongoQuery.java:113)
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:81)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:460)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.data.projection.DefaultMethodInvokingMethodInterceptor.invoke(DefaultMethodInvokingMethodInterceptor.java:61)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:92)
	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:179)
	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:213)
	at com.sun.proxy.$Proxy56.findByRevisorAndCreatedBetween(Unknown Source)
@Query(fields = "{ 'text' : 0, 'statistics' : 0}")
Page<DocumentManualRevision> findByState(State state, Pageable p)

the execution of the previous function (where state is enum) return the following exception

java.lang.RuntimeException: json can't serialize type : class database.models.revision.DocumentManualRevision$State

	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:79)
	at com.mongodb.util.JSONSerializers$MapSerializer.serialize(JSONSerializers.java:323)
	at com.mongodb.util.ClassMapBasedObjectSerializer.serialize(ClassMapBasedObjectSerializer.java:82)
	at com.mongodb.util.JSON.serialize(JSON.java:53)
	at com.mongodb.util.JSON.serialize(JSON.java:39)
	at com.mongodb.BasicDBObject.toString(BasicDBObject.java:196)
	at org.springframework.data.mongodb.repository.query.PartTreeMongoQuery.createQuery(PartTreeMongoQuery.java:113)
	at org.springframework.data.mongodb.repository.query.AbstractMongoQuery.execute(AbstractMongoQuery.java:81)
	at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.doInvoke(RepositoryFactorySupport.java:482)

Affects: 1.9.3 (Hopper SR3)

Referenced from: pull request #404

Backported to: 1.9.5 (Hopper SR5)

@spring-projects-issues spring-projects-issues added type: bug in: repository in: mapping labels Dec 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: mapping in: repository type: bug
Projects
None yet
Development

No branches or pull requests

2 participants