diff --git a/data-jdbc/src/main/java/io/micronaut/data/jdbc/annotation/JdbcRepository.java b/data-jdbc/src/main/java/io/micronaut/data/jdbc/annotation/JdbcRepository.java index dce8936181..405b0b1c31 100644 --- a/data-jdbc/src/main/java/io/micronaut/data/jdbc/annotation/JdbcRepository.java +++ b/data-jdbc/src/main/java/io/micronaut/data/jdbc/annotation/JdbcRepository.java @@ -65,12 +65,6 @@ * @return The dialect to use. */ @AliasFor(annotation = Repository.class, member = "dialect") - Dialect dialect() default Dialect.ANSI; + Dialect dialect(); - /** - * @return The dialect to use. - */ - @AliasFor(annotation = Repository.class, member = "dialect") - @AliasFor(annotation = JdbcRepository.class, member = "dialect") - String dialectName() default "ANSI"; } diff --git a/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2AuthorRepository.java b/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2AuthorRepository.java index e28bc21432..bd4f32f8a0 100644 --- a/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2AuthorRepository.java +++ b/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2AuthorRepository.java @@ -18,11 +18,12 @@ import io.micronaut.data.annotation.Query; import io.micronaut.data.jdbc.annotation.JdbcRepository; import io.micronaut.data.jdbc.mapper.SqlResultConsumer; +import io.micronaut.data.model.query.builder.sql.Dialect; import io.micronaut.data.tck.entities.Author; import io.micronaut.data.tck.entities.AuthorDTO; import io.micronaut.data.tck.entities.Book; -@JdbcRepository(dialectName = "H2") +@JdbcRepository(dialect = Dialect.H2) public interface H2AuthorRepository extends io.micronaut.data.tck.repositories.AuthorRepository { @Query("select *, author.name as author_name, author.nick_name as author_nick_name from book as book inner join author as author where book.title = :title and book.total_pages > :pages") diff --git a/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2CompanyRepository.java b/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2CompanyRepository.java index 32632388aa..f41af794e4 100644 --- a/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2CompanyRepository.java +++ b/data-jdbc/src/test/java/io/micronaut/data/jdbc/h2/H2CompanyRepository.java @@ -15,10 +15,11 @@ */ package io.micronaut.data.jdbc.h2; +import io.micronaut.data.model.query.builder.sql.Dialect; import io.micronaut.data.tck.repositories.CompanyRepository; import io.micronaut.data.jdbc.annotation.JdbcRepository; -@JdbcRepository(dialectName = "H2") +@JdbcRepository(dialect = Dialect.H2) public interface H2CompanyRepository extends CompanyRepository { } diff --git a/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/Dialect.java b/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/Dialect.java index 999a6b5513..5c9e433f9d 100644 --- a/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/Dialect.java +++ b/data-model/src/main/java/io/micronaut/data/model/query/builder/sql/Dialect.java @@ -21,7 +21,14 @@ import java.util.EnumSet; -import static io.micronaut.data.annotation.Join.Type.*; +import static io.micronaut.data.annotation.Join.Type.ALL_TYPES; +import static io.micronaut.data.annotation.Join.Type.DEFAULT; +import static io.micronaut.data.annotation.Join.Type.FETCH; +import static io.micronaut.data.annotation.Join.Type.INNER; +import static io.micronaut.data.annotation.Join.Type.LEFT; +import static io.micronaut.data.annotation.Join.Type.LEFT_FETCH; +import static io.micronaut.data.annotation.Join.Type.RIGHT; +import static io.micronaut.data.annotation.Join.Type.RIGHT_FETCH; /** * The SQL dialect to use. @@ -33,7 +40,7 @@ public enum Dialect { /** * H2 database. */ - H2(true, false, true, + H2(true, false, EnumSet.of( DEFAULT, LEFT, @@ -46,7 +53,7 @@ public enum Dialect { /** * MySQL 5.5 or above. */ - MYSQL(true, true, false, EnumSet.of( + MYSQL(true, true, EnumSet.of( DEFAULT, LEFT, LEFT_FETCH, @@ -58,23 +65,22 @@ public enum Dialect { /** * Postgres 9.5 or later. */ - POSTGRES(true, false, true, ALL_TYPES), + POSTGRES(true, false, ALL_TYPES), /** * SQL server 2012 or above. */ - SQL_SERVER(false, false, false, ALL_TYPES), + SQL_SERVER(false, false, ALL_TYPES), /** * Oracle 12c or above. */ - ORACLE(true, true, false, ALL_TYPES, true), + ORACLE(true, true, ALL_TYPES, true), /** * Ansi compliant SQL. */ - ANSI(true, false, true, ALL_TYPES); + ANSI(true, false, ALL_TYPES); private final boolean supportsBatch; private final boolean stringUUID; - private final boolean supportsArrays; private final boolean supportsJsonEntity; @@ -82,50 +88,42 @@ public enum Dialect { /** * Allows customization of batch support. - * @param supportsBatch If batch is supported - * @param stringUUID Does the dialect require a string UUID - * @param supportsArrays Does the dialect supports arrays + * + * @param supportsBatch If batch is supported + * @param stringUUID Does the dialect require a string UUID * @param joinTypesSupported EnumSet of supported join types. */ - Dialect(boolean supportsBatch, boolean stringUUID, boolean supportsArrays, EnumSet joinTypesSupported) { - this(supportsBatch, stringUUID, supportsArrays, joinTypesSupported, false); + Dialect(boolean supportsBatch, boolean stringUUID, EnumSet joinTypesSupported) { + this(supportsBatch, stringUUID, joinTypesSupported, false); } /** * The constructor with all parameters. * - * @param supportsBatch If batch is supported - * @param stringUUID Does the dialect require a string UUID - * @param supportsArrays Does the dialect supports arrays + * @param supportsBatch If batch is supported + * @param stringUUID Does the dialect require a string UUID * @param joinTypesSupported EnumSet of supported join types. * @param supportsJsonEntity Whether JSON entity is supported */ - Dialect(boolean supportsBatch, boolean stringUUID, boolean supportsArrays, EnumSet joinTypesSupported, boolean supportsJsonEntity) { + Dialect(boolean supportsBatch, boolean stringUUID, EnumSet joinTypesSupported, boolean supportsJsonEntity) { this.supportsBatch = supportsBatch; this.stringUUID = stringUUID; - this.supportsArrays = supportsArrays; this.joinTypesSupported = joinTypesSupported; this.supportsJsonEntity = supportsJsonEntity; } /** * Some drivers and dialects do not support JDBC batching. This allows customization. + * * @return True if batch is supported. */ public final boolean allowBatch() { return supportsBatch; } - /** - * Some databases support arrays and the use of {@link java.sql.Connection#createArrayOf(String, Object[])}. - * @return True if arrays are supported. - */ - public final boolean supportsArrays() { - return supportsArrays; - } - /** * Returns compatible dialect dataype. + * * @param type the type * @return The dialect compatible DataType * @since 2.0.1 diff --git a/data-processor/src/test/groovy/io/micronaut/data/processor/visitors/EmbeddedSpec.groovy b/data-processor/src/test/groovy/io/micronaut/data/processor/visitors/EmbeddedSpec.groovy index b211ff58d8..25b3b89e7f 100644 --- a/data-processor/src/test/groovy/io/micronaut/data/processor/visitors/EmbeddedSpec.groovy +++ b/data-processor/src/test/groovy/io/micronaut/data/processor/visitors/EmbeddedSpec.groovy @@ -253,7 +253,7 @@ interface LikeRepository extends CrudRepository { void "test jdbc compile embedded id count query"() { given: def repository = buildRepository('test.LikeRepository', """ -import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder; +import io.micronaut.data.model.query.builder.sql.Dialect;import io.micronaut.data.model.query.builder.sql.SqlQueryBuilder; @javax.persistence.Entity @javax.persistence.Table(name = "likes") @@ -291,7 +291,7 @@ class LikeId { } } -@io.micronaut.data.jdbc.annotation.JdbcRepository +@io.micronaut.data.jdbc.annotation.JdbcRepository(dialect = Dialect.ANSI) @io.micronaut.context.annotation.Executable interface LikeRepository extends CrudRepository { long countByLikeIdImageIdentifier(UUID likeIdImageIdentifier); diff --git a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/annotation/R2dbcRepository.java b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/annotation/R2dbcRepository.java index 41c2dab726..182356dfba 100644 --- a/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/annotation/R2dbcRepository.java +++ b/data-r2dbc/src/main/java/io/micronaut/data/r2dbc/annotation/R2dbcRepository.java @@ -81,12 +81,5 @@ * @return The dialect to use. */ @AliasFor(annotation = Repository.class, member = "dialect") - Dialect dialect() default Dialect.ANSI; - - /** - * @return The dialect to use. - */ - @AliasFor(annotation = Repository.class, member = "dialect") - @AliasFor(member = "dialect") - String dialectName() default "ANSI"; + Dialect dialect(); }