Thanks for your answer. I guess I found another way:
@Entity
public class B {
private @Id @GeneratedValue Long id;
private @Transient Long a_id;
private @JsonbTransient @ManyToOne @JoinColumn(name = "a_id") A a;
...
}
This makes my code a bit more complex b/c of the necessary mapping between the fields, but OTOH nothing changes for the caller.