diff --git a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java index 2916b91eb0..74013286f9 100644 --- a/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java +++ b/hibernate-community-dialects/src/main/java/org/hibernate/community/dialect/SQLiteDialect.java @@ -13,6 +13,7 @@ import java.util.Date; import java.util.TimeZone; import org.hibernate.ScrollMode; +import org.hibernate.boot.Metadata; import org.hibernate.boot.model.FunctionContributions; import org.hibernate.boot.model.TypeContributions; import org.hibernate.boot.model.relational.SqlStringGenerationContext; @@ -37,6 +38,7 @@ import org.hibernate.exception.spi.TemplatedViolatedConstraintNameExtractor; import org.hibernate.exception.spi.ViolatedConstraintNameExtractor; import org.hibernate.internal.util.JdbcExceptionHelper; import org.hibernate.mapping.Column; +import org.hibernate.mapping.UniqueKey; import org.hibernate.query.SemanticException; import org.hibernate.query.sqm.IntervalType; import org.hibernate.dialect.NullOrdering; @@ -149,6 +151,19 @@ public class SQLiteDialect extends Dialect { public String getColumnDefinitionUniquenessFragment(Column column, SqlStringGenerationContext context) { return " unique"; } + + /** + * Alter table support in SQLite is very limited and does + * not include adding a unique constraint (as of 9/2023). + * + * @return always empty String + * @see SQLite SQL omissions + */ + @Override + public String getAlterTableToAddUniqueKeyCommand(UniqueKey uniqueKey, Metadata metadata, SqlStringGenerationContext context) { + return ""; + } + } @Override @@ -402,6 +417,16 @@ public class SQLiteDialect extends Dialect { return NullOrdering.SMALLEST; } + /** + * Generated keys are not supported by the (standard) Xerial driver (9/2022). + * + * @return false + */ + @Override + public boolean getDefaultUseGetGeneratedKeys() { + return false; + } + @Override public SqlAstTranslatorFactory getSqlAstTranslatorFactory() { return new StandardSqlAstTranslatorFactory() {