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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:56:36+00:00 2026-06-12T18:56:36+00:00

I need to do getKey() with this kind of Entity: @Entity public class Value

  • 0

I need to do getKey() with this kind of Entity:

@Entity
public class Value {
    @Id
    private long id;
    private byte[] value;

    com.googlecode.objectify.Key<Value> getKey() {
        return com.googlecode.objectify.Key.create(Value.class, id); // When executed this line throws NullPointerException
    }

        // Code omitted
}

However the pattern I used before with version 3 seems to be not applicable anymore.
The @Transient is replaced by @Ignore but when I annotate my getKey() function with @Ignore I get this error:

The annotation `@Ignore` is disallowed for this location 

So I just commented it out. And see if it will work.

Furthermore,

When I run my application the getKey() function throws NullPointerException as commented above.

So, what is the pattern to get a @Entity key?

  • 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-12T18:56:37+00:00Added an answer on June 12, 2026 at 6:56 pm

    You can’t create a Key with a null or 0 id. Neither Objectify nor the datastore will allow it.

    If you want to create a Key from an entity, make sure it has a valid id first.

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

Sidebar

Related Questions

I need to get key/value pairs from XML to populate member info on a
There are a multitude of key-value stores available. Currently you need to choose one
I would like to use this kind of Objects with json: class Message{ int
Need to apply a filter to a file like this: TUPAC_0006:1:1:2554:2356#0/1 0 * 0
Need a map reduce function by mongo in php This my mongo structure [_id]
Need just a push in the right direction with this. I'm building a multi-language
i need to build a position manager class to tell me if a position
Possible Duplicate: Most efficient method to get key for a value in a dict
I have a key value pair in Hashmap in Java, I am traversing Map
Can anyone tell me whether this class is threadsafe or not ? class Foo

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.