java - Can JPA entity inherit @Version from an interface method? -


i defined versioned interface, expecting implement on persisted entity wanted use jpa versioning features (e.g., comparing version mid-air collisions, auto-incrementing on updates).

public interface versioned {     @version     int getrevision(); } 

this doesn't save (if any) coding, gives me marker interface had plans later.

public class foo implements versioned {     private int revision;      @override     public int getrevision() {             return revision;     } } 

@version allowed on methods, , expected foo inherit characteristic versioned interface. not appear case. can update instance of foo in database, revision number doesn't change automatically.

if, however, add @version annotation implementation, works expected:

    @version     private int revision; 

i'm not stuck - can functionality need. i'm curious: there "trick" getting work annotation on interface's method? or can point me documentation of why doesn't work expect?

annotation inheritance doesn't work on methods. documentation of @inherited:

note meta-annotation type has no effect if annotated type used annotate other class. note meta-annotation causes annotations inherited superclasses; annotations on implemented interfaces have no effect.


Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -