Reputation: 1
I'm trying to save a new record from Spring Boot JPA. My DB2 database has already created sequence (My_Sequence) which has to be used for autoincrement (tried for all generation types)
I'm facing an issue while saving a new record, with code as below
@Id
@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "My_Sequence")
@SequenceGenerator(name = "FIFAFIFT_SEQ1", sequenceName = "My_Sequence", allocationSize = 1)
@Column(name="My_Column"),
Error:
com.ibm.db2.jcc.am.SqlSyntaxErrorException: DB2 SQL Error: SQLCODE=-204, SQLSTATE=42704, SQLERRMC=schemaName.My_sequence, DRIVER=4.24.92
Please suggest any solution.
Upvotes: 0
Views: 568
Reputation: 2396
generator = "My_Sequence"
is not equal to name = "FIFAFIFT_SEQ1"
Example:
@Id
@GeneratedValue(
strategy = GenerationType.SEQUENCE,
generator = "My_Sequence"
)
@SequenceGenerator(
name = "My_Sequence",
sequenceName = "mySeq",
allocationSize = 5
)
private Long id;
Upvotes: 1