Skip to content

AutoIncrement failing #36

@29swastik

Description

@29swastik

I have a table named collections in SQLite database with id as autoincrement and I’m using Spring Boot + Hibernate to connect to SQLite database. I’ve found that insert to collections table is failing with following error

What could be the reason for this?

Error Message

org.springframework.dao.DataIntegrityViolationException: A different object with the same identifier value
was already associated with the session : [com.product.cache.engine.entity.Collection#1624314]; nested 
exception is javax.persistence.EntityExistsException: A different object with the same identifier value was 
already associated with the session : [com.product.cache.engine.entity.Collection#1624314]

Entity class

@Data
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonIgnoreProperties(ignoreUnknown = true)
@ToString(doNotUseGetters = true)
@NoArgsConstructor
@AllArgsConstructor
@EqualsAndHashCode
@Builder
@Entity
@Table(name = TableConstants.COLLECTIONS)
public class Collection {

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Column(name = TableConstants.ENTITY_ID)
  private Long id;

  @Column(name = TableConstants.PRODUCT_ID)
  @JsonProperty(value = TableConstants.PRODUCT_ID)
  private Long productId;

  @Column(name = TableConstants.COLLECTION_ID)
  @JsonProperty(value = TableConstants.COLLECTION_ID)
  private Long collectionId;

  @Column(name = TableConstants.BOT_REF)
  @JsonProperty(value = TableConstants.BOT_REF)
  private Integer botRef;

  @Column(name = TableConstants.SHOP_DOMAIN)
  @JsonProperty(value = TableConstants.SHOP_DOMAIN)
  private String shopDomain;

  @Column(name = TableConstants.DESCRIPTION)
  @JsonProperty(value = TableConstants.DESCRIPTION)
  private String description;

  @Column(name = TableConstants.HANDLE)
  @JsonProperty(value = TableConstants.HANDLE)
  private String handle;

  @Column(name = TableConstants.TITLE)
  @JsonProperty(value = TableConstants.TITLE)
  private String title;

  @Column(name = TableConstants.IMAGE_URL)
  @JsonProperty(value = TableConstants.IMAGE_URL)
  private String imageUrl;

  @Column(name = TableConstants.UPDATED_AT)
  @JsonProperty(value = TableConstants.UPDATED_AT)
  @JsonFormat(shape= JsonFormat.Shape.STRING, pattern="yyyy-MM-dd HH:mm:ss")
  private Timestamp updatedAt;
}

gwenn SQLite-dialect & xerial jdbc-driver versions

implementation("org.xerial:sqlite-jdbc:3.36.0.3")
implementation("com.github.gwenn:sqlite-dialect:0.1.0")

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions