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 9045453
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:19:33+00:00 2026-06-16T11:19:33+00:00

I have a problem using GAEJ and JDO for storing the data. This is

  • 0

I have a problem using GAEJ and JDO for storing the data.
This is what I’m working with:

class Usuari.java:

@PrimaryKey
@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
private Key key;

@Persistent
private String email;

@Persistent
private String rol="";

class DBUtils.java:
I’ve tried with two ways of doing the delete operation:

// This method removes a record from the database using its unique Key
public static boolean eliminar(Key k) throws Exception {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    String kind;
    Long id;
    kind = k.getKind();
    id = k.getId();
    try {
        if (k.getKind().equals("Usuari")) {
            Usuari u = (Usuari)pm.getObjectById(k);
            pm.deletePersistent(u);
            _log.log(Level.INFO, "Deleted an entity->kind: " + kind + " id: " + id);
        }

        return true;
    } catch (Exception e) {
        _log.log(Level.SEVERE, "Unable to delete an entity->kind: " + kind + " id: " + id);
        System.err.println(e.getMessage());
        throw e;
    }
    finally {
        pm.close();
    }
}

// This method removes a record from the database using its unique Key - too
public static void eliminar2(Key k) throws Exception {
    PersistenceManager pm = PMF.get().getPersistenceManager();
    javax.jdo.Transaction tx = pm.currentTransaction();
    try
    {
        tx.begin();
        if (k.getKind().equals("Usuari")) {
            Usuari u = (Usuari) pm.getObjectById(k);
            pm.deletePersistent(u);
        }
        tx.commit();
    }
    catch (Exception e)
    {
        if (tx.isActive())
        {
            tx.rollback();
        }
        throw e;
    }
}

I’m able to create new instances of some class “Usuari” but I can’t delete them.
Everytime I call “eliminar” or “eliminar2” methods I get a “No such object” as result of trying to fetch it. I’ve checked manually and I see the object exists in my admin panel, with its ID and KIND, so I don’t know what am I doing wrong.

Any help would be much appreciated.

  • 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-16T11:19:34+00:00Added an answer on June 16, 2026 at 11:19 am

    PM.getObjectById does not take in a Key object, as per the JDO spec. It takes in an identity object, the same type as you would get from pm.getObjectId(obj); suggest you glance through the JDO spec. No doubt if you inspected what is returned from this method you would see that it can’t find an object with that ‘identity’ because a Key is not an identity. You can also do

    pm.getObjectById(Usuari.class, key);
    

    which is shown very clearly in GAE documentation.

    Still don’t get why users are putting @Persistent on every field virtually every type is default persistent; only leads to making code more unreadable.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I´m have a problem using EF for my data model. I have this code
I have a problem using the SSIS. I try to import data from database
i have a problem using the Catch Clipboard Events code found on this link
I have problem with using dequeueReusableCellWithIdentifier method. Whenever I use this one, one cell
I have a problem using Gin. Here is a simple example. @GinModules(AppModule.class) public interface
I have a problem using data from a tab delimited data file imported with
We have a problem using a class template which itself uses function objects in
I have a problem using opengl on android to draw a simple rectangle. This
I have problem with using class instance in Python. Ive created a new class
I have problem in using ExceptionMatcher...My example spec: class DescribeBall extends \PHPSpec\Context { private

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.