You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomee.apache.org by "chaminda.sl@gmail.com" <ch...@gmail.com> on 2011/02/16 20:42:10 UTC
Remote Interface with JPA Issue
Hi Guys,
I have a Stateless SB with @Remote interface which calls em.persist(entity).
Entity implements Serialization and Identity as the id generation Type.
Issue is em.persist runs without any exception (in mysql, HSQL and JavaDB)
and saves the entity to db but it does not set the generated id to entity.
Interesting thing is if I change the @Remote to @Local em sets the generated
id to entity fine.
This can be reproduce easily in OpenEJB example as well...
Thanks
--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3309594.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Remote Interface with JPA Issue
Posted by "chaminda.sl@gmail.com" <ch...@gmail.com>.
Hi Thiago,
Thanks It worked.
But this is bit doubtful, the purpose to make entity serializable (if my
understanding is correct) is giving chances to change the status of entity
in different layers even in different jvm.
Thanks again.
On Thu, Feb 17, 2011 at 3:06 AM, Thiago Veronezi-3 [via OpenEJB] <
ml-node+3309787-2130815877-213545@n4.nabble.com> wrote:
> Hi,
>
> You shouldn't rely on changes on your method’s parameters when working with
>
> EJBs. For example, imagine that you are calling…
>
>
>
> MyEntity myEntity = new MyEntity();
>
> myEntity.setName(“Thiago”);
>
> myEntity.setNickName(“Boto”);
>
> mySessionBean.createEntity(myEntity);
>
> System.println(myEntity.getId());
>
>
>
> The result of the println method above depends on from where you are
> calling
> the ejb. If it is a remote ejb, it will be null… if it is local, it will be
>
> your bean id. That’s because you should return the value from the
> “createEntity” method. So, to fix it, you should change the code above
> from...
>
>
> mySessionBean.createEntity(myEntity);
>
>
> to…
>
>
> myEntity = mySessionBean.createEntity(myEntity);
>
>
> Could you check it?
>
>
> []s,
>
> Thiago.
>
> On Wed, Feb 16, 2011 at 2:42 PM, [hidden email]<http://user/SendEmail.jtp?type=node&node=3309787&i=0><
> chaminda.sl@
> gmail.com> wrote:
>
> >
> >
> > Hi Guys,
> >
> > I have a Stateless SB with @Remote interface which calls
> > em.persist(entity).
> > Entity implements Serialization and Identity as the id generation Type.
> >
> > Issue is em.persist runs without any exception (in mysql, HSQL and
> JavaDB)
> > and saves the entity to db but it does not set the generated id to
> entity.
> >
> > Interesting thing is if I change the @Remote to @Local em sets the
> > generated
> > id to entity fine.
> >
> > This can be reproduce easily in OpenEJB example as well...
> >
> > Thanks
> > --
> > View this message in context:
> >
> http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3309594.html<http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3309594.html?by-user=t>
> > Sent from the OpenEJB User mailing list archive at Nabble.com.
> >
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3309787.html
> To unsubscribe from Remote Interface with JPA Issue, click here<http://openejb.979440.n4.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=3309594&code=Y2hhbWluZGEuc2xAZ21haWwuY29tfDMzMDk1OTR8LTE0OTY0NzUyNzM=>.
>
>
--
Chaminda Amarasinghe,
--
View this message in context: http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3310187.html
Sent from the OpenEJB User mailing list archive at Nabble.com.
Re: Remote Interface with JPA Issue
Posted by Thiago Veronezi <th...@veronezi.org>.
Hi,
You shouldn't rely on changes on your method’s parameters when working with
EJBs. For example, imagine that you are calling…
MyEntity myEntity = new MyEntity();
myEntity.setName(“Thiago”);
myEntity.setNickName(“Boto”);
mySessionBean.createEntity(myEntity);
System.println(myEntity.getId());
The result of the println method above depends on from where you are calling
the ejb. If it is a remote ejb, it will be null… if it is local, it will be
your bean id. That’s because you should return the value from the
“createEntity” method. So, to fix it, you should change the code above
from...
mySessionBean.createEntity(myEntity);
to…
myEntity = mySessionBean.createEntity(myEntity);
Could you check it?
[]s,
Thiago.
On Wed, Feb 16, 2011 at 2:42 PM, chaminda.sl@gmail.com <chaminda.sl@
gmail.com> wrote:
>
>
> Hi Guys,
>
> I have a Stateless SB with @Remote interface which calls
> em.persist(entity).
> Entity implements Serialization and Identity as the id generation Type.
>
> Issue is em.persist runs without any exception (in mysql, HSQL and JavaDB)
> and saves the entity to db but it does not set the generated id to entity.
>
> Interesting thing is if I change the @Remote to @Local em sets the
> generated
> id to entity fine.
>
> This can be reproduce easily in OpenEJB example as well...
>
> Thanks
> --
> View this message in context:
> http://openejb.979440.n4.nabble.com/Remote-Interface-with-JPA-Issue-tp3309594p3309594.html
> Sent from the OpenEJB User mailing list archive at Nabble.com.
>