I have the following ManyToMany (bidirectional) relationship:
@Entity
public class Proposal extends Model {
...
@ManyToMany
public List<Tag> tags;
}
@Entity
public class Tag extends Model {
...
@ManyToMany(mappedBy="tags")
public List<Proposal> taggedProposals;
}
And I want to populate my DB with some test data using a yaml file (to display later using a simple view). This is part of my yaml file:
...
- &prop2 !!models.Proposal
id: 2
title: Prop2 title
proposer: *user2
- &prop3 !!models.Proposal
id: 3
title: Prop3 title
proposer: *user3
# Tags
- &tag1 !!models.Tag
name: Tag1 name
desc: Tag1 description
taggedProposals:
- *prop1
- &tag2 !!models.Tag
name: Tag2 name
desc: Tag2 description
taggedProposals:
- *prop2
- *prop3
The problem is that when I try to display a Proposal's tags
or a Tag's taggedProposals
, the ArrayLists are empty! I tried using square brackets and commas without success. All the other data is being loaded and displayed correctly.