gpt4 book ai didi

java - JDO 无法为 Apache Derby 映射 java.lang.Boolean

转载 作者:太空宇宙 更新时间:2023-11-04 08:32:25 31 4
gpt4 key购买 nike

这是我第一次使用Eclipse和JDO。我在Eclipse中使用Schema Tool生成DDL时遇到问题。

Java 类中的字段之一如下所示:

@Persistent
@Column(name = "Enabled", jdbcType = "BOOLEAN")
private boolean enabled = true;

我已经使用Enhancer Tool成功增强了该类,但是当我运行Schema Tool(使用derbyclient.jar作为JDBC驱动程序)时,记录了以下错误消息:

18:47:26,164 (main) ERROR [DataNucleus.SchemaTool] - An exception was thrown during the operation of SchemaTool. Please refer to the log for full details. The following may help : JDBC type BOOLEAN declared for field "org.company.core.User.enabled" of java type java.lang.Boolean cant be mapped for this datastore. JDBC type BOOLEAN declared for field "org.company.core.User.enabled" of java type java.lang.Boolean cant be mapped for this datastore. org.datanucleus.exceptions.NucleusException: JDBC type BOOLEAN declared for field "org.company.core.User.enabled" of java type java.lang.Boolean cant be mapped for this datastore. at org.datanucleus.store.rdbms.mapping.RDBMSMappingManager.getDatastoreMappingClass(RDBMSMappingManager.java:329) at org.datanucleus.store.rdbms.mapping.RDBMSMappingManager.createDatastoreMapping(RDBMSMappingManager.java:533) at org.datanucleus.store.mapped.mapping.SingleFieldMapping.prepareDatastoreMapping(SingleFieldMapping.java:55) at org.datanucleus.store.mapped.mapping.SingleFieldMapping.initialize(SingleFieldMapping.java:44) at org.datanucleus.store.mapped.mapping.MappingFactory.createMapping(MappingFactory.java:97) at org.datanucleus.store.mapped.mapping.AbstractMappingManager.getMapping(AbstractMappingManager.java:255) at org.datanucleus.store.rdbms.table.ClassTable.manageMembers(ClassTable.java:571) at org.datanucleus.store.rdbms.table.ClassTable.manageClass(ClassTable.java:451) at org.datanucleus.store.rdbms.table.ClassTable.initializeForClass(ClassTable.java:1111) at org.datanucleus.store.rdbms.table.ClassTable.initialize(ClassTable.java:268) at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.initializeClassTables(RDBMSStoreManager.java:2439) at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.addClassTablesAndValidate(RDBMSStoreManager.java:2346) at org.datanucleus.store.rdbms.RDBMSStoreManager$ClassAdder.run(RDBMSStoreManager.java:1996) at org.datanucleus.store.rdbms.AbstractSchemaTransaction.execute(AbstractSchemaTransaction.java:113) at org.datanucleus.store.rdbms.RDBMSStoreManager.createSchema(RDBMSStoreManager.java:3114) at org.datanucleus.store.schema.SchemaTool.createSchema(SchemaTool.java:443) at org.datanucleus.store.schema.SchemaTool.main(SchemaTool.java:378)

我查了Apache Derby的手册,数据库支持BOOLEAN数据类型: http://db.apache.org/derby/docs/10.8/ref/rrefsqljBoolean.html

导致该错误的原因是什么?

提前致谢。

最佳答案

DataNucleus 对于我来说可以很好地将 boolean Java 字段持久化为 BOOLEAN jdbcType;使用 DataNucleus 3.x 和 Derby 10.7.1.1。

DataNucleus 日志清楚地告诉您该版本的 Derby 实际上支持哪些 JDBC 类型(即 Derby 声称通过 JDBC 调用支持哪些类型 - 手册中所说的不一定相同)。

关于java - JDO 无法为 Apache Derby 映射 java.lang.Boolean,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7214104/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com