View Model Duplicates
See original GitHub issueHi,
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();
}
Issue Analytics
- State:
- Created 4 years ago
- Comments:24 (13 by maintainers)
Top Results From Across the Web
MVVM duplicating Model properties in ViewModel
It seems that there is a guidance that a model should not expose its entities to View, and that all required properties should...
Read more >Duplicating Domain Model in View Model or not
A separate View Model hierarchy duplicates all of the fields in the XML model while adding error checking and everything else needed (such ......
Read more >Duplicate class androidx.lifecycle.ViewModelLazy found in ...
ViewModelLazy found in modules lifecycle-viewmodel-2.5.0-runtime (androidx.lifecycle:lifecycle-viewmodel:2.5.0) and lifecycle-viewmodel-ktx-2.3.
Read more >Prevent duplicate values in a table field using an index
Set the field's Indexed property to Yes (No duplicates) You can do this by opening the table in Design view. This method is...
Read more >Duplicate value when Observing from ViewModel #3 - GitHub
Hi sir, I am trying to observer two LiveData but the values are set two times and make it has duplicate value. My...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Ok, now it’s working fine. Thank you!
So what you can do is either this
or this