Skip to content

Commit e0c81b9

Browse files
committed
make repositories always @Dependent-scoped
I don't love this at all -- see the comment :-/
1 parent 4b8ba5c commit e0c81b9

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -354,14 +354,15 @@ public boolean isInjectable() {
354354

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

367368
@Override

0 commit comments

Comments
 (0)