[hibernate-dev] Another @Access quandry

Hardy Ferentschik hardy at hibernate.org
Wed Mar 26 16:26:18 EDT 2014


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