-
1. Re: Merging necessary for detached association?
asookazian Jul 23, 2009 6:54 AM (in response to vk101)Honestly, I think you're the first person I've seen in this forum that is actually using an entity class with a non-default (i.e. non-conversation) scope. That's not necessarily a bad thing but why are you using a session-scoped entity class?
Why don't you just outject a List<foo> as a result of a JPQL query or similar to session scope instead?
Are you using that entity class as a backing bean with a @Name annotation?
There is an example in SiA book (see Listing 4.1) with @Scope(ScopeType.EVENT) on an entity class. Are you doing something similar?
-
2. Re: Merging necessary for detached association?
asookazian Jul 23, 2009 7:38 AM (in response to vk101)The booking example has a session-scoped entity class:
@Entity @Name("user") @Scope(SESSION) @Table(name="Customer") public class User implements Serializable {...}
But it is being outjected to session scope in the AuthenticatorAction:
@Stateless @Name("authenticator") public class AuthenticatorAction implements Authenticator { @PersistenceContext private EntityManager em; @In(required=false) @Out(required=false, scope = SESSION) private User user; public boolean authenticate() { List results = em.createQuery("select u from User u where u.username=#{identity.username} and u.password=#{identity.password}") .getResultList(); if (results.size()==0) { return false; } else { user = (User) results.get(0); return true; } } }
I'm not sure that the entity class needs to be session-scoped if the outjection to session scope is there...
-
3. Re: Merging necessary for detached association?
vk101 Jul 23, 2009 8:07 AM (in response to vk101)The session-scoped entity, as in your example, is a User. However, I haven't defined the @Scope annotation on the entity - I've outjected the user to a session scope from an authentication method.
In cases where a session-scoped entity is an attribute of a conversation-scoped entity about to be persisted, I don't want to update the contents of the session-scoped entity from the database.
It seems the only way to do this would be to use straight JDBC.
I really hope there's a simple way to do what I'm trying using Seam and Hibernate.
-
4. Re: Merging necessary for detached association?
vk101 Jul 28, 2009 6:19 AM (in response to vk101)Any Seam user who uses a session-scoped Member/User object would have come across this issue.
Either they're living with the inefficiency of a separate database access for the merge of the session-scoped Member/User, or they have found a way around it - if the latter, please share :)