Announcement Announcement Module
Collapse
No announcement yet.
Exception retrieving empty Set from mongodb database Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Exception retrieving empty Set from mongodb database

    I have an entity bean like this:

    Code:
    @Document
    public class AccountData implements Serializable
    {
    	@Id
    	private String userId;
    	private String description;
    	private Date birthday;
    	private Set<Occupation> occupations;
    	// Other simple attributes
    
    	// Getters and setters
    }
    When I add Occupation items to Set, those are serialized and deserialized from database without any problem.

    But when the Set is empty and I try to retrieve it from database I get this exception:

    Code:
    java.lang.IllegalArgumentException: Can not set java.util.Set field org.myproject.data.beans.AccountData.occupations to java.util.LinkedList
    	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:146)
    	at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:150)
    	at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:63)
    	at java.lang.reflect.Field.set(Field.java:657)
    	at org.springframework.util.ReflectionUtils.setField(ReflectionUtils.java:92)
    	at org.springframework.data.mapping.BeanWrapper.setProperty(BeanWrapper.java:159)
    	at org.springframework.data.document.mongodb.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:242)
    	at org.springframework.data.document.mongodb.convert.MappingMongoConverter$2.doWithPersistentProperty(MappingMongoConverter.java:230)
    	at org.springframework.data.mapping.BasicPersistentEntity.doWithProperties(BasicPersistentEntity.java:112)
    	at org.springframework.data.document.mongodb.convert.MappingMongoConverter.read(MappingMongoConverter.java:230)
    	at org.springframework.data.document.mongodb.convert.MappingMongoConverter.read(MappingMongoConverter.java:174)
    	at org.springframework.data.document.mongodb.convert.MappingMongoConverter.read(MappingMongoConverter.java:128)
    	at org.springframework.data.document.mongodb.MongoTemplate$ReadDbObjectCallback.doWith(MongoTemplate.java:1655)
    	at org.springframework.data.document.mongodb.MongoTemplate.executeFindOneInternal(MongoTemplate.java:1374)
    	at org.springframework.data.document.mongodb.MongoTemplate.doFindOne(MongoTemplate.java:1145)
    	at org.springframework.data.document.mongodb.MongoTemplate.findById(MongoTemplate.java:608)
    	at org.springframework.data.document.mongodb.MongoTemplate.findById(MongoTemplate.java:600)
    	at org.springframework.data.document.mongodb.repository.SimpleMongoRepository.findOne(SimpleMongoRepository.java:104)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.executeMethodOn(RepositoryFactorySupport.java:358)
    	at org.springframework.data.repository.support.RepositoryFactorySupport$QueryExecuterMethodInterceptor.invoke(RepositoryFactorySupport.java:339)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy20.findOne(Unknown Source)
    	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    	at java.lang.reflect.Method.invoke(Method.java:597)
    	at org.springframework.aop.support.AopUtils.invokeJoinpointUsingReflection(AopUtils.java:309)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.invokeJoinpoint(ReflectiveMethodInvocation.java:183)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:150)
    	at org.springframework.aop.interceptor.ExposeInvocationInterceptor.invoke(ExposeInvocationInterceptor.java:89)
    	at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    	at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)
    	at $Proxy22.findOne(Unknown Source)
    	at org.myproject.data.services.impl.UserServiceImpl.getAccountData(UserServiceImpl.java:158)
    	...

  • #2
    I've seen Oliver Gierke has created a Jira issue for this error (https://jira.springsource.org/browse/DATADOC-192).

    I'm not familiar with Springsource Jira. Must I report directly to Jira when I think I've found an unknown bug?

    Thank you.

    PD.- Oliver I'll try to reproduce the error reported by me in stackoverflow and send de stacktrace. I have had no time for this one.

    Comment


    • #3
      It's already fixed . See [0] for the commit. I am just publishing the build to the snapshot repo.

      [0] https://github.com/SpringSource/spri...4e0a7f0b142855

      Comment

      Working...
      X