blaze-persistence: View Model Duplicates

Hi,

I’m struggling with fetching data from the database. When querying for a specific RFA view, I get a duplicate for each “history” entity. So with three entries in “history”, I get the same RFA three times. I found out that Hibernate has a ResultTransformer for this problem, but this isn’t useable for blazebit when I’m correct. Furthermore, I didn’t find anything helpful in the issue section. Am I missing something?

I got the following two entities:

@Entity
@Table(name = "requests")
public class RFA {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected long id;

    @OneToMany(mappedBy = "rfa")
    private Set<StatusEntry> history = new HashSet<>();
}
@Entity
@Table(name = "status_history")
public class StatusEntry {

    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    protected long id;

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "rfa_id")
    private RFA rfa;

}

Views:

@EntityView(RFA.class)
public interface RFAView {

    @IdMapping("id")
    Long getId();

    Set<StatusEntryView> getHistory();
}
@EntityView(StatusEntry.class)
public interface StatusEntryView {

    @IdMapping("id")
    Long getId();

}

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 24 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Ok, now it’s working fine. Thank you!