You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I recently upgraded from querydsl 2.9.0 to 3.2.3 and spring-data-mongodb 1.2.1.RELEASE to 1.3.1.RELEASE.
Currently, some of my MongoDB entities have inner objects stored using maps with Long keys :
@Document(collection = "xxx")
@QueryEntity
public class ObjectA {
private Map<Long, ObjectB> objects;
}
When querying whether a key is present in the map (for example QObjectA.objectA.objects.get(objectId).isNotNull()), I now get a ClassCastException :
java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.String
at com.mysema.query.types.PathMetadata.getName(PathMetadata.java:70)
at org.springframework.data.mongodb.repository.support.SpringDataMongodbSerializer.getKeyForPath(SpringDataMongodbSerializer.java:66)
The getKeyForPath() method has changed between the two spring-data-mongodb releases : it was metadata.getExpression().toString() in the previous version, not getName(). However I'm not really sure whether the culprit is spring-data-mongodb or query-dsl. I noticed the PathMetadata code was rather "odd" : the generic type is never used, and the getName() method blindly casts the element to a String.
public String getName() {
return (String)element;
}
Is this issue only related to query-dsl ?
Should I ask the spring-data guys for help ?
Any pointers in helping resolve this issue would be much appreciated.
The text was updated successfully, but these errors were encountered:
This should be safer than the previous behaviour of taking the generic key object and calling toString(). You will get a ClassCastException for cases where the last path stage doesn't refer to a property.
Hello,
I recently upgraded from querydsl 2.9.0 to 3.2.3 and spring-data-mongodb 1.2.1.RELEASE to 1.3.1.RELEASE.
Currently, some of my MongoDB entities have inner objects stored using maps with Long keys :
When querying whether a key is present in the map (for example QObjectA.objectA.objects.get(objectId).isNotNull()), I now get a ClassCastException :
The getKeyForPath() method has changed between the two spring-data-mongodb releases : it was metadata.getExpression().toString() in the previous version, not getName(). However I'm not really sure whether the culprit is spring-data-mongodb or query-dsl. I noticed the PathMetadata code was rather "odd" : the generic type is never used, and the getName() method blindly casts the element to a String.
Is this issue only related to query-dsl ?
Should I ask the spring-data guys for help ?
Any pointers in helping resolve this issue would be much appreciated.
The text was updated successfully, but these errors were encountered: