If you don't specify an id generation strategy, Hibernate will use GenerationType.AUTO
. This will result in any of
AUTO - either identity column, sequence or table depending on the
underlying DB.
If you look here, you'll notice all of those generate ids of type long
, short
or int
, not of type String
.
Say you wanted a String
UUID as an id, you could use
@Id
@GeneratedValue(generator = "uuid")
@GenericGenerator(name = "uuid", strategy = "uuid2")
@Column(name = "PR_KEY")
private String prKey;
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…