I have a problem with cascade and maps.
The classes are:
Campaign.java
Code:
...
@OneToMany(cascade=CascadeType.ALL)
@MapKey(name="position")
private Map<Integer,Ad> ads;
...
Ad.java
Code:
...
@ManyToOne(optional=false)
private Campaign campaign;
...
When I try to save a Campaign object with some Ads, it throws exception for not null field "campaign_id" in the ads table.
If I take optional=false it works but no reference is kept for the Ad parent (campaign_id = NULL).
I can't set the id for the parent because it doesn't exists yet.
Am I missing something?