jeudi 21 juillet 2016

How do you remove a Java Annotation at Runtime (probably using Reflection)?

We are building a tool (for internal use) that only works if the javax.persistence.GeneratedValue annotation is removed from our source code (we are setting the Id in the tool, which is rejected due to the GeneratedValue annotation)... but for normal operations, we require this annotation.

How do you remove a Java Annotation at Runtime (probably using Reflection)?

This is my class:

@Entity
public class PersistentClass{
  @Id
  @GeneratedValue(strategy = GenerationType.AUTO)
  private long id;

  // ... Other data
}

This is what I would like to be able to change it to, at runtime:

@Entity
public class PersistentClass{
  @Id
  private long id;

  // ... Other data
}

Thanks!





Aucun commentaire:

Enregistrer un commentaire