Problem with the EntityManager and persist

Hello,

I wrote a entity bean with generatedValue for ID. I can save the entity in the database with the EntityManager and the method persist. But if I save the object with the persist method, I didn't get the reference with the new ID back to the client...

I print the object in the application Server (JBoss) and the object is correct with values and generated ID. But in the client I have the same old object without ID.

Can somebody help me? I commit the method the reference but I never get the current object...

Here the Client invoke:

NewsVO news2 =new NewsVO("Peter Pan",new Date(),"躡erschriften wtf","Hier steht irgendwann Inhalt");

verwaltung.saveNews(news2);

System.out.println(news2);

Here the console output:

NEWSBEAN [ID=null] [AUTHOR=Peter Pan] [ERSTELLT_AM=Wed May 23 14:25:52 CEST 2007] [UEBERSCHRIFT=躡erschriften wtf] [INHALT=Hier steht irgendwann Inhalt]

Now the Remote Object:

publicvoid saveNews(NewsVO news){

if(news !=null){

try{

manager.persist(news);

log.info("News would be saved.\t\t\n" + news);

}catch(Exception ex){

log.error("Could not save News.\t\t\n" + news);

ex.printStackTrace();

}

}

}

In the application server the news object would be printed correctly:

14:30:55,021 INFO [NewsVerwaltung] News would be saved.

NEWSBEAN [ID=1] [AUTHOR=Peter Pan] [ERSTELLT_AM=Wed May 23 14:30:54 CEST 2007] [UEBERSCHRIFT=▄berschriften wtf] [INHALT=Hier steht irgendwann Inhalt]

Anybody a idea how I get the current instance with the ID from the object?

[2276 byte] By [RooKeea] at [2007-11-27 5:14:30]
# 1

Remote EJB invocations make copies of any arguments, so the news2 object created in the client

is not the same java object that is updated in the EJB.You need to return the news object from

saveNews if you want the client to see the latest changes.

public NewsVO saveNews(NewsVO news);

ksaksa at 2007-7-12 10:36:27 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...