Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7786487
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T20:25:29+00:00 2026-06-01T20:25:29+00:00

I’m worring about JDO in GAE (Google App Engine). (GWT 2.4 and GAE 1.6.3

  • 0

I’m worring about JDO in GAE (Google App Engine). (GWT 2.4 and GAE 1.6.3 SDK and JDO 2.3)

I have a class “Users” which should save a Collection of “User” in a List, but it doesn’t work.

When i save my Users-Class, then it creates the “Users”-Object in the Datebase and it also creates the User-Object in the List users. But when i load the Users-Object from the Database, the List users is empty…
Do i have to load the list by my self? I guess that JDO schould load the list directy, when i load the Users-Object.

I need your Help here! Thanks in previous!

Could it be a Problem that i create the Key in abstract class PersistentUser and PersistentUsers?
Could the LinkedList be the Problem?

My Code:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Version(strategy=VersionStrategy.VERSION_NUMBER)
public class Users extends PersistentUsers implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = -21666269538993247L;

/**
 * Mapped from Operator X
 */
@Persistent
private String operatorId;

@Persistent(mappedBy="userlist")
@Element(dependent = "true")
private List<User> users;

 /**
 * 
 * List of Ids of Users
 * 
 */
@Persistent(serialized = "true")
@Element(dependent = "true")
private List<String> userIds;


/**
 * @return the users
 */
public List<User> getUsers() {
    return users;
}
/**
 * @param users the users to set
 */
public void setUsers(List<User> users) {
    this.users = users;
}
...
}

The User Class:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Version(strategy=VersionStrategy.VERSION_NUMBER)
public class User extends PersistentUser implements Serializable{

/**
 * 
 */
private static final long serialVersionUID = 6899284258473985914L;

@Persistent
private String emailAddress;

@Persistent
private UserRole role;

/**
 * 
 * Mapped from Userlist X from Operator Y
 */
@Persistent
private Users userlist;

public User(String email, UserRole role){
    this.emailAddress = email;
    this.role = role;
}

public String getEmailAddress() {
    return emailAddress;
}
public void setEmailAddress(String emailAddress) {
    this.emailAddress = emailAddress;
}
public UserRole getRole() {
    return role;
}
public void setRole(UserRole role) {
    this.role = role;
}

/**
 * @return the userlist
 */
public Users getUserlist() {
    return userlist;
}

/**
 * @param userlist the userlist to set
 */
public void setUserlist(Users userlist) {
    this.userlist = userlist;
}


}

PersistentUser and PersistentUsers Class are the same content (but because of JDO-AppEngine Inheritance Problem two seperate classes:

@PersistenceCapable(identityType = IdentityType.APPLICATION, detachable = "true")
@Inheritance(strategy = InheritanceStrategy.SUBCLASS_TABLE)
@Version(strategy=VersionStrategy.VERSION_NUMBER)
public abstract class PersistentUsers implements IPersitentObject {

 /**
 * Id
 *
 * Autogenerated String id of the Database
 * 
 */
@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
protected Key encodedKey;


@Persistent
protected String username;

@Override
public String getId() {
    if(encodedKey == null) return null;
    return KeyFactory.keyToString(encodedKey);
}
/*public void setId(String id) {

    this.encodedKey = id;
}*/

/**
 * Helper function - get Version from DB
 */
@Override
public Long getVersion(){
    ...
}

/**
 * Helper function - will save this instance in DB
 */
public void persist(){

    ...
}

/**
 * Helper function - will remove this instance from DB
 */
public void delete(){
    ...
}

@Override
public final boolean checkUsername() {

    ...

}


}

Create User Code:
…
if(RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal() != null){

        //Create New User
        String email =     RequestFactoryServlet.getThreadLocalRequest().getUserPrincipal().getName();
        User u = UserFactory.getUser(email, UserRole.ADMINISTRATOR);
        //u.persist();

        //Create New Userlist
        Users users = UserFactory.getUsers();

        //Get Uids (normally empty)
        LinkedList<String> uids =  (LinkedList<String>) users.getUserIds();
        if(uids==null){
            uids = new LinkedList<String>();
        }
        uids.add(u.getId());

        //Get DB-Userlist of current User-List
        LinkedList<User> userlist =  (LinkedList<User>) users.getUsers();
        if(userlist==null){
            userlist = new LinkedList<User>();
        }
        userlist.add(u);
        users.setUserIds(uids);
        users.setUsers(userlist);

        u.setUserlist(users);
        //Persit Userlist and Persist User
        users.persist();

        this.userlistId = users.getId();

}
...

Persistence Code:

public static void persist(IPersitentObject o){

        PersistenceManager pm = Pmf.get().getPersistenceManager();

        try{
            pm.makePersistent(o);

        } catch (Exception e) {
            e.printStackTrace();
        }finally {

            pm.close();
        }


}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T20:25:30+00:00Added an answer on June 1, 2026 at 8:25 pm

    I found the problem/solution

    It’s my stupid brain thinking i could fetch it while debugging.

    My code is correct, but the information is not in the object while debugging!

    Test it in a TestCase showed, that it works.

    public class UsersTest {
    
    private PersistenceManager pm;
    private final LocalServiceTestHelper helper =
                new LocalServiceTestHelper(new LocalDatastoreServiceTestConfig());
    private String userlistId;
    private String userId;
    
    @Before
    public void setUp() throws Exception {
        helper.setUp();
    
        pm = ch.zhaw.ams.server.core.persistance.Pmf.get().getPersistenceManager();
    
    
    }
    
    
    @After
    public void tearDown() throws Exception {
    }
    
    @Test
    public void testNewUsers() {
    
    
        //New UserList
    
    
    
            //Create New Userlist
            Users users = UserFactory.getUsers();
    
            //Create New User
            String email = "ss";
            User u = UserFactory.getUser(email, UserRole.ADMINISTRATOR);
    
            users.getUsers().add(u);
    
            users.persist();
            this.userlistId = users.getId();
            this.userId = users.getUsers().get(0).getId();
    
    
    
        //Test Users
        pm = ch.zhaw.ams.server.core.persistance.Pmf.get().getPersistenceManager();
        Users ul=   pm.getObjectById(Users.class, this.userlistId);
        assertNotNull(ul);
        assertNotNull(ul.getUsers().get(0));
        assertTrue(ul.getUsers().get(0).getId().equals(this.userId));
        pm.close();
    }
    
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.