In
Java Persistence with Hibernate (p. 269), the example
Code:
@OneToMany(cascade = { CascadeType.PERSIST, CascadeType.MERGE },
mappedBy = "item")
private Set<Bid> bids = new HashSet<Bid>();
implies that session.save(item) will save all associated bid instances. That's not what I'm finding.
I have a bi-directional one-to-many, many-to-one relation, and saving the one instance doesn't save the associated many instances. If, however, I change the annotations (just the annotations, none of the actual code) to use org.Hibernate CascadeType class :
Code:
@OneToMany(mappedBy = "item")
@Cascade(value = CascadeType.SAVE_UPDATE)
private Set<Bid> bids = ...;
everything gets saved correctly.
Is this expected behavior, because it's sure not what I expected from the text?