Skip to content

Commit

Permalink
Merge pull request #87 from flynndi/dev
Browse files Browse the repository at this point in the history
Test
  • Loading branch information
flynndi authored Mar 6, 2024
2 parents 4239bd9 + b0e85a9 commit 093f609
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ BookDetailView {
authors {
#allScalars
}
}

input BookInput {

#allScalars(Book)

id(store)

authors {
#allScalars(Author)
-id
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
input UserRoleInput {

#allScalars(UserRole)

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@
import jakarta.inject.Singleton;

import io.quarkiverse.jimmer.runtime.cache.impl.QuarkusTransactionCacheOperator;
import io.quarkus.agroal.DataSource;

@Singleton
public class QuarkusTransactionCacheOperatorConfig {

// @Singleton
@Singleton
@DataSource("DB2")
public QuarkusTransactionCacheOperator quarkusTransactionCacheOperator() {
return new QuarkusTransactionCacheOperator();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package io.quarkiverse.jimmer.it.repository;

import java.util.UUID;

import jakarta.enterprise.context.ApplicationScoped;

import io.quarkiverse.jimmer.it.entity.UserRole;
import io.quarkiverse.jimmer.runtime.repository.support.JRepository;
import io.quarkus.agroal.DataSource;

@ApplicationScoped
@DataSource("DB2")
public class UserRoleRepository extends JRepository<UserRole, UUID> {
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
import static io.quarkiverse.jimmer.it.entity.Fetchers.*;

import java.util.List;
import java.util.UUID;

import jakarta.inject.Inject;
import jakarta.transaction.Transactional;
import jakarta.ws.rs.*;
import jakarta.ws.rs.core.MediaType;
import jakarta.ws.rs.core.Response;
Expand All @@ -18,10 +20,13 @@
import io.quarkiverse.jimmer.it.entity.BookFetcher;
import io.quarkiverse.jimmer.it.entity.Tables;
import io.quarkiverse.jimmer.it.entity.dto.BookDetailView;
import io.quarkiverse.jimmer.it.entity.dto.UserRoleInput;
import io.quarkiverse.jimmer.it.repository.BookRepository;
import io.quarkiverse.jimmer.it.repository.BookStoreRepository;
import io.quarkiverse.jimmer.it.repository.UserRoleRepository;
import io.quarkiverse.jimmer.runtime.Jimmer;
import io.quarkiverse.jimmer.runtime.repository.support.Page;
import io.quarkus.agroal.DataSource;

@Path("/testResources")
@Produces(MediaType.APPLICATION_JSON)
Expand All @@ -34,6 +39,10 @@ public class TestResources {
@Inject
BookStoreRepository bookStoreRepository;

@Inject
@DataSource("DB2")
UserRoleRepository userRoleRepository;

@GET
@Path("/test")
public Response test() {
Expand Down Expand Up @@ -93,6 +102,20 @@ public Response testBookRepositoryViewById(@RestQuery long id) {
return Response.ok(bookRepository.viewer(BookDetailView.class).findNullable(id)).build();
}

@GET
@Path("/testUserRoleRepositoryById")
public Response UserRoleRepositoryById(@RestQuery UUID id) {
return Response.ok(userRoleRepository.findNullable(id)).build();
}

@POST
@Path("/testUserRoleRepositoryTransactional")
@Transactional(rollbackOn = Exception.class)
public Response testUserRoleRepositoryTransactional(UserRoleInput userRoleInput) {
userRoleRepository.update(userRoleInput);
return Response.ok().build();
}

private static final Fetcher<Book> COMPLEX_BOOK = BOOK_FETCHER.allScalarFields()
.store(BOOK_STORE_FETCHER.name())
.authors(AUTHOR_FETCHER.firstName().lastName());
Expand Down
2 changes: 1 addition & 1 deletion integration-tests/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ quarkus:
show-sql: true
pretty-sql: true
inline-sql-variables: true
trigger-type: BOTH
trigger-type: TRANSACTION_ONLY
database-validation:
mode: NONE
error-translator:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public class JRepository<E, ID> implements io.quarkiverse.jimmer.runtime.reposit
protected final JSqlClientImplementor sqlClient = Utils.validateSqlClient(sql());

public JSqlClient sql() {
Class<?> actualType = ClientProxy.unwrap(this.getClass()).getSuperclass();
Class<?> actualType = ClientProxy.unwrap(this.getClass());
if (null != actualType.getAnnotation(DataSource.class)) {
return Jimmer.getJSqlClient(actualType.getAnnotation(DataSource.class).value());
}
Expand Down

0 comments on commit 093f609

Please sign in to comment.