Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Just started using javers in place of envers and was stuck in associations(@OneToMany and @ManyToOne). To prevent javers from scanning and registering all association changes I applied @DiffIgnore on all @OneToMany associations and strangely when i get the entity in postpersist event of hibernate it @DiffIgnore annotated properties are ignored and I got lazy init exception when accessing those fields.

Here is my sample entity:

@OneToMany(fetch = FetchType.LAZY, mappedBy = "property")
@ShallowReference
private List<PropertyImage> propertyImages = new ArrayList<>();

Property Images

@GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") Long id; @ManyToOne(fetch = FetchType.LAZY) @JoinColumn(name = "property_id", referencedColumnName = "property_id", nullable = false) private Property property;

Also I tried @ShallowReference annotation but again it fetches all associated entities and causes performance issue.

But when I change @FetchType.EAGER it works fine. Confused what's the issue here

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.