I have the following scenario of an unowned relationship between a
User and UserRoles

public class User extends DomainObject<Long, User> {
        @Id
        @GeneratedValue(strategy = GenerationType.IDENTITY)
        @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value
= "true")
        private String encodedKey;

        @Extension(vendorName = "datanucleus", key = "gae.pk-id", value =
"true")
        private Long userId;
        private String username;
        private String password;
        private Long salt;
        ....
        ....
//      @Basic(fetch = FetchType.EAGER)
        private Set<Key> userRoleKeys = new HashSet<Key>();
        @Transient
        private Set<UserRole> userRoles = new HashSet<UserRole>();

As you would notice, I am using JPA, The UserRoles collection is
marked transient and I am adding the keys for the UserRoles in the
userRoleKeys Set.

So far so good.

Now, when I retrieve the user and try to access the userRoles, i get
the above mentioned error.
The error gets resolved when I use the @Basic annotation with the
userRoleKeys (see the commented line), however, that conflicts with
another functionality. If I want to add roles to the user and then
merge it then that does not work. It continues to retain the earlier
set if I have the @Basic annotation applied.

Questions
----------------
1) How do I detach the userRoleKeys set from the user object. I
already have the following in my persistence.xml
                        <property name="datanucleus.DetachAllOnCommit" 
value="true" />
                        <property name="datanucleus.DetachOnClose" value="true" 
/>
2) Why doesn't the merge update the set when I add the @Basic
annotation?
3) Is there a standard way of resolving the above situation?

-- 
You received this message because you are subscribed to the Google Groups 
"Google App Engine for Java" group.
To post to this group, send email to google-appengine-j...@googlegroups.com.
To unsubscribe from this group, send email to 
google-appengine-java+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-appengine-java?hl=en.

Reply via email to