Java共享getter,setter,属性但不是anotations

时间:2015-12-18 04:27:56

标签: java object annotations

我有这个代码(只需用ALOT乘以属性数):

@Entity
@Table(name = "MY_TABLE")
@Immutable
public class MyEntity {

    @Id
    @Column(name = "ID")
    private String id;
    public static final String PROPERTYNAME_ID = "id";

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

/* used by JPA, needs to have same getters/setters as MyEntity */
public class MyEntityCriteria { 

    private String id;

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }
}

有没有办法在这些类之间共享属性,getter和setter? ('延伸'不起作用,因为它也分享注释......)

0 个答案:

没有答案