Skip to content

Commit

Permalink
Merge pull request #7 from mraible/r2dbc-support
Browse files Browse the repository at this point in the history
Add Component to R2DBC repositories
  • Loading branch information
Matt Raible authored Feb 7, 2022
2 parents e859b13 + 20674b6 commit 83288ac
Show file tree
Hide file tree
Showing 8 changed files with 521 additions and 11 deletions.
21 changes: 11 additions & 10 deletions README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,14 @@ org.springframework.beans.factory.BeanCreationException: Error creating bean wit
Circular depends-on relationship between 'dataSourceScriptDatabaseInitializer' and 'liquibase'
----
. Build with `./mvnw package -Pnative,prod -DskipTests`
. If you're using Spring WebFlux with R2DBC, we https://github.com/jhipster/generator-jhipster/issues/17271#issuecomment-1029581856[haven't figured that one out yet].
. If you're using Spring WebFlux with R2DBC, you'll need to add `@Component` to your Impl classes and add `SimpleR2dbcRepository` to your type hints and `com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]` as a typeName for Liquibase.
+
----
@TypeHint(types = {
...
org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository.class
}, typeNames = "com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]")
----
. If Spring MVC, add names to any `@RequestParam` and `@PathVariable` annotations.
+
Expand All @@ -252,16 +257,12 @@ public ResponseEntity<?> logout(HttpServletRequest request, @AuthenticationPrinc
OidcIdToken idToken = oidcUser.getIdToken();
----
. Build with `./mvnw package -Pnative,prod -DskipTests`
== Known Issues
- `-DskipTests` is needed for both Spring MVC and WebFlux. This seems to be caused by Mockito.
- Creating a new `Post` or `Tag` in the `postgres-mvc` project doesn't work. The error is:
+
----
Caused by: com.fasterxml.jackson.databind.JsonMappingException: Unable to perform requested lazy initialization
[com.mycompany.myapp.domain.Post.tags] - no session and settings disallow loading outside the Session
(through reference chain: java.util.Collections$UnmodifiableRandomAccessList[0]->com.mycompany.myapp.domain.Post["tags"])
----
- Creating a new `Post` or `Tag` in the `postgres-mvc` project doesn't work. This is a [JHipster bug](https://github.com/jhipster/generator-jhipster/issues/17794) and doesn't seem to be related to Spring Native.
- Several of JHipster's Administration features don't work: metrics, logs, and configuration.
- Metrics: `UnsupportedFeatureError: ThreadMXBean methods`
- Logs: `/management/loggers` returns HTML instead of JSON
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,16 @@
import tech.jhipster.config.DefaultProfileUtil;
import tech.jhipster.config.JHipsterConstants;

@org.springframework.nativex.hint.TypeHint(types = { org.HdrHistogram.Histogram.class, org.HdrHistogram.ConcurrentHistogram.class })
@org.springframework.nativex.hint.TypeHint(types = {
org.HdrHistogram.Histogram.class,
org.HdrHistogram.ConcurrentHistogram.class,
org.springframework.data.r2dbc.repository.support.SimpleR2dbcRepository.class,
liquibase.configuration.LiquibaseConfiguration.class,
com.zaxxer.hikari.HikariDataSource.class,
liquibase.change.core.LoadDataColumnConfig.class,
tech.jhipster.domain.util.FixedPostgreSQL10Dialect.class,
org.hibernate.type.TextType.class,
}, typeNames = "com.zaxxer.hikari.util.ConcurrentBag$IConcurrentBagEntry[]")
@SpringBootApplication
@EnableConfigurationProperties({ LiquibaseProperties.class, ApplicationProperties.class })
public class PostgresApp {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,15 @@
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.r2dbc.core.RowsFetchSpec;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
* Spring Data SQL reactive custom repository implementation for the Blog entity.
*/
@SuppressWarnings("unused")
@Component
class BlogRepositoryInternalImpl extends SimpleR2dbcRepository<Blog, Long> implements BlogRepositoryInternal {

private final DatabaseClient db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.r2dbc.core.RowsFetchSpec;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
* Spring Data SQL reactive custom repository implementation for the Post entity.
*/
@SuppressWarnings("unused")
@Component
class PostRepositoryInternalImpl extends SimpleR2dbcRepository<Post, Long> implements PostRepositoryInternal {

private final DatabaseClient db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
import org.springframework.data.relational.repository.support.MappingRelationalEntityInformation;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.r2dbc.core.RowsFetchSpec;
import org.springframework.stereotype.Component;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

/**
* Spring Data SQL reactive custom repository implementation for the Tag entity.
*/
@SuppressWarnings("unused")
@Component
class TagRepositoryInternalImpl extends SimpleR2dbcRepository<Tag, Long> implements TagRepositoryInternal {

private final DatabaseClient db;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.springframework.data.relational.core.sql.Expression;
import org.springframework.data.relational.core.sql.Table;
import org.springframework.r2dbc.core.DatabaseClient;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Repository;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
Expand Down Expand Up @@ -57,6 +58,7 @@ interface UserRepositoryInternal {
Flux<User> findAllWithAuthorities(Pageable pageable);
}

@Component
class UserRepositoryInternalImpl implements UserRepositoryInternal {

private final DatabaseClient db;
Expand Down
Loading

0 comments on commit 83288ac

Please sign in to comment.