同时具有以下对象图:
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
指定注释参数,但这仍然没有解决问题。我尝试这样做是因为我认为 datanucleus 正在构建二进制列,这就是我必须指定长度的原因。而且我什至没有指定长度,因为我不知道应该在哪里指定它!@Element
@Persistence
false
编辑: Datanucleus 从头开始创建整个数据库。我只使用 SQL 查询只有 3 个配置表,并且没有与它们相关的映射。
我正在使用 datanucleus v3.1.3 和 MySQL v5.5