刚刚学习hebirnate
一个关于多对一的问题:
第一个:User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.hao.hibernate.User" table="t_User">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<many-to-one name="group" unique="true"/>
</class>
</hibernate-mapping>
第二个:Group.hbm.xml<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.hao.hibernate.Group" table="t_Group">
<id name="groupNo">
<generator class="native"/>
</id>
<property name="gname"/>
</class>
</hibernate-mapping>
在进行建表的时候遇到了如下问题
14:47:37,609 INFO SchemaExport:154 - Running hbm2ddl schema export
14:47:37,625 DEBUG SchemaExport:170 - import file not found: /import.sql
14:47:37,625 INFO SchemaExport:179 - exporting generated schema to database
alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,859 DEBUG SchemaExport:303 - alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,953 DEBUG SchemaExport:288 - Unsuccessful: alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,953 DEBUG SchemaExport:289 - Table 'hibernatedb_test4.t_user' doesn't exist
drop table if exists t_Group
14:47:38,953 DEBUG SchemaExport:303 - drop table if exists t_Group
drop table if exists t_User
14:47:39,234 DEBUG SchemaExport:303 - drop table if exists t_User
create table t_Group (groupNo integer not null auto_increment, gname varchar(255), primary key (groupNo))
14:47:39,265 DEBUG SchemaExport:303 - create table t_Group (groupNo integer not null auto_increment, gname varchar(255), primary key (groupNo))
create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 DEBUG SchemaExport:303 - create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 ERROR SchemaExport:274 - Unsuccessful: create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group integer unique, primary key (id))' at line 1
alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 DEBUG SchemaExport:303 - alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 ERROR SchemaExport:274 - Unsuccessful: alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group' at line 1
14:47:39,437 INFO SchemaExport:196 - schema export complete
急求帮助!谢谢!!!
一个关于多对一的问题:
第一个:User.hbm.xml
<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.hao.hibernate.User" table="t_User">
<id name="id">
<generator class="native"/>
</id>
<property name="name"/>
<many-to-one name="group" unique="true"/>
</class>
</hibernate-mapping>
第二个:Group.hbm.xml<?xml version="1.0"?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-mapping-3.0.dtd">
<hibernate-mapping>
<class name="com.hao.hibernate.Group" table="t_Group">
<id name="groupNo">
<generator class="native"/>
</id>
<property name="gname"/>
</class>
</hibernate-mapping>
在进行建表的时候遇到了如下问题
14:47:37,609 INFO SchemaExport:154 - Running hbm2ddl schema export
14:47:37,625 DEBUG SchemaExport:170 - import file not found: /import.sql
14:47:37,625 INFO SchemaExport:179 - exporting generated schema to database
alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,859 DEBUG SchemaExport:303 - alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,953 DEBUG SchemaExport:288 - Unsuccessful: alter table t_User drop foreign key FKCB5540D6C4C43CFD
14:47:38,953 DEBUG SchemaExport:289 - Table 'hibernatedb_test4.t_user' doesn't exist
drop table if exists t_Group
14:47:38,953 DEBUG SchemaExport:303 - drop table if exists t_Group
drop table if exists t_User
14:47:39,234 DEBUG SchemaExport:303 - drop table if exists t_User
create table t_Group (groupNo integer not null auto_increment, gname varchar(255), primary key (groupNo))
14:47:39,265 DEBUG SchemaExport:303 - create table t_Group (groupNo integer not null auto_increment, gname varchar(255), primary key (groupNo))
create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 DEBUG SchemaExport:303 - create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 ERROR SchemaExport:274 - Unsuccessful: create table t_User (id integer not null auto_increment, name varchar(255), group integer unique, primary key (id))
14:47:39,437 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group integer unique, primary key (id))' at line 1
alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 DEBUG SchemaExport:303 - alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 ERROR SchemaExport:274 - Unsuccessful: alter table t_User add index FKCB5540D6C4C43CFD (group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group (groupNo)
14:47:39,437 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'group), add constraint FKCB5540D6C4C43CFD foreign key (group) references t_Group' at line 1
14:47:39,437 INFO SchemaExport:196 - schema export complete
急求帮助!谢谢!!!
解决方案 »
- spring的@PreDestroy与scope问题
- 升学历还是苦修技术
- 读取远程SQLSERVER的2进制字段在本地生成文件后,插入到本地ORACLE的LONG RAW字段报"数据大小超出此类型的最大值"错
- 一个服务返回一个ArrayList,如何使用Axis序列化/反序列化啊
- 照这网上的教程写了个hibernate的例子,可以操作数据库,不过有异常。。。
- 求解决升级struts2-core-2.3.14.2.jar报错
- JAVA 链接数据库的问题...
- 怎样提高JAVA开发水平
- 请大家看一看下面的编译信息,不知道存在什么问题。
- weblogic的使用方法
- 关于数据库连接的问题!出现了8小时中断!
- 一个主流的JS+FLASH应用??
楼主【h495854943】截止到2008-06-27 14:48:35的历史汇总数据(不包括此帖):
发帖数:4 发帖分:61
结贴数:0 结贴分:0
未结数:4 未结分:61
结贴率:0.00 % 结分率:0.00 %
如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
14:47:39,437 ERROR SchemaExport:275 - You have an error in your SQL syntax; check the manual that corresponds to <id name="id" type="java.lang.Integer">
<generator class="native"/>
</id>