I have a SFSB that is invoked in multiple requests without a clear Begin or
End. It uses a SLSB to get a reference to an entity.
Here's an example from my project (note this worked in 1.2.1):
Foo is session scoped, so I expect its instance variables to stay around and
managed. When I invoke a() the 'entity' ref is set. When I then invoke b(),
entity is not-null and I can even get lazy loaded properties.
With Seam 1.2.1 this worked, now with 2.0 it no longer works. I'm not sure
what's changed between versions that would cause this.
With 2.0. I get a NPE when trying to access 'entity' from a seperate request. I
can get around this by creating a @Begin @Create public void init() {} method
in Foo, but that's an ugly workaround.
The seam SMPC in a Session bean should be session scoped, and any entities that
it retrieves should also be managed throughout the session, right?
| @Name
| @Scope(STATEFULL)
| @Stateful
| public class FooImpl implenents Foo {
| @In
| EntityManager entityManager;
|
| @In
| Bar bar;
|
| private entity;
|
| // several methods that access 'entity' and access lazy loaded
| // properties of entity
| public void a() {
| entity = bar.getEntity();
| // do something
| }
|
| public void b() {
| entity.getProperty();
| entity.getLazyProperty();
| }
| }
|
| @Name
| @Stateless
| public class BarImpl implenents Bar {
| @In
| EntityManager entityManager;
|
| public Entity getEntity() {
| entityManager.find(Bar.class, ...);
| }
| }
|
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4127422#4127422
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4127422
_______________________________________________
jboss-user mailing list
[email protected]
https://lists.jboss.org/mailman/listinfo/jboss-user