3

I have to minins:

@JsonIdentityInfo(generator=ObjectIdGenerators.None.class,
                  property="@id")
public interface NoReferenceMixin {

}
@JsonTypeInfo(use=JsonTypeInfo.Id.CLASS,
              include=JsonTypeInfo.As.PROPERTY,
              property="@class")
public interface FullClassInfoMixin { }

I want to apply both of these to a particular class, Thing. It appears that I can only add one Mixin per class, as evidenced by experiment and the existing of ObjectMapper.findMixInForClass which returns a single Class.

I have tried making an interface that extends both:

public interface ThingMixins extends NoReferenceMixin, FullClassInfoMixin { }

findMixInForClass returns the mixing, but FullClassInfoMixin is not applied. (It is harder to check if NoReferenceMixin is applied and I have not checked that.)

What is the correct way to do this?

I am using jackson 2.9.0.pr4

Troy Daniels
  • 3,270
  • 2
  • 25
  • 57

1 Answers1

0

Your work-around of having an interface that extends 2 interfaces you want to combine should work; annotations are scanned from specific mixin class throughout inheritance chain.

If you can reproduce the problem with simple example maybe file an issue against jackson-databind.

StaxMan
  • 113,358
  • 34
  • 211
  • 239