hibernate配置问题。请教高手~~~
我的domain里面是这么写的
XML code
<union-subclass name="Topic" table=" wisdom_topic">
<property name="type" column="type_" />
<many-to-one name="forum" column="forumId_" lazy="false" />
<property name="summary" column="summary_" length="500" />
<property name="viewCount" column="viewCount_" />
<property name="replyCount" column="replyCount_" />
<!-- 这是一对一的关系,但把unique设为了false。
因为在sqlserver中运行时,有异常如下:
违反了 UNIQUE KEY 约束 'UQ__wisdom_topic__1367E606'。不能在对象 'dbo.wisdom_topic' 中插入重复键。 -->
<many-to-one name="lastReply" column="lastReplyId_" unique="false" lazy="false" />
<property name="lastArticlePostTime" column="lastArticlePostTime_" />
<property name="nextFloor" column="nextFloor_" />
</union-subclass>
始终报错如下:
23:35:25,125 [main] ERROR SchemaUpdate : Unsuccessful: create table wisdom_topic (id_ varchar(255) not null, title_ varchar(255), content_ text, authorId_ varchar(45), postTime_ datetime, ipAddr_ varchar(16), deleted_ bit, type_ varchar(255), forumId_ varchar(255), summary_ text, viewCount_ integer, replyCount_ integer, lastReplyId_ varchar(255), lastArticlePostTime_ datetime, nextFloor_ integer, primary key (id_)) ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:155)
23:35:25,125 [main] ERROR SchemaUpdate : Table 'wisdom_topic' already exists ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:156)
23:35:25,125 [main] ERROR SchemaUpdate : Unsuccessful: alter table wisdom_topic add index FK56D80D5190BF431F (forumId_), add constraint FK56D80D5190BF431F foreign key (forumId_) references wisdom_forum (id_) ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:155)
23:35:25,125 [main] ERROR SchemaUpdate : Duplicate key name 'FK56D80D5190BF431F' ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:156)
23:35:25,125 [main] ERROR SchemaUpdate : Unsuccessful: alter table wisdom_topic add index FK56D80D51F0AA1F15 (lastReplyId_), add constraint FK56D80D51F0AA1F15 foreign key (lastReplyId_) references wisdom_reply (id_) ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:155)
23:35:25,125 [main] ERROR SchemaUpdate : Duplicate key name 'FK56D80D51F0AA1F15' ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:156)
23:35:25,140 [main] ERROR SchemaUpdate : Unsuccessful: alter table wisdom_topic add index FKDDDD4478AE4DB58956d80d51 (authorId_), add constraint FKDDDD4478AE4DB58956d80d51 foreign key (authorId_) references wisdom_user (id_) ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:155)
23:35:25,140 [main] ERROR SchemaUpdate : Duplicate key name 'FKDDDD4478AE4DB58956d80d51' ==> org.hibernate.tool.hbm2ddl.SchemaUpdate.execute(SchemaUpdate.java:156)
是个什么原因呢??不懂。。。。每次看见控制台报错,头就很大。。。。。学的不扎实。。还请各位赐教啊,,,,
------解决方案--------------------
好像是表关联的事情。 是不是那里建了外键。
------解决方案--------------------
Table 'wisdom_topic' already exists
提示表wisdom_topic已经存在了