I am using Hibernate to save an object in the database. I am generating my primary key with @GeneratedValue annotation.
Here is my code Vendor class
I don't know if the Hibernate ORM has been updated that much but currently you have to omit the decorator @Column()
if you use @GeneratedValue
.
So your code will be
@Id
@GeneratedValue
private int vendor_ID;
instead of
@Id
@GeneratedValue(strategy = javax.persistence.GenerationType.IDENTITY)
@Column(name="vendor_ID", unique = true, nullable = false)
private int vendor_ID;
Hope it helps.