javajakarta-eepojoannotated-pojos

How to clear (remove) all annotations from a Java (EE) entity bean?


Is there a way to automatically (or with a one-click trigger to) remove all annotations from a class source code in whichever IDE?

My specific requirement is to convert all entity beans into just un-annotated POJOs which will be used by plain JDBC controllers.

Sample code fragment:

@Entity
@NamedQueries({
    @NamedQuery(name = "Gpu.findAll", query = "SELECT g FROM GPU g"),
    @NamedQuery(name = "Gpu.findByArascl", query = "SELECT g FROM GPU g WHERE g.arascl = :arascl"),
    @NamedQuery(name = "Gpu.findByUnvan", query = "SELECT g FROM GPU g WHERE g.unvan = :unvan")})
public class GPU implements Serializable {

    @Id
    @Basic(optional = false)
    @Size(min = 1, max = 15)
    @Column(nullable = false, length = 15)
    private String arascl;
    @Column(name = "BAGLI_CALISAN_SAYISI")
    private int bagliCalisanSayisi;
    @Size(max = 24)
    @Column(name = "BOLGE_TANIMI", length = 24)
    private String bolgeTanimi;
    @Size(max = 35)
    @Column(length = 35)
    private String eladi;
    private Integer elmkod;
    @Size(max = 30)
    @Column(length = 30)
    private String elsoy;
    @Size(max = 30)
    @Column(name = "SUBE_TANIMI", length = 30)

Solution

  • Try use regexp to replace this:

    @.+
    

    with empty string.