[jboss-user] [EJB 3.0] - Re: How to get generated id after persiting an entity?

jaikiran do-not-reply at jboss.com
Thu Oct 23 09:47:54 EDT 2008


"mike_ap" wrote : 
  | 
  | 
  | 
  |   | context = new InitialContext();
  |   | LogFileManagerRemote beanRemote = (LogFileManagerRemote) context.lookup(LogFileManager.RemoteJNDIName);
  |   | 
  |   | MyLogFile file = new MyLogFile("newfile.log", 12345);
  |   | beanRemote.saveMyLogFile(file);
  |   | System.out.println(file.getId());
  |   | 
  | 
  | 
When you are using a remote bean, the parameters are passed by value. So any changes to the "file" entity that you are passing will not be reflected in the method that calls the bean. So at your client, you should use the object returned by your bean. That object will have the id set:

MyLogFile savedFile = beanRemote.saveMyLogFile(file);
  | System.out.println(savedFile.getId());

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

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



More information about the jboss-user mailing list