users@glassfish.java.net

Re: Stateless beans / JPA - when comit transactions occure?

From: Marina Vatkina <Marina.Vatkina_at_Sun.COM>
Date: Tue, 13 Feb 2007 15:24:29 -0800

It seems that you use some older build version - there were several bugs in the
logging integration that had been fixed so that you get real messages.

That said, you should see plenty of TopLink messages at the FINEST level at
least when the PU is being loaded.

Are you using default transaction setting? Is em.merge() the only access to the
entity manager? Can it be that you call em.clear() before the transaction commits?

thanks,
-marina

glassfish_at_javadesktop.org wrote:
> I have a strange behavious when I try to merge entities with modified values but nothing occures...
>
>
> This is my scenario:
> I have a stateless EJB named 'fooEjb' with one method that updates some entities that looks like:
>
> @Stateless()
> public class FooBean implements FooLocal {
> public void updateEntities(Collection<MyEntity> entities) {
> for(MyEntity currEntity : entities) {
> currEntity.setX("value");
> currEntity.setY("value...");
> em.merge(currEntity);
> }
>
>
> And 'Bar' which is is another stateless EJB, with one method that initiate some POJO like:
> @EJB(name="fooEjbRef", beanInterface=FooLocal.class)
> @Stateless()
> public class BarBean implements BarLocal {
> public void start() {
> MyPojo mp = new MyPojo();
> mp.doSomeStuff();
> }
>
>
> I lookup for 'fooEjbRef' in pojo:
> public class MyPojo {
> public void doSomeStuff() {
> try {
> InitialContext ic = new InitialContext();
> FooLocal fooLocal = (FooLocal) ic.lookup("java:comp/env/fooEjbRef");
> }
>
> //Load some entities...
> //Prepare a list of entities to remove
>
> fooLocal.updateEntities(listOfEntitiesToRemove);
> }
>
>
>
>
> em.merge is executed per iteration, but nothing is done. UNLESS I add 'em.flush()' at the end of the 'updateEntities()' method in FooBean...
>
>
> Aint the transaction should be flushed when I end my call to the ejb's method?
>
> I couldn't see anything in log even in FINEST level, the only thing I could have seen is:
>
> [#|2007-02-12T13:36:30.473+0200|FINEST|sun-appserver-ee9.1|oracle.toplink.essentials.session.file:/opt/glassfish/domains/domain1/applications/j2ee-apps/edm/lib/entities.jar-pu1.transaction|_ThreadID=11;_ThreadName=p: thread-pool-1; w: 3;ClassName=null;MethodName=null;_RequestID=ae43984a-1efc-4751-af31-59fa754e093f;|Merge clone with references app.entity.MyEntity_at_c8efc|#]
>
> But nothing else.
>
>
>
> Any clue? should I flush the EntityManager when I end my calls? this is really scary and confusing :)
>
>
> As always, many thanks,
>
> Asaf.
> [Message sent by forum member 'trouby' (trouby)]
>
> http://forums.java.net/jive/thread.jspa?messageID=203507
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: users-help_at_glassfish.dev.java.net
>