[jboss-user] [JBoss Seam] - Re: EntityManager: For newbies or to close gaps in your know

y_zl do-not-reply at jboss.com
Wed Nov 29 01:21:33 EST 2006


Hi! bfo81,

great! 

I have one question as following:

Suppose I have two tables 


  | user(id, name) 
  | userlog(id,userid,content)
  | 

I'd like to create a new user and write the log at the same time.

Suppose I use extended persistent manager. 

I have the following code:


  | @In @Out user;
  | 
  | @PersistenceContext(type=EXTENDED)
  | private EntityManager em;
  | 
  | public void new_user()
  | {
  | 
  | user.setName("user");
  | Userlog userlog=new Userlog();
  | userlog.setContent("register");
  | userlog.setUser(user);
  | 
  | -----
  | 
  | }
  | 

the question is:
1)Do I need to em.persist to save user and userlog?
2)If it is needed. Which one is first? user or userlog

thanks in advance

View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=3989578#3989578

Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=3989578



More information about the jboss-user mailing list