研究了通过 navicat premium 手动新建表添加字段没有设置主键自增
需要通过 sql 语句建表设置主键 id 自增:
[id] int identity(1,1) not null,
具体创建表示例:
create table [dbo].[bsrecord] (
[id] int identity(1,1) not null,
[shipmentno] varchar(11) collate chinese_prc_ci_as null,
[filename] varchar(35) collate chinese_prc_ci_as null,
[pageid] int null,
[type] int null,
primary key clustered ([id] asc)
with (pad_index = off, statistics_norecompute = off, ignore_dup_key = off, allow_row_locks = on, allow_page_locks = on)
on [primary]
)
on [primary]
go
可以看到实现了 id 自增
项目代码问题,jpa insert 数据报错
需要在 entity 处 id 添加注解自增
@generatedvalue(strategy = generationtype.identity)
发表评论