My code looks like this:
@Entity
public class Document extends Model
{
@Id
private Long id;
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "developers")
private Set<Tester> developers = new HashSet<>();
@ManyToMany(cascade = CascadeType.ALL)
@JoinTable(name = "testers")
private Set<Tester> testers = new HashSet<>();
}
I am using the JoinTable
annotation otherwise I end up with the same join table for the many-to-many relation. This works well and I get two tables generated (developers and testers).
I am even able to save the data properly. Setting the developers and/or testers and then saving the document entity works properly.
Now the problem is that the moment I do something like:
Document.find.all()
to get the available Documents, the developers and the testers fields return the same data, despite the data being different in the database. Doing document.getDevelopers()
and document.getTesters()
return the same data with getDevelopers()
always hiding the getTesters()
data.
Is this some bug/limitation in the Ebean ORM?
I am using Play 2.3.8
Explicitly fetching the fields returns the proper data.
Just define own find method like this:
Still wondering if there are better ways...