babyfish-ct / jimmer

A revolutionary ORM framework for both java and kotlin.
Apache License 2.0
834 stars 81 forks source link

实体特殊属性名导致的序列化失败问题仍然没有彻底解决 #752

Open sunshio opened 12 hours ago

sunshio commented 12 hours ago

版本:0.9.10

image image

Exception in thread "main" java.lang.RuntimeException: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: There is no jimmer property for public final java.lang.String org.babyfish.jimmer.sql.example.model.BookDraft$Producer$Implementor.getISApp() at org.babyfish.jimmer.ImmutableObjects.toString(ImmutableObjects.java:365) at org.babyfish.jimmer.sql.example.model.BookDraft$Producer$Impl.toString(BookDraft.java:924) at java.base/java.lang.String.valueOf(String.java:4507) at java.base/java.io.PrintStream.println(PrintStream.java:1187) at org.babyfish.jimmer.sql.example.App.main(App.java:34) Caused by: com.fasterxml.jackson.databind.exc.InvalidDefinitionException: There is no jimmer property for public final java.lang.String org.babyfish.jimmer.sql.example.model.BookDraft$Producer$Implementor.getISApp() at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:77) at com.fasterxml.jackson.databind.SerializerProvider.reportBadDefinition(SerializerProvider.java:1300) at com.fasterxml.jackson.databind.SerializerProvider._createAndCacheUntypedSerializer(SerializerProvider.java:1447) at com.fasterxml.jackson.databind.SerializerProvider.findValueSerializer(SerializerProvider.java:544) at com.fasterxml.jackson.databind.SerializerProvider.findTypedValueSerializer(SerializerProvider.java:822) at com.fasterxml.jackson.databind.ser.DefaultSerializerProvider.serializeValue(DefaultSerializerProvider.java:308) at com.fasterxml.jackson.databind.ObjectMapper._writeValueAndClose(ObjectMapper.java:4568) at com.fasterxml.jackson.databind.ObjectMapper.writeValueAsString(ObjectMapper.java:3821) at org.babyfish.jimmer.ImmutableObjects.toString(ImmutableObjects.java:363) ... 4 more

babyfish-ct commented 10 hours ago

这类“BUG”的修复,无外乎就一个把下限放多低的问题。好奇为什么要违背Java的规则呢?

sunshio commented 10 hours ago

我也好奇为什么要通过getter方法反推属性名是什么,不能直接维护原始属性名吗

sunshio commented 10 hours ago

这个主要不是我需要把属性定义成这个样子,而是我认为,通过getter方法反推属性名的做法似乎不妥,java的pojo,record,难道会有此类问题?

sunshio commented 9 hours ago

实测,pojo会有类似问题,record不会,我已了解,不再纠结此类问题

SWQXDBA commented 47 minutes ago

java中属性的前两个字符不要大写 纠结为什么没意义,是生态的问题。 很多框架对pojo的解析千奇百怪。