mysql中默认engine为myisam,不支持外键。如果engine为myisam的情况下创建包含外键命令的表,会自动变成索引,运行desc tablename显示key为MUL((MySQL Key值(PRI, UNI, MUL)的含义));mysql存储引擎(五星http://www.cnblogs.com/lina1006/archive/2011/04/29/2032894.html);
*修改所有表为InnoDB类型
alter table country engine=InnoDB;
alter table province engine=InnoDB;
alter table university engine=InnoDB;
……
修改之后再回到MyEclipse10中使用hibernate的反向工程自动生成持久化类中便有了set类型
// Fields private Integer id; private Country country; private String name; private Set universities = new HashSet(0);
可以看出province和country是多对一,province和university是一对多;
方法1、修改mysql安装目录下my.ini,在[mysqld]下加上default-storage-engine=INNODB ;
方法2、mysql> set storage_engine=InnoDB;【用show engines查看是否设置成功】
Query OK, 0 rows affected (0.00 sec)
【注意】实际操作发现修改默认存储引擎和修改默认字符集,如果是输命令,那么在mysql服务重启之前设置一直有效,但是重启之后mysql会加载my.ini初始化,所以最好在my.ini中配置好才能一劳永逸(重启mysql服务后才见效)。
配置如下
# The following options will be passed to all MySQL clients [client] #password = your_password port = 3306 socket = MySQL # add default-character-set=utf8 # Here follows entries for some specific programs # The MySQL server [mysqld] port = 3306 socket = MySQL # add character_set_server=utf8 default-storage-engine=INNODB skip-locking key_buffer_size = 16K max_allowed_packet = 1M table_open_cache = 4 sort_buffer_size = 64K read_buffer_size = 256K read_rnd_buffer_size = 256K net_buffer_length = 2K thread_stack = 128K basedir=E:\MySql\ datadir=E:\MySql\Data\
(五星http://www.cnblogs.com/mydomain/archive/2011/11/10/2244233.html)
外键的使用条件
① 两个表必须是InnoDB表,MyISAM表暂时不支持外键
② 外键列必须建立了索引,MySQL 4.1.2以后的版本在建立外键时会自动创建索引,但如果在较早的版本则需要显式建立;
③ 外键关系的两个表的列必须是数据类型相似,也就是可以相互转换类型的列,比如int和tinyint可以,而int和char则不可以;
修改my.ini中default-character-set为utf8,查看 MySQL 数据库服务器和数据库字符集:show variables like '%char%';
手动修改为utf8:
mysql> set character_set_database=utf8;
Query OK, 0 rows affected (0.00 sec)mysql> set character_set_server=utf8;
Query OK, 0 rows affected (0.00 sec)
但是退出mysql之后再次查询variable会发现没有更改,接着修改my.ini,将[client]和[mysqld]两处default-character-set=gbk全部用utf8替代,结果关闭mysql服务,重新启动的时候出现“mysql 服务无法启动。发生系统错误 1067”,找了诸多资料发现:将[mysqld]下default-character-set=utf8修改为character_set_server=utf8便可以成功启动服务,原因令人费解??
西电系列教程(http://see.xidian.edu.cn/cpp/html/1468.html);
官网系列教程(http://dev.mysql.com/doc/refman/5.1/zh/tutorial.html);
用Myeclipse安装egit,使用官网最新地址或者下载最新的egit插件到本地安装均在team中看不到git;(http://blog.csdn.net/softwave/article/details/7622790)
在marketplace中下载失败,官网egit下载到本地之后在team中没有egit
选择Gonsole{没用}
Gonsole is a Git console for the Eclipse IDE. Git commands can be entered directly into the Eclipse Console View and display their output within this view.
Features include
Content assist for commands along with usage hints
Command history
Optional integration with EGit
Multiple console sessions
Git included, it is not necessary to have Git installed
Please see the plug-in's homepage for documentation and support. For bug reports or enhancement requests, please use the issue tracker.
【http://marketplace.eclipse.org/content/gonsole?mpc=true&mpc_state=】
整个spring>整合Hibernate,逆向工程将表映射为domain对象>整合Struts2>
小测试,看在没有把Action交给spring容器管理能否协同工作,test.jsp提交给test.action>showCountry.jsp;跳转测试没实现。。。