Two entities with a bidirectional one to many relationship.
Entity A points to a list of entity B's which will be several at most. Entity B has a back reference to an A.
When displayed as JSON, I was expecting to see A with a number of B's or B with its corresponding A. But that seems to depend on the fetch strategy in the @OneToMany or @ManyToOne annotation.
Most things I have read says @ManyToOne should be LAZY, and the @OneToMany should be EAGER. And that approach will work when listing entity A; each A and it's associated B's are shown in JSON.
But when listing B's, I get an error
Type definition error: [simple type, class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor]; nested exception is com.fasterxml.jackson.databind.exc.InvalidDefinitionException: No serializer found for class org.hibernate.proxy.pojo.bytebuddy.ByteBuddyInterceptor and no properties discovered to create BeanSerializer (to avoid exception, disable SerializationFeature.FAIL_ON_EMPTY_BEANS
Changing the LAZY to EAGER fixes the problem. But, with LAZY, I would have expected it to at least bring up the B records. The error is surprising.
I will just add that both entity definitions use JsonIdentityInfo (added to prevent infinite recursion) which uses a SimpleObjectIdResolver.
So, in summary, I am confused. I can make it "work" but not really sure why.