我把配置文件发出来,各位帮我看看那里错了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>
<?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>
解决方案 »
- 求救求救Exception creating bean of class org.apache.struts.validator.DynaActionForm:
- 上传图片的问题
- tomcat 6 移植到 jboss 5问题多多
- 404报错。。。求解决。。。
- 有个整数1234,写个方法将其反转结果为4321(如果是1230,结果为321),考虑负数
- IIS用了80端口我的tomcat还可以用吗??
- hibernate+sql server 2005 映射问题
- struts 提交后什么都没有.
- 100分。关于 resin 的集群
- 如果一个应用采用了过滤器,为什么很多错误在控制台报的是过滤器错误,而不报具体的错误,能解决这个问题么?同样的,在struts中(见内容
- 请教一个涉及别名的hql语句
- 找人些个商家的静态也面1000-1500
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;
<column name="UserId"/>
</many-to-one>
这里不能同时使用column属性和column元素,两者取一即可。值为外键的那个列名。