0

org.springframework.dao.DataIntegrityViolationException: could not execute statement;

@Entity
@Table(name = "GROUP")
@JsonInclude(JsonInclude.Include.NON_NULL)
public class ContactGroup implements Serializable{

private static final long serialVersionUID = 7161778136151592279L;
@Id
@GenericGenerator(name = "increment", strategy = "increment")
@GeneratedValue(generator = "increment")
@Column(name = "GRP_ID")
private Long id;

}

In my entity id is the primary key when insert the data first time it was running and insert with id 1 and if I run again It will gives error Can you please tell me What did I wrong

Venkata Rama Raju
  • 1,325
  • 2
  • 10
  • 15
  • check this --> http://stackoverflow.com/questions/18205574/difference-between-generatedvalue-and-genericgenerator – sgpalit Sep 30 '15 at 13:55
  • using non-standard generators, so not JPA. There are ample options in JPA standard for the vast majority of usecases – Neil Stockton Sep 30 '15 at 18:25

1 Answers1

0

If you have your table with autoincrement, can use

@GeneratedValue(strategy=GenerationType.IDENTITY)
hide
  • 92
  • 3