This content has been marked as final.
Show 1 reply
-
1. Re: More seam examples
pmuir Jul 26, 2006 8:13 AM (in response to kryptontri)Parent parent = new Parent(); Child child = new Child(); Car car = new Car(); parent.setCar(car); parent.add(child); parent.persist(parent);
Assuming car and child are entities with no references to parent and Parent is:@Entity public class Parent { @ManyToOne(cascade=PERSIST) private Car car; @OneToMany(cascade=PERSIST) private List<Child> children; ... // Getters and setters }
If you had bi-directional relationships you might wantentityManager.flush(); entityManager.refresh(parent);
as well.
Nullifying view objects should work fine (empty fields) (but you need to make sure the new version is outjected which requires a reasonable understanding of the difference between variables in the component and context variables).
Regarding relationships - this is really a Hibernate/EJB3 JPA issue. The hibernate unit tests are good for understanding the sematics involved.