[jboss-user] [EJB 3.0] - Re: Entitymanager Persistent
ALRubinger
do-not-reply at jboss.com
Thu May 3 15:43:06 EDT 2007
Well, unless the relationship defined is annotated with @Cascade (CascadeType.PERSIST), you can't persist one entity and expect the relationship to be inserted as well.
So that's one solution.
However, I typically keep the Cascading strategies to NONE as a default (to keep close tabs on what operations the container might do without my explictly telling it so; this is a perference only), and would do the following:
// Create Rollingstock
| rollingstock = new Rollingstock();
| rollingstock.setNextRoute( "STH" );
| rollingstock.setRoute( "HALL" );
|
| // Create Schedule
| schedule = new Schedule();
|
| // Persist Each
| manager.persist(rollingstock);
| manager.persist(scheulde);
|
| // Associate (bi-directionally) after Persisted
| rollingstock.setSchedule(schedule);
| schedule.setRollingstock(rollingstock);
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4042957#4042957
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4042957
More information about the jboss-user
mailing list