具有以下对象图:
public class SecureDetails{
@Persistent(defaultFetchGroup = "true", table = "sc_details_emails")
@Join(column = "sc_details_pk")
@Element(column = "email")
private List<String> emails;
}
我继续收到此异常,而datanucleus尝试自动创建架构( DEBUG 日志记录级别已激活,并且为了简洁起见而截断了栈跟踪):
21:09:24 DEBUG (Log4JLogger.java:58)-[main] Creating foreign key constraint : "sc_details_emails_fk1" in catalog "" schema ""
21:09:24 DEBUG (Log4JLogger.java:58)-[main] ALTER TABLE sc_details_emails ADD CONSTRAINT sc_details_emails_fk1 FOREIGN KEY (sc_details_pk) REFERENCES sc_details (sc_details_id)
21:09:24 ERROR (Log4JLogger.java:115)-[main] An exception was thrown while adding/validating class(es) : BLOB/TEXT column 'sc_details_pk' used in key specification without a key length
com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: BLOB/TEXT column 'sc_details_pk' used in key specification without a key length
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:39)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:27)
at java.lang.reflect.Constructor.newInstance(Constructor.java:513)
at com.mysql.jdbc.Util.handleNewInstance(Util.java:411)
at com.mysql.jdbc.Util.getInstance(Util.java:386)
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:1053)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4096)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:4028)
at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2490)
at com.mysql.jdbc.MysqlIO.sqlQueryDirect(MysqlIO.java:2651)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2728)
at com.mysql.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2678)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:894)
at com.mysql.jdbc.StatementImpl.execute(StatementImpl.java:732)
.
.
.
我尝试为serialized
注释一次指定值false
的注释参数@Element
,并为@Persistence
注释指定另一次,值为{ {1}}但这仍然无法解决问题。我试过,因为我认为datanucleus正在构建二进制列,这就是为什么我必须指定一个长度。我甚至没有指定长度,因为我不知道应该在哪里指定它!
编辑:Datanucleus从头开始创建整个数据库。我只使用SQL查询了3个配置表,并且没有与之相关的映射。
我正在使用带有MySQL v5.5的datanucleus v3.1.3
答案 0 :(得分:0)
令人惊讶的是,干净的构建解决了这个问题!
答案 1 :(得分:-1)
所以你没有让DataNucleus创建所有的模式,并且某处的BLOB列与你提供的(小)元数据不一致。解决方案:让DataNucleus生成架构,或者实际呈现架构,以便人们可以告诉您它有什么问题。