日期:2014-05-18  浏览次数:20708 次

struts2.3.4+hibernate4.18+spring3.2 自动创建外键关联失败,创建序列失败!
用 struts2.3.4+hibernate4.18+spring3.2 框架写一个web小程序,实体类用的jpa注解。
在让hibernate自动创建表时总是提示无法添加外键,并且无法创建用于生成id的sequence。
本该创建序列seq_6bit ,它却发出create table seq_6bit ( next_val bigint );insert into seq_6bit values ( 100000 )的语句!
这个程序在只用hibernate4.18时是能够自动创建相关表,建立关联关系,创建序列等。
为什么添加其他两个框架后,就不行了呢!

我用的数据库是oracle10g。

具体错误提示如下:

17:33:15,005 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate:226 - alter table Admin add index FK3C3132FA38882C2 (userId), add constraint FK3C3132FA38882C2 foreign key (userId) references users (userId)
17:33:15,097 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:235 - HHH000388: Unsuccessful: alter table Admin add index FK3C3132FA38882C2 (userId), add constraint FK3C3132FA38882C2 foreign key (userId) references users (userId)
17:33:15,098 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:236 - ORA-00904: : 标识符无效

17:33:15,099 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate:226 - alter table Course_Teacher add index FK2FDB6BBE2921AA00 (tid), add constraint FK2FDB6BBE2921AA00 foreign key (tid) references Teacher (tId)
17:33:15,102 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:235 - HHH000388: Unsuccessful: alter table Course_Teacher add index FK2FDB6BBE2921AA00 (tid), add constraint FK2FDB6BBE2921AA00 foreign key (tid) references Teacher (tId)
17:33:15,103 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:236 - ORA-00904: : 标识符无效

17:33:15,104 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate:226 - alter table Course_Teacher add index FK2FDB6BBED464D56A (cid), add constraint FK2FDB6BBED464D56A foreign key (cid) references Course (cId)
17:33:15,109 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:235 - HHH000388: Unsuccessful: alter table Course_Teacher add index FK2FDB6BBED464D56A (cid), add constraint FK2FDB6BBED464D56A foreign key (cid) references Course (cId)
17:33:15,109 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:236 - ORA-00904: : 标识符无效

17:33:15,110 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate:226 - alter table Score add index FK4C04E72EEE5C98 (sId), add constraint FK4C04E72EEE5C98 foreign key (sId) references Student (sId)
17:33:15,113 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:235 - HHH000388: Unsuccessful: alter table Score add index FK4C04E72EEE5C98 (sId), add constraint FK4C04E72EEE5C98 foreign key (sId) references Student (sId)
17:33:15,113 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:236 - ORA-00904: : 标识符无效

17:33:15,114 DEBUG org.hibernate.tool.hbm2ddl.SchemaUpdate:226 - alter table Score add index FK4C04E72D464D56A (cId), add constraint FK4C04E72D464D56A foreign key (cId) references Course (cId)
17:33:15,117 ERROR org.hibernate.tool.hbm2ddl.SchemaUpdate:235 - HHH000388: Unsuccessful: alter table