[EJB 3.0] - Re: EntityManager not auto-flushing at end of SLSB method
by lpmon
I decided to post the code. I just saw your comment about the "new entity ..." and that does explain part of it (purchase not saved ) as you will see. That does not explain why the changed entity (member) did not get saved. Member was injected in the calling SLSB using SEAM and passed to this method.
If it is true that a new entity is not saved on exit that needs to be emphasized in documentation. I started with the trailblazer and use the references. Maybe it is in there but I never noticed it.
public @Stateless class PurchaseCreditsBean implements PurchaseCredits {
@PersistenceContext
EntityManager em;
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
public void purchaseCredits(Member member, int purchaseQty)
{
Purchase purchase = new Purchase();
purchase.setPurchasedCredits(purchaseQty);
member.setCredits(purchaseQty + member.getCredits());
purchase.setMember(member);
purchase.setPurchasedCredits(purchaseQty);
em.merge(purchase); // TODO should not have to call merge
em.merge(member);
}
}
Thanks, my assumption is the SEAM injected entity is behaving as if it is not attached to my em as well. If this is the case I certainly misunderstood this. I bet many others have been down this same path!
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116598#4116598
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116598
18 years, 3 months
[EJB 3.0] - Re: EntityManager not auto-flushing at end of SLSB method
by lpmon
Thanks Mazz.
I am aware of the transaction layering effect (for lack of a better term) that applies if one session beans calls another. I am certain all of my session bean methods are exiting.
The code is simple and basic. In this particular method I create one entity and modify another. Neither is saved to the DB unless I call em.merge.
However, as an experiment, I added this to the method in question:
@TransactionAttribute(TransactionAttributeType.REQUIRES_NEW)
My understanding of this annotation is that the container should begin a new transaction for this method and it will end when the method exits. Correct? Adding this made no difference. I have never seen any of this work as documentation suggests it should work. I have been using JBoss AS for along time but this is my first EJB3 app. What could I have done wrong to cause this behavior? Again, 4.0.5.GA w/EJB3 (used installer and selected EJB3, Windows XP 64-bit)
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116596#4116596
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116596
18 years, 3 months
[Installation, Configuration & DEPLOYMENT] - Re: In Linux environment , jboss-4.2.2.GA don't startup
by javang
Hi all
My install env is sun vm, down is the trace:
16:23:33,116 INFO [ServerInfo] Java version: 1.5.0_06,Sun Microsystems Inc.
16:23:33,116 INFO [ServerInfo] Java VM: Java HotSpot(TM) Server VM 1.5.0_06-b05,Sun Microsystems Inc.
16:23:33,116 INFO [ServerInfo] OS-System: Linux 2.6.9-11.ELsmp,i386
16:23:33,116 DEBUG [ServerInfo] Full System Properties Dump
16:23:33,116 DEBUG [ServerInfo] java.runtime.name: Java(TM) 2 Runtime Environment, Standard Edition
16:23:33,116 DEBUG [ServerInfo] jboss.server.base.dir: /usr/jbossB/server
16:23:33,116 DEBUG [ServerInfo] java.protocol.handler.pkgs: org.jboss.net.protocol
16:23:33,116 DEBUG [ServerInfo] sun.boot.library.path: /usr/jdk15/jre/lib/i386
16:23:33,116 DEBUG [ServerInfo] jboss.server.lib.url: file:/usr/lutop/jbossB/server/all/lib/
16:23:33,116 DEBUG [ServerInfo] java.vm.version: 1.5.0_06-b05
16:23:33,116 DEBUG [ServerInfo] javax.management.builder.initial: org.jboss.mx.server.MBeanServerBuilderImpl
16:23:33,116 DEBUG [ServerInfo] java.vm.vendor: Sun Microsystems Inc.
16:23:33,117 DEBUG [ServerInfo] java.vendor.url: http://java.sun.com/
16:23:33,117 DEBUG [ServerInfo] path.separator: :
16:23:33,117 DEBUG [ServerInfo] java.vm.name: Java HotSpot(TM) Server VM
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4116582#4116582
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4116582
18 years, 3 months