I have an entity class Content
and I'm using a sequence generator to generate the id automatically.
@Entity
@Table(name = "CONTENT")
public class Content {
@Id
@Column(name = "ID", unique = true)
@GeneratedValue(strategy = GenerationType.IDENTITY, generator = "SEQ_C")
@SequenceGenerator(name = "SEQ_C", sequenceName = "SEQ_INCREMENTER_CONTENT", allocationSize = 1)
private Long id;
}
I'm inserting data with a saveAll()
using spring boot JPA.
contentRepository.saveAll(contents);
I'm generating the table using liquibase
.
<createSequence sequenceName="SEQ_INCREMENTER_CONTENT" cycle="false" minValue="1" startValue="1" incrementBy="1"/>
<createTable tableName="content">
<column defaultValueSequenceNext="SEQ_INCREMENTER_CONTENT" name="id" type="BIGINT">
<constraints nullable="false" primaryKey="true" primaryKeyName="pk_content"/>
</column>
<column name="content_type" type="VARCHAR(255)"/>
<column name="content_type_id" type="INT"/>
<column name="data" type="VARCHAR2(255)"/>
<column name="placement" type="INT"/>
<column name="placement_id" type="INT"/>
<column name="segment_id" type="BIGINT"/>
</createTable>
<addForeignKeyConstraint baseColumnNames="segment_id" baseTableName="content" constraintName="FK_CONTENT_ON_SEGMENT" referencedColumnNames="id" referencedTableName="segment"/>
When I insert the data, spring boot JPA gives me the following error.
Caused by: oracle.jdbc.OracleDatabaseException: ORA-02201: sequence not allowed here
Also, I tried the other generation strategies as GenerationType.IDENTITY
, GenerationType.AUTO
and GenerationType.SEQUENCE
. Still, I'm having the issue. What can I do?