当我做持久化时,我有以下实体我得到转储,我移动到字段字符串值(这是模型定义的 ID 类型字符串的值,例如(假期,WORK_ACCIDENT ...所以我不能改变它),错误是
INTEGER 类型的字符串格式无效。
@Entity
public class LeaveReType {
@Id
@GeneratedValue(strategy = GenerationType.TABLE)
private String id;
我有另一个 ID 类型字符串的实体,当我移到它的编号时,持久性工作正常,我可以使用一些 ID 注释来忽略这个限制吗?
Exception in thread "main" javax.persistence.RollbackException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.4.1.v20121003-ad44345): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLDataException: Invalid character string format for type INTEGER.
Error Code: 20000
Call: INSERT INTO LESTTYPE (ID, AVAILABLEBALANCE, ENTITLEMENT, NAME, PENDINGITEMS) VALUES (?, ?, ?, ?, ?)
bind => [5 parameters bound]
Query: InsertObjectQuery(LESTTYPE [id=WORK_ACCIDENT, name=Work Accident, entitlement=n/a, availableBalance=n/a, pendingItems=0 pending items])
我也试过了,我得到了同样的错误
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
@TypeConverter(dataType = Long.class, name = "id")
private String id;