[jboss-user] [JBoss Seam] - Re: More seam examples
petemuir
do-not-reply at jboss.com
Wed Jul 26 08:13:16 EDT 2006
| 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 want
| entityManager.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.
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3960960#3960960
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3960960
More information about the jboss-user
mailing list