我有一个主键列,它是一个INT列,我想更改为BIGINT.我们的测试和生产环境使用
MySQL,但是对于单元测试,我们使用嵌入式H2数据库.
我创建了以下Liquibase重构:
...
...
重构工作,但当我尝试使用Hibernate将对象持久化到数据库时,我收到以下错误消息(我已经包装了错误消息):
ERROR org.hibernate.util.JDBCExceptionReporter [main]: NULL not allowed for column "ID";
SQL statement: insert into event (id, eventtime, guid, meta, objectguid, originatorid, subtype, type) values (null, ?, ?, ?, ?, ?, ?, '0') [90006-140]
JDBC exception on Hibernate data access:
SQLException for SQL [insert into event (id, eventtime, guid, meta, objectguid, originatorid, subtype, type) values (null, ?, ?, ?, ?, ?, ?, '0')];
SQL state [90006]; error code [90006]; could not insert: [event.MyEvent];
nested exception is org.hibernate.exception.GenericJDBCException: could not insert: [event.MyEvent]
MyEvent类继承自AbstractBaseEvent,它在代码中定义了以下Hibernate映射:
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private long id;
几点:
> hibernate映射在重构数据类型之前有效
> Liquibase的版本是2.0.1
>这是否适用于MySQL尚未经过测试