Skip to content

unique key Error.  #25

@finnbell

Description

@finnbell

JPA

@entity
@Getter
@Setter
@NoArgsConstructor
public class MenuEntity implements Serializable {

@Id
@GeneratedValue()
private Long id;

@ManyToOne(fetch = FetchType.LAZY)
@JoinColumn(name="parent_id")
private MenuEntity parent;

private String name;

@Column( nullable = false )
private int listOrder;

@Column( nullable = false , **unique = true**)
private String menuCode;

@OneToMany(mappedBy = "menuEntity")
private List<MenuItemEntity> menuItemList = new ArrayList<>();

....
}

P6spy SQL query excute ->
alter table menu_entity add constraint UK_lk5c2lk5kyawukpw7lvotbivg unique (menu_code);

Error ->
Error executing DDL "alter table menu_entity add constraint UK_lk5c2lk5kyawukpw7lvotbivg unique (menu_code)"

I know that, SQLite does not support "alter table ~~~ add constraint " ,
SQlite query should be " CREATE INDEX ~~~~ "

Also, I tried @table ( constraint ~~ ) , It was same problem.

It may be different Sqlite from Other SQL query.
So, do you fix that problem on Dialect ?

Thanks in advance!

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