Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Spring Boot Support for [Doma](https://github.com/domaframework/doma)
<dependency>
<groupId>org.seasar.doma</groupId>
<artifactId>doma-processor</artifactId>
<version>3.6.0</version>
<version>3.8.0</version>
<optional>true</optional>
</dependency>
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public Dialect dialect(ObjectProvider<JdbcConnectionDetails> connectionDetailsPr
JdbcConnectionDetails connectionDetails = connectionDetailsProvider.getIfAvailable();
if (connectionDetails == null) {
throw new BeanCreationException(
"No connection details available. You will probably have to set 'doma.dialect' explicitly.");
"No JdbcConnectionDetails available. You will need to explicitly set 'doma.dialect' property in your configuration.");
}
DatabaseDriver databaseDriver = DatabaseDriver.fromJdbcUrl(connectionDetails.getJdbcUrl());
switch (databaseDriver) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,15 @@
import org.seasar.doma.jdbc.statistic.StatisticManager;

/**
* {@link Config} implementation used in doma-spring-boot.
* Implementation of {@link Config} used by the Doma Spring Boot integration.
* <p>
* This class encapsulates all configuration properties required by Doma,
* such as {@link DataSource}, {@link Dialect}, and {@link JdbcLogger}.
* <p>
* The configuration is built using a builder pattern through {@link DomaConfigBuilder}.
*
* @author Toshiaki Maki
* @see DomaConfigBuilder
*/
public class DomaConfig implements Config {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@ public DataSource dataSource() {
*
* @param dataSource dataSource to use
* @return chained builder
* @throws NullPointerException if dataSource is null
*/
public DomaConfigBuilder dataSource(DataSource dataSource) {
Objects.requireNonNull(dataSource, "dataSource must not be null");
this.dataSource = new TransactionAwareDataSourceProxy(dataSource);
return this;
}
Expand All @@ -72,7 +74,15 @@ public Dialect dialect() {
return dialect;
}

/**
* Set the Dialect.
*
* @param dialect the Dialect
* @return this instance
* @throws NullPointerException if dialect is null
*/
public DomaConfigBuilder dialect(Dialect dialect) {
Objects.requireNonNull(dialect, "dialect must not be null");
this.dialect = dialect;
return this;
}
Expand All @@ -81,7 +91,15 @@ public JdbcLogger jdbcLogger() {
return jdbcLogger;
}

/**
* Set the JdbcLogger.
*
* @param jdbcLogger the JdbcLogger
* @return this instance
* @throws NullPointerException if jdbcLogger is null
*/
public DomaConfigBuilder jdbcLogger(JdbcLogger jdbcLogger) {
Objects.requireNonNull(jdbcLogger, "jdbcLogger must not be null");
this.jdbcLogger = jdbcLogger;
return this;
}
Expand All @@ -90,7 +108,15 @@ public SqlFileRepository sqlFileRepository() {
return sqlFileRepository;
}

/**
* Set the SqlFileRepository.
*
* @param sqlFileRepository the SqlFileRepository
* @return this instance
* @throws NullPointerException if sqlFileRepository is null
*/
public DomaConfigBuilder sqlFileRepository(SqlFileRepository sqlFileRepository) {
Objects.requireNonNull(sqlFileRepository, "sqlFileRepository must not be null");
this.sqlFileRepository = sqlFileRepository;
return this;
}
Expand Down Expand Up @@ -146,7 +172,15 @@ public Naming naming() {
return naming;
}

/**
* Set the Naming convention.
*
* @param naming the Naming convention
* @return this instance
* @throws NullPointerException if naming is null
*/
public DomaConfigBuilder naming(Naming naming) {
Objects.requireNonNull(naming, "naming must not be null");
this.naming = naming;
return this;
}
Expand All @@ -173,8 +207,16 @@ public EntityListenerProvider entityListenerProvider() {
return entityListenerProvider;
}

/**
* Set the EntityListenerProvider.
*
* @param entityListenerProvider the EntityListenerProvider
* @return this instance
* @throws NullPointerException if entityListenerProvider is null
*/
public DomaConfigBuilder entityListenerProvider(
EntityListenerProvider entityListenerProvider) {
Objects.requireNonNull(entityListenerProvider, "entityListenerProvider must not be null");
this.entityListenerProvider = entityListenerProvider;
return this;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ public void testDialectMissingJdbConnectionDetails() {
BeanCreationException exception = assertThrows(BeanCreationException.class,
() -> this.context.refresh());
assertThat(exception.getMessage(), containsString(
"No connection details available. You will probably have to set 'doma.dialect' explicitly."));
"No JdbcConnectionDetails available. You will need to explicitly set 'doma.dialect' property in your configuration."));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,16 @@

import org.seasar.doma.jdbc.SqlBuilderSettings;

public class DomaSpringBootSqlBuilderSettings implements SqlBuilderSettings {

private final Predicate<String> shouldRemoveBlockComment;
private final Predicate<String> shouldRemoveLineComment;
private final boolean shouldRemoveBlankLines;
private final boolean shouldRequireInListPadding;

public DomaSpringBootSqlBuilderSettings(Predicate<String> shouldRemoveBlockComment,
Predicate<String> shouldRemoveLineComment, boolean shouldRemoveBlankLines,
boolean shouldRequireInListPadding) {
this.shouldRemoveBlockComment = shouldRemoveBlockComment;
this.shouldRemoveLineComment = shouldRemoveLineComment;
this.shouldRemoveBlankLines = shouldRemoveBlankLines;
this.shouldRequireInListPadding = shouldRequireInListPadding;
}
/**
* Implementation of {@link SqlBuilderSettings} for Spring Boot.
* <p>
* This record encapsulates the SQL builder settings used by Doma in a Spring Boot application.
*/
public record DomaSpringBootSqlBuilderSettings(
Predicate<String> shouldRemoveBlockComment,
Predicate<String> shouldRemoveLineComment,
boolean shouldRemoveBlankLines,
boolean shouldRequireInListPadding) implements SqlBuilderSettings {

@Override
public boolean shouldRemoveBlockComment(String comment) {
Expand Down