Skip to content

How to remove/replace existing annotations? #917

@initshdb

Description

@initshdb

Thank you for this wonderful library. However, I am stuck at one point. I am able to add annotations to a field/method, but not able to replace or remove existing annotation.

I have the following requirement, on a method,

@OneToOne (fetch = FetchType.LAZY) // I want to remove / replace annotation values 
public Employee getEmployee()

I would like to,

  1. Remove the existing annotation @OneToOne (fetch = FetchType.LAZY)
  2. Replace the existing annotation's values with @OneToOne (fetch = FetchType.EAGER)

I am using the bytebuddy maven plugin, using the DynamicType.Builder to visit the method to add new annotation using MemberAttributeExtension.ForMethod().annotateMethod(), but not sure how to remove or replace existing annotations.

I tried using MemberSubstitution, but did not get that to work for removing / replacing annotations

For your help I will be immensely grateful.

Metadata

Metadata

Assignees

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions