Let's say I have entity class that is also seam component named "account":
@Scope(ScopeType.SESSION)
@Name("account")
@Entity
public class Account implements Serializable{
private Long id;
private Collection<Operation> operations;
...
}
During log in operation I read user account object from db and outjected under name "currentAccount":
@Name("authenticator")
public class Authenticator {
@Out(required=false, scope=ScopeType.SESSION, value="currentAccount")
private Account account;
public boolean authenticate() {
account = getUserAccountFromDB();
}
...
}
Now I want to use currentAccount object in diffrent manager(plain pojo), for instance:
@Name("someManager")
public class SomeManager () {
@In Account currentAccount;
public void doSth() {
for (Operation operation:currentAccount.getOperations()) {
log.debug(operation);
}
}
}
And now currentAccount.getOperations() will cause
org.hibernate.LazyInitializationException the same if I try use use sth like #{currentAccount.operations} directly in view.
I came across :
http://www.jboss.com/index.html?module=bb&op=viewtopic&t=85964 where Gavin King posted that It's neccesary to reattach detached object (scoped SESSION) using session.lock() to make it valid to conversation context.
And now my qustions:
1. Do I really have to do this "reattach" in every bean that uses SESSION scoped seam components?
2. If I use many views that displays SESSION scoped objects (complex lazy initialization) I have to make them EAGER ??? (imagine there is outjection at the begginig and then only views that uses SESSION scoped components - no other beans)
3. Why @In does not make this "attach" automatically?
I'm just at the begging of seam developing process and maybe I miss some important point? ;)
Many thanks in advance