How can i use Transient and @MetaProperty not just for reading but also for writing?

I want to extend User as ExtUser as Follows:

@Entity(name = "petclinic_ExtUser")
@Extends(User.class)
public class ExtUser extends User {

    @Transient
    @MetaProperty(related="userRoles")
    private List<Role> roles;

    public List<Role> getRoles() {
        if (this.getUserRoles() == null || this.getUserRoles().isEmpty()) {
            return new ArrayList<Role>();
        }
        List<Role> roleList = new ArrayList<Role>();
        for (UserRole userRole : this.getUserRoles()) {
            roleList.add(userRole.getRole());
        }
        return roleList;
    }

Using rest API, I can perfectly get role list by defining a view with roles.

But if I want to put or post an extUser by just sending roles list to server, how can I get the roles attribute values and rewrite its userRoles attribute.

The put or post JSON is as follows:

{"_entityName":“petclinic_ExtUser”,"_instanceName":“u11 [u11]”,“id”:“95685734-f6d9-f975-580e-ab21ac611090”,“loginLowerCase”:“u11”,“roles”:[{“id”:“0c018061-b26f-4de2-a5be-dff348347f93”}],“login”:“u11”,“changePasswordAtNextLogon”:false,“group”:{“id”:“0fa2b1a5-1d68-4d69-9fbd-dff348347f93”},“active”:true,“passwordEncryption”:“bcrypt”,“name”:“u11”}

Have you tried to use entity listeners like BeforeAttachEntityListener or BeforeUpdateEntityListener?

Thanks for reply. But the core problem is not on EntityListener. The entity controller of rest api will not pass/copy the roles value from client json to entity’s attribute. So, in EntityListener, you can not get any value sent by client.

I see. Could you file an issue with the whole explanation?