Jeff
Jeff

Reputation: 1591

JPA ManyToMany relationship -- Why would association (join) table be empty

I have two entities Account and Position. The POSITION table and the ACCOUNT table have contents but the POSITION_ACCOUNT table, which I think should have at least one row, is empty. What could I be doing wrong? Here is the relevant code (I am using EclipseLink 2.4.2:

In Position:

@ManyToMany private List accounts;

In Account:

@ManyToMany(mappedBy = "accounts",fetch=FetchType.EAGER,cascade=CascadeType.PERSIST) @JoinTable(name="POSITION_ACCOUNT")

Confusing to me and perhaps relevant is that some examples I see annotate the getters and setters but others, as I am doing here, annotate the actual Lists.

Upvotes: 0

Views: 169

Answers (1)

Jeff
Jeff

Reputation: 1591

It turns out that I needed to specify cascade=CascadeType.PERSIST on both sides of the relationship but there were other application-specific issues along the way. I don't know if reading the original question or this answer will be of much help to anyone. Sorry.

Upvotes: 0

Related Questions