Skip to content

Conversation

@gavinking
Copy link
Member

@gavinking gavinking commented Mar 13, 2025

presence of JTA was not detected due to misspelling of package name

[Please describe here what your change is about]


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license
and can be relicensed under the terms of the LGPL v2.1 license in the future at the maintainers' discretion.
For more information on licensing, please check here.


https://hibernate.atlassian.net/browse/HHH-19109

@hibernate-github-bot
Copy link

hibernate-github-bot bot commented Mar 13, 2025

Thanks for your pull request!

This pull request appears to follow the contribution rules.

› This message was automatically generated.

@gavinking gavinking changed the title fix use of @TransactionScoped by repository HHH-19109 fix use of @TransactionScoped by repository Mar 13, 2025
presence of JTA was not detected due to misspelling of package name
@gavinking gavinking force-pushed the jakartatransaction branch from 7104fe1 to b8c1be3 Compare March 13, 2025 21:15
@gavinking gavinking merged commit 3c1636f into hibernate:main Mar 13, 2025
25 of 26 checks passed
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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants