I have a stateful session bean that uses other stateless session beans via their remote
interfaces. The stateless session beans use EJB3 persistence. Now I have this scenario:
Application bean (stateful):
Resource resource = securityManager_.createResource(admin);
| return folderManager_.createRootFolder(resource);
Security Manager bean (stateless):
@PersistenceContext private EntityManager em_;
|
| public Resource createResource(User owner) throws SecurityException {
| Resource resource = new Resource(owner);
| em_.persist(resource);
| return resource;
| }
Folder Manager bean (stateless):
@PersistenceContext private EntityManager em_;
|
| public Folder createRootFolder(Resource resource) throws FolderException {
|
| // this instruction causes the exception
| em_.refresh(resource);
|
| // code omitted
| }
The em_.refresh(resource); causes a HibernateException to be throws:
anonymous wrote : Stack Trace:
| *
org.hibernate.ejb.AbstractEntityManagerImpl.throwPersistenceException(AbstractEntityManagerImpl.java:567)
| *
org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:239)
| *
org.jboss.ejb3.entity.TransactionScopedEntityManager.refresh(TransactionScopedEntityManager.java:193)
| *
net.sf.adigres.foldermanager.FolderManagerBean.createRootFolder(FolderManagerBean.java:88)
| * ....
| Caused by: org.hibernate.HibernateException: this instance does not yet exist as a row
in the database
| *
org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:90)
| *
org.hibernate.event.def.DefaultRefreshEventListener.onRefresh(DefaultRefreshEventListener.java:39)
| * org.hibernate.impl.SessionImpl.fireRefresh(SessionImpl.java:895)
| * org.hibernate.impl.SessionImpl.refresh(SessionImpl.java:879)
| *
org.hibernate.ejb.AbstractEntityManagerImpl.refresh(AbstractEntityManagerImpl.java:233)
| * ... 106 more
This happens only in conjunction with the stateful Application bean. Stand alone tests of
the two stateless beans involved work without problems.
I guess it has something to do with transactions but I don't use @TransactionAttribute
annotations anywhere so the default value (REQUIRED) should apply (and be appropriate).
Can anyone help me with this, please?
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4004544#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...