Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -234,9 +234,9 @@ private boolean handleSettings(ProcessingEnvironment environment) {
final PackageElement jakartaContextPackage =
context.getProcessingEnvironment().getElementUtils()
.getPackageElement( "jakarta.enterprise.context" );
final PackageElement jakartaTransactionsPackage =
final PackageElement jakartaTransactionPackage =
context.getProcessingEnvironment().getElementUtils()
.getPackageElement( "jakarta.transactions" );
.getPackageElement( "jakarta.transaction" );
final PackageElement jakartaDataPackage =
context.getProcessingEnvironment().getElementUtils()
.getPackageElement( "jakarta.data" );
Expand Down Expand Up @@ -267,7 +267,7 @@ && packagePresent(quarkusOrmPanachePackage) ) {
context.setAddNonnullAnnotation( packagePresent(jakartaAnnotationPackage) );
context.setAddGeneratedAnnotation( packagePresent(jakartaAnnotationPackage) );
context.setAddDependentAnnotation( packagePresent(jakartaContextPackage) );
context.setAddTransactionScopedAnnotation( packagePresent(jakartaTransactionsPackage) );
context.setAddTransactionScopedAnnotation( packagePresent(jakartaTransactionPackage) );
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @gavinking ,
Just wanted to check with you as I was updating a Jakarta Data quickstart for Quarkus and noticed that the tests started failing, and it led me to this change 😃.

Let's say there's a repository:

@Repository
public interface FruitRepository extends CrudRepository<Fruit, Integer> {
	@Find
	Stream<Fruit> findAll(Order<Fruit> order);
}

and then a rest resource using it:

@Path("fruits")
@ApplicationScoped
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
public class FruitResource {

	@Inject FruitRepository repository;

	@GET
	public List<Fruit> get() {
		return repository.findAll( Order.by( Sort.asc( Fruit_.NAME ) ) ).toList();
	}
}

Before this change, it worked "fine" since there was no @TransactionScoped on the generated repository impl. Now, with the fix in place, this code starts failing as it's missing a transaction:

jakarta.enterprise.context.ContextNotActiveException: TransactionScoped context was not active when trying to obtain a bean instance for a client proxy of CLASS bean [class=org.acme.hibernate.orm.FruitRepository_, id=TvJttWO9ga0P9U-D0WtDkfqtuGU]
                at io.quarkus.arc.impl.ClientProxies.notActive(ClientProxies.java:76)

Now, I'll put the @Transactional annotation on the rest methods that use the repository, to make the thing work. But I was wondering whether we should or shouldn't allow calling repository "find" methods outside of a transaction?

context.setDataEventPackageAvailable( packagePresent(dataEventPackage) );
context.setQuarkusInjection( packagePresent(quarkusOrmPackage) );
context.setUsesQuarkusOrm( packagePresent(quarkusOrmPanachePackage) );
Expand Down
Loading