I get an error saying the class can't be serialized (see exception below).
But I noticed the error only happens when the log level is set to DEBUG, when a line in MongoTemplate.java attempts to add the Query to a debug message. The serialization error is then triggered by toString() of BasicDBObject. The exception thrown is:
java.lang.RuntimeException: json can't serialize type : class au.org.aurin.workflow.datamodel.ComponentType
at com.mongodb.util.JSON.serialize(JSON.java:261)
at com.mongodb.util.JSON.serialize(JSON.java:141)
at com.mongodb.util.JSON.serialize(JSON.java:58)
at com.mongodb.BasicDBObject.toString(BasicDBObject.java:84)
at java.lang.String.valueOf(String.java:2902)
at java.lang.StringBuilder.append(StringBuilder.java:128)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1241)
at org.springframework.data.mongodb.core.MongoTemplate.doFind(MongoTemplate.java:1233)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:471)
at org.springframework.data.mongodb.core.MongoTemplate.find(MongoTemplate.java:466)
at au.org.aurin.workflow.persistence.ComponentRepository.getByType(ComponentRepository.java:42)
When log level is set to INFO, the problem doesn't appear. The enum value is serialized as expected in all DB operations.
William Voorsluys opened DATAMONGO-495 and commented
I'm trying to execute the following code to query MongoDB where the field 'type' is an Enum.
I get an error saying the class can't be serialized (see exception below).
But I noticed the error only happens when the log level is set to DEBUG, when a line in MongoTemplate.java attempts to add the Query to a debug message. The serialization error is then triggered by
toString()
ofBasicDBObject
. The exception thrown is:When log level is set to
INFO
, the problem doesn't appear. The enum value is serialized as expected in all DB operations.Affects: 1.0.3, 1.1 M2
Referenced from: commits 594ddbd, 04a17ca
The text was updated successfully, but these errors were encountered: