[hibernate-dev] Another @Access quandry

Steve Ebersole steve at hibernate.org
Wed Mar 26 16:39:52 EDT 2014


One thing I suggested on IRC (because of the awesomely centralized job you
did here) was to possibly extract this into a strategy.  We could have a
legacy one that follows what Emmanuel decided initially, and then another
that does what we all agree here as the correct thing moving forward.


On Wed, Mar 26, 2014 at 3:26 PM, Hardy Ferentschik <hardy at hibernate.org>wrote:

>
> On 26 Jan 2014, at 21:09, Steve Ebersole <steve at hibernate.org> wrote:
>
> > I really like the general approach you did in metamodel.  In fact, even
> though I heavily refactored most of that package, the way annotated members
> are found is largely unchanged.
> >
> > But specifically, take Sanne's example.  Access(PROPERTY) for the class.
>  Then for one attribute they want field *access* (runtime).  How would you
> see that?  Like I said initially, I think there are 2 potentially valid
> ways to support this.
> >
> > First,
> >
> > @Entity
> > @Access(AccessType.PROPERTY)
> > public class Course3 {
> >     @Id
> >     @GeneratedValue
> >     @Access(AccessType.FIELD)
> >     private long id;
> >     ...
> >
> >     public long getId() {
> >         return id;
> >     }
> >     ...
> > }
> >
> > This approach gives credence to the passage I have been quoting here:
> "It is not permitted to specify a field as Access(PROPERTY) or a property
> as Access(FIELD)".
> >
> >
> > Second,
> >
> > @Entity
> > @Access(AccessType.PROPERTY)
> > public class Course3 {
> >     private long id;
> >     ...
> >
> >     @Id
> >     @GeneratedValue
> >     @Access(AccessType.FIELD)
> >     public long getId() {
> >         return id;
> >     }
> >     ...
> > }
> >
> > I prefer the first one.
>
> I prefer #1 as well


More information about the hibernate-dev mailing list