Skip to content

Commit b9419e0

Browse files
committed
HHH-19374 make repositories always @Dependent-scoped
I don't love this at all -- see the comment :-/
1 parent b7a24c2 commit b9419e0

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

tooling/metamodel-generator/src/main/java/org/hibernate/processor/annotation/AnnotationMetaEntity.java

+9-8
Original file line numberDiff line numberDiff line change
@@ -349,14 +349,15 @@ public boolean isInjectable() {
349349

350350
@Override
351351
public String scope() {
352-
if (jakartaDataRepository) {
353-
return context.addTransactionScopedAnnotation()
354-
? "jakarta.transaction.TransactionScoped"
355-
: "jakarta.enterprise.context.RequestScoped";
356-
}
357-
else {
358-
return "jakarta.enterprise.context.Dependent";
359-
}
352+
// @TransactionScoped doesn't work here because repositories
353+
// are supposed to be able to demarcate transactions, which
354+
// means they should be injectable when there is no active tx
355+
// @RequestScoped doesn't work because Arc folks think this
356+
// scope should only be active during a HTTP request, which
357+
// is simply wrong according to me, but whatever
358+
// @ApplicationScoped could work in principle, but buys us
359+
// nothing additional, since repositories are stateless
360+
return "jakarta.enterprise.context.Dependent";
360361
}
361362

362363
@Override

0 commit comments

Comments
 (0)