还是SSH问题

fengzhizi715 2007-04-25 12:18:09
出现如下的错误:
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/applicationContext.xml]: Initialization of bean failed; nested exception is org.hibernate.MappingException: column attribute may not be used together with <column> subelement


看英文觉得是hibernate的hbm.xml文件配置问题


...全文
467 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
fengzhizi715 2007-04-26
  • 打赏
  • 举报
回复
问题解决了
谢谢
fengzhizi715 2007-04-25
  • 打赏
  • 举报
回复
数据库的脚本如下:
create table Entries (
EntryId int not null auto_increment,

Subject varchar(50) not null,
Body text not null,
PostDate datetime not null,

constraint PK_EntryId primary key (EntryId)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;

create table Comments (
CommentId int not null auto_increment,

Subject varchar(50) not null,
Body text not null,
PostDate datetime not null,
Entry int not null,
ReplyTo int null,
PostedBy int null,

index (ReplyTo),
index (PostedBy),
index (Entry),

constraint PK_CommentId primary key (CommentId),
constraint FK_ReplyTo foreign key (ReplyTo) references Comments(CommentId) on delete cascade,
constraint FK_PostedBy foreign key (PostedBy) references Users(UserId) on delete cascade,
constraint FK_Entry foreign key (Entry) references Entries(EntryId) on delete cascade
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
fengzhizi715 2007-04-25
  • 打赏
  • 举报
回复
我把配置文件发出来,各位帮我看看那里错了

Comment.hbm.xml文件如下:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="model">

<class name="Comment" table="Comments">
<id name="commentId" column="CommentId" type="int" unsaved-value="0" >
<generator class="identity"/>
</id>

<property name="subject" column="Subject" type="string" length="50" not-null="true"/>
<property name="body" column="Body" type="string" not-null="true"/>
<property name="postDate" column="PostDate" type="java.util.Date" not-null="true"/>
<property name="entry" column="Entry" type="int" not-null="true"/>
<property name="replyTo" column="ReplyTo" type="int" not-null="false"/>
<many-to-one name="postedBy" class="model.User" column="PostedBy">
<column name="UserId"/>
</many-to-one>
</class>

</hibernate-mapping>


Entry.hbm.xml文件如下:
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd" >

<hibernate-mapping package="Entry">

<class name="Entry" table="Entries">
<id name="entryId" column="EntryId" type="int" unsaved-value="0" >
<generator class="identity"/>
</id>

<property name="subject" column="Subject" type="string" length="50" not-null="true"/>
<property name="body" column="Body" type="string" not-null="true"/>
<property name="postDate" column="postDate" type="java.util.Date" not-null="true"/>
<set name="comments" table="Comments">
<key column="Entry"/>
<one-to-many class="model.Comment"/>
</set>
</class>

</hibernate-mapping>
bl_long1 2007-04-25
  • 打赏
  • 举报
回复
<many-to-one name="postedBy" class="model.User" column="PostedBy">
<column name="UserId"/>
</many-to-one>
这里不能同时使用column属性和column元素,两者取一即可。值为外键的那个列名。

67,515

社区成员

发帖
与我相关
我的任务
社区描述
J2EE只是Java企业应用。我们需要一个跨J2SE/WEB/EJB的微容器,保护我们的业务核心组件(中间件),以延续它的生命力,而不是依赖J2SE/J2EE版本。
社区管理员
  • Java EE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧