When ever I try to save object of class UserPrincipalCredentials ,
using persistancemanager (see snippet below) , the child property
userProfile does not get saved. can anyone please review my
annotations and tell me what could be wrong with them ?

Code for saving Operation
________________________________________________
        public UserPrincipalCredentials create(UserPrincipalCredentials
credentials) {
                final PersistenceManager pm = 
PMFProvider.get().getPersistenceManager
();
                try {
                        System.out.println("trying to save");
                        //final UserProfile profile = 
credentials.getUserProfile();
                        //profile.setLoginAccount(credentials);
                        pm.makePersistent(credentials);

                } finally {
                        pm.close();
                }

                System.out.println("New User Added....... ");
                System.out.println("UserName : " + credentials.getUserName());
                System.out.println("Password : " + credentials.getPassword());
                System.out.println("Role : " + 
credentials.getRoles().get(0).getRole
());
                System.out.println("Perm : "
                                + 
credentials.getRoles().get(0).getPermissions());
                System.out.println("Profile : " + credentials.getUserProfile()
                                + " , persistent ? : "
                                + 
JDOHelper.isPersistent(credentials.getUserProfile()));
                return credentials;
        }
________________________________________________
and out put at sysout is
________________________________________________
New User Added.......
UserName : loginAccount5
Password :
52cfddd56f5ff8dd68f564b8172efe27ae14d7fe1f93d89828ab96dcf6ea6670
Role : DEFAULT
Perm : []
Profile : com.kpatil.global.persistance.model.userprof...@1bca1c3 ,
persistent ? : false
________________________________________________
________________________________________________Class
UserPrincipalCredentials
________________________________________________
package com.kpatil.global.persistance.model;

import java.util.List;

import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.PersistenceModifier;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserPrincipalCredentials {

        @PrimaryKey
        @Persistent
        private String userName;

        @Persistent(persistenceModifier=PersistenceModifier.PERSISTENT)
        private UserProfile userProfile;

        @Persistent
        private String password;

        @Persistent
        private List<UserRole> roles;

        public String getUserName() {
                return userName;
        }

        public void setUserName(String userName) {
                this.userName = userName;
        }

        public UserProfile getUserProfile() {
                return userProfile;
        }

        public void setUserProfile(UserProfile userProfile) {
                this.userProfile = userProfile;
        }

        public String getPassword() {
                return password;
        }

        public void setPassword(String password) {
                this.password = password;
        }

        public List<UserRole> getRoles() {
                return roles;
        }

        public void setRoles(List<UserRole> roles) {
                this.roles = roles;
        }

}

________________________________________________Class UserProfile
________________________________________________
package com.kpatil.global.persistance.model;

import java.io.Serializable;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import com.google.appengine.api.datastore.Key;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class UserProfile implements Serializable {

        private static final long serialVersionUID = -303737956990979603L;
        @PrimaryKey
        @Persistent(valueStrategy=IdGeneratorStrategy.IDENTITY)
        private Key key;

        @Persistent
        private String firstName;
        @Persistent
        private String lastName;


        public Key getKey() {
                return key;
        }

        public void setKey(Key key) {
                this.key = key;
        }

        public String getFirstName() {
                return firstName;
        }

        public void setFirstName(String firstName) {
                this.firstName = firstName;
        }

        public String getLastName() {
                return lastName;
        }

        public void setLastName(String lastName) {
                this.lastName = lastName;
        }

}
_______________________________________________________________________________________________________
-- 
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