Chinaunix首页 | 论坛 | 博客
  • 博客访问: 40151
  • 博文数量: 18
  • 博客积分: 366
  • 博客等级: 一等列兵
  • 技术积分: 200
  • 用 户 组: 普通用户
  • 注册时间: 2012-09-26 10:41
文章分类

全部博文(18)

文章存档

2013年(3)

2012年(15)

我的朋友

分类: 系统运维

2012-12-12 15:18:15

@javax.persistence.TableGenerator(
   name="my_table_gen",//table生成器本身的名字
   table="gen_table",//生成器产生的表的名字
   pkColumnName = "pk_key",
//表中的主键的字段名 Name of the primary key column in the table.
   valueColumnName = "pk_value",
   pkColumnValue="id",运用该生成器的主键字段名
   allocationSize=1
)
在mysql 中 key和 value是关键字 所以这里valueColumnName 和PkCoulmnName 不能写成value 和 key 否则程序会报错 

@GeneratedValue(strategy=GenerationType.TABLE,generator="my_table_gen")

mysql> select * from gen_table;
+--------+----------+
| pk_key | pk_value |
+--------+----------+
| id     |        2 |
+--------+----------+
1 row in set (0.00 sec)

mysql> select * from professor;
+----+------+--------+
| id | name | title  |
+----+------+--------+
|  1 | xxd  | deputy |
+----+------+--------+
1 row in set (0.00 sec)


阅读(387) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~