-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
unique key Error. #25
Comments
Could you please check <!-- value="create" to build a new database on each run; value="update" to modify an existing database; value="create-drop" means the same as "create" but also drops tables when Hibernate closes; value="validate" makes no changes to the database -->
<!--property name="hibernate.hbm2ddl.auto" value="validate"/-->
<property name="hibernate.hbm2ddl.auto" value="none"/> Since SQLite doesn't fully support |
spring.jpa.hibernate.ddl-auto=update I see. I've just excute native query by myself. Thanks. |
fixed /**
* SQLite use table creation sql to define unique constraints.
*/
@Override
public String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context) {
return "";
}
/**
* SQLite do not support 'alter table' to add constraints.
*/
@Override
public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) {
return "";
}
/**
* SQLite uses table creation sql to define unique constraints, and do not support alter table sql to add
* constraints.
* Such as "create table person( first_name varchar(255),last_name varchar(255),unique(first_name, last_name) )".
*/
@Override
public String getTableCreationUniqueConstraintsFragment(Table table, SqlStringGenerationContext context) {
// get all uniqueKeys
StringBuilder builder = new StringBuilder();
Iterator<UniqueKey> iter = table.getUniqueKeyIterator();
while (iter.hasNext()) {
UniqueKey key = iter.next();
builder.append(", ").append(uniqueConstraintSql(key));
}
return builder.toString();
}
/**
* SQLite do not support 'drop constraint'.
*/
public String getAlterTableToDropUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata,
SqlStringGenerationContext context) {
return "";
} |
Where can I find SqlStringGenerationContext ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
JPA
@entity
@getter
@Setter
@NoArgsConstructor
public class MenuEntity implements Serializable {
....
}
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!
The text was updated successfully, but these errors were encountered: