jakartaee / jakartaee/persistence
defaulted attribute access type for a hierarchy when root is annotated @Access
- Dominant language
- Java
- Stars
- 268
- Forks
- 78
- Avg merge
- 1d 6h
- Merged PRs (30d)
- 13
Description
If the root of an entity class hierarchy is annotated `@Access`, then it seems to me that the spec is very unclear on how the default access type for the class hierarchy is determined. [The effect of `@Access` is not inherited, and I don't think it should be.]
So what is the expected behavior if a subclass does not explicitly specify `@Access`?
Either:
1. it's an error: all classes in an entity hierarchy with a root annotated `@Access` must also be annotated `@Access`, or
2. we consider all subclasses of the root class in determining the default access type.
I imagine that 2 is what was intended, but it's unclear. And, since the `@Id` attribute is declared by the root entity, the subclasses in principle might not have any mapping annotations allowing the default access type to be inferred. Consider:
```java
@Entity @Access(FIELD)
class Root {
@Id String id;
}
@Entity
class Child extends Root {
String name;
String getName();
void setName(String name);
}
```
what is the access type of `Child`? I don't think it has one.
We need to say something more explicit here.
Contributor guide
Research direction
Review the Jakarta Persistence access-type rules against the Root/Child example in the issue, focusing on how a subclass without @Access determines its default. Compare the two proposed interpretations and identify the specification wording needed; done means the behavior for this hierarchy is explicitly defined.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend, documentation
- Issue type
- Documentation
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 25/100