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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:03:37+00:00 2026-05-26T12:03:37+00:00

I am not sure if I use the @Id in objectify the right way.

  • 0

I am not sure if I use the @Id in objectify the right way.
Right now I am using the eMail-Address as @Id field. The email field will be set on the server-side only (OAuthService.getCurrentUser.getEmail)

First question: Is this a good idea?

If I create for example an Item-class which has RegistrationTO as it’s parent does it make sense to use the email-address as the @Id field in my Item-class or should Item-class have it’s own, auto-generated, id and Key parent to specify the relation?

Objectify-Tutorial recommends to avoid @Parent – so, here I think it’s not necessary either.
I am right?

Here my RegistrationTO:

public class RegistrationTO implements Serializable {
private static final long   serialVersionUID    = 1L;

@NotNull
@Size(min = 5, max = 20)
private String              firstname;

@NotNull
@Size(min = 5, max = 20)
private String              name;

@NotNull
@Size(min = 5, max = 20)
private String              country;

@Id
@NotNull
@Size(min = 5, max = 20)
@Pattern(regexp = "\b[A-Z0-9._%-]+@[A-Z0-9.-]+\\.[A-Z]{2,4}\b")
private String              email;

public RegistrationTO() {

}

public RegistrationTO(final String firstname, final String name, final String company) {
    this.firstname = firstname;
    this.name = name;
    this.country = country;
    email = "will be set on server (Oauth)";
}

public String getFirstname() {
    return firstname;
}

public String getName() {
    return name;
}

public String getCountry() {
    return country;
}

public String getEmail() {
    return email;
}

public void setEmail(final String email) {
    this.email = email;
}
  }

Sample for Item class:

public class Item implements Serializable {
private static final long   serialVersionUID    = 1L;

@Id
Long id

//or
//@Id
//String email

Key<RegistrationTO> parent;

String itemno;
    }

Thank you in advance!

  • 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-05-26T12:03:38+00:00Added an answer on May 26, 2026 at 12:03 pm

    Regarding your question if the use of e-mail as @Id is correct or not, since the email will uniquely identify each object of the class, then you are fine!

    Now, regarding the @Id of your Item class, if the email uniquely identifies each object, then there is no need to create a new auto-generated Long as @Id. In general, the criterion for the selection of the @Id is to uniquely identify all the objects of the class.

    For the relationship between RegistrationTO and Item classes, use the @Parent annotation only if you need these entities to be the same entity group. The code for this:

    @Parent
    Key<RegistrationTO> parent;
    

    Otherwise, use a “plain” relationship (as you have it in your example) that allows RegistrationTO and Item entities to be stored in different entity groups in the GAE datastore. For more information about entity groups, take a look at:
    http://code.google.com/appengine/docs/java/datastore/entities.html#Entity_Groups_and_Ancestor_Paths

    Hope that helps!

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

Sidebar

Related Questions

I am not sure how to use a single port at server side simultaneously
I'm using JPA but I'm not sure how to use it for relation between
I'm using http://cloud.github.com/downloads/emberjs/ember.js/ember-0.9.5.js and I'm not sure how to use the mouseenter and mouseleave
I'm new to Objective-C and I'm not sure if I'm using NSAutoreleasePool the right
I'm not sure if they use an image or if it's some kind of
I'm not sure how to use composite key. My Categories table has CategoryId (PK,FK),
I'm not sure how to use the Unproject method provided by GLM. Specifically, in
I've found ScriptingJsonSerializationSection but I'm not sure how to use it. I could write
I am working on threading in MFC..I am not sure how to use threading..
Not sure this is a programming question, but we use LaTeX for all our

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.