No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type '

1. javax.validation.UnexpectedTypeException: HV000030: No validator could be found for constraint 'javax.validation.constraints.NotEmpty' validating type 'java.lang.Integer'. Check configuration for 'roleId'
    at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.getExceptionForNullValidator(ConstraintTree.java:108) ~[hibernate-validator-6.0.17.Final.jar:6.0.17.Final]
    at .................

@NotEmpty注解支持字符串类型字段,不支持Integer,对Integer类型的校验要用@NotNull

 

 

 

2.  org.springframework.orm.jpa.JpaSystemException: ids for this class must be manually assigned before calling save(): com.neptunus.data.modules.sys.model.entity.SysUserRole; nested exception is org.hibernate.id.IdentifierGenerationException: ids for this class must be manually assigned before calling save(): com.neptunus.data.modules.sys.model.entity.SysUserRole
    at org.springframework.orm.jpa.vendor.HibernateJpaDialect.convertHibernateAccessException(HibernateJpaDialect.java:352) ~[spring-orm-5.1.10.RELEASE.jar:5.1.10.RELEASE]

 

id的生成错误,在保存之前,需先生成

在实体类字段id前加上下面这句话即可

@GeneratedValue(strategy = GenerationType.IDENTITY)

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值