2017-01-22 63 views
2

我想安裝Javer使用MongoDB存儲庫。我爲javers-corejavers-persistence-mongo使用了版本2.9.1。Javers MongoRepository拋出IllegalArgumentException爲布爾JsonPrimitive

然而,當我嘗試犯了一個布爾字段的實體,以下異常被拋出:

java.lang.IllegalArgumentException: unsupported JsonElement type - JsonPrimitive 
    at org.javers.repository.mongo.DocumentConverter.fromJsonElement(DocumentConverter.java:71) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.DocumentConverter.toDocument(DocumentConverter.java:20) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.DocumentConverter.fromJsonElement(DocumentConverter.java:39) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.DocumentConverter.toDocument(DocumentConverter.java:20) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.MongoRepository.writeToDBObject(MongoRepository.java:200) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.MongoRepository.persistSnapshots(MongoRepository.java:217) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.mongo.MongoRepository.persist(MongoRepository.java:74) ~[javers-persistence-mongo-2.9.1.jar:?] 
    at org.javers.repository.api.JaversExtendedRepository.persist(JaversExtendedRepository.java:109) ~[javers-core-2.9.1.jar:?] 
    at org.javers.core.JaversCore.commit(JaversCore.java:83) ~[javers-core-2.9.1.jar:?] 
    at org.javers.core.JaversCore.commit(JaversCore.java:65) ~[javers-core-2.9.1.jar:?] 

展望在javers-persistence-mongo-2.9.1/DocumentConverterprivate static Object fromJsonElement(JsonElement jsonElement)方法,有對JsonPrimitives字符串和號碼只轉換方法(不是布爾)。

我在這裏是否缺少一些配置?

MWE:

public static void main(final String[] args) { 
    final TestEntity testEntity = new TestEntity(); 
    testEntity.id = 12345L; 
    testEntity.testBoolean = true; 

    final MongoClient mongoClient = new MongoClient(...); 
    final Javers javers = JaversBuilder.javers() 
     .registerJaversRepository(new MongoRepository(mongoClient.getDatabase(...))).build(); 

    javers.commit("testAuthor", testEntity); // Throws IllegalArgumentException 
    } 

    @Entity 
    static class TestEntity { 

    @Id 
    Long id; 

    Boolean testBoolean; 
    } 

回答

相關問題