Announcement Announcement Module
Collapse
No announcement yet.
MappingMongoConverter could not read the org.joda.money fields back from MongoDB Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • MappingMongoConverter could not read the org.joda.money fields back from MongoDB

    I was using 1.0.0.M4 and having a pojo with a field called unitPrice mapped to org.joda.money.Money type.

    I was able to save the data successfully, but while retrieving the same pojo spring throws the following exception.
    Appreciated your help in this regard.

    Using the following joda money jar -- org.joda.money 0.6


    org.springframework.data.mapping.model.MappingInst antiationException: Could not instantiate bean class [org.joda.money.CurrencyUnit]: Illegal arguments for constructor; nested exception is java.lang.IllegalArgumentException
    at org.springframework.data.mapping.model.BeanWrapper .<init>(BeanWrapper.java:119)
    at org.springframework.data.mapping.model.BeanWrapper .create(BeanWrapper.java:73)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 245)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 193)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter$1.getParameterValue(MappingMongo Converter.java:234)
    at org.springframework.data.mapping.model.BeanWrapper .<init>(BeanWrapper.java:112)
    at org.springframework.data.mapping.model.BeanWrapper .create(BeanWrapper.java:73)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 245)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 193)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter$1.getParameterValue(MappingMongo Converter.java:234)
    at org.springframework.data.mapping.model.BeanWrapper .<init>(BeanWrapper.java:112)
    at org.springframework.data.mapping.model.BeanWrapper .create(BeanWrapper.java:73)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 245)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 193)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter$1.getParameterValue(MappingMongo Converter.java:234)
    at org.springframework.data.mapping.model.BeanWrapper .<init>(BeanWrapper.java:112)
    at org.springframework.data.mapping.model.BeanWrapper .create(BeanWrapper.java:73)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 245)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 193)
    at org.springframework.data.mongodb.core.convert.Mapp ingMongoConverter.read(MappingMongoConverter.java: 161)
    at org.springframework.data.mongodb.core.MongoTemplat e$ReadDbObjectCallback.doWith(MongoTemplate.java:1 462)
    at org.springframework.data.mongodb.core.MongoTemplat e.executeFindMultiInternal(MongoTemplate.java:1233 )
    at org.springframework.data.mongodb.core.MongoTemplat e.doFind(MongoTemplate.java:1044)
    at org.springframework.data.mongodb.core.MongoTemplat e.doFind(MongoTemplate.java:1033)
    at org.springframework.data.mongodb.core.MongoTemplat e.find(MongoTemplate.java:460)
    at org.springframework.data.mongodb.repository.Simple MongoRepository.findAll(SimpleMongoRepository.java :238)
    at org.springframework.data.mongodb.repository.Simple MongoRepository.findAll(SimpleMongoRepository.java :180)
    at org.springframework.data.mongodb.repository.Simple MongoRepository.findAll(SimpleMongoRepository.java :41)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Nativ e Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(Native MethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(De legatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.springframework.data.repository.core.support.R epositoryFactorySupport$QueryExecutorMethodInterce ptor.executeMethodOn(RepositoryFactorySupport.java :322)
    at org.springframework.data.repository.core.support.R epositoryFactorySupport$QueryExecutorMethodInterce ptor.invoke(RepositoryFactorySupport.java:307)
    at org.springframework.aop.framework.ReflectiveMethod Invocation.proceed(ReflectiveMethodInvocation.java :172)
    at org.springframework.aop.framework.JdkDynamicAopPro xy.invoke(JdkDynamicAopProxy.java:202)
    at $Proxy82.findAll(Unknown Source)



    Thanks

  • #2
    I've resolved this by adding custom read/write converters for CurrencyUnit and hooking into MongoMappingConverter.

    Comment

    Working...
    X