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

The Archive Base Latest Questions

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

I am currently working with GWT, GAE and using JPA as my ORM. I

  • 0

I am currently working with GWT, GAE and using JPA as my ORM. I have an issue where the keys that GAE is generating are too large reasonably to be used on a mobile device with RequestFactory. The amount of data in a small list is overwhelming due to the size of the ID/KEY when converted to String.

I am using String for my key’s so that I can handle inheritence.

  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Extension(vendorName = "datanucleus", key = "gae.encoded-pk", value = "true")  
  protected String key;

This creates a key that is very long example “agxzbWFydGJhcnNpdGVyFAsSDUVzdGFibGlzaG1lbnQYuAIM” and gets larger due to storing object type and parent in the key.

I need a way to create a smaller unique id but still have the ability to handle inheritence in GAE. I tried Long as the @Id/key but was not able to use a @OneToMany relationship on my objects due to the relationship that is built into the String/Key key.

The other option is to create a sequence for each class and use a Long property for that id. There is an example below but I am not sure how to handle a generated Long sequence in app engine.

@GeneratedValue
private Long friendlyClassSpecificKey;

Any advice would be appreciated. If there is another option other than using the sequence for each class type I am interested but if not is there an example of creating a sequence (That is not the @ID) for a specific class?

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

    I came up with a good solution for smaller keys. I think the best way to do this cleanly is to use jpa/jdo 2 for app engine with an unowned relationship. This way you can fetch the keys from (Long) id using just their type and not have to use the parent relationship.

    This is the base datstore object and notice I am using the app engine key.

    @Entity
    @Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
    public class DatastoreObject {
    
      @Id
      @GeneratedValue(strategy = GenerationType.IDENTITY)
      private Key key;
    
      public Long getId() {
        return key.getId();
      }
    
    }
    

    This class will use the @Unowned attribute supported in jpa 2 so that the inventory’s key does not contain the parent establishment key. Otherwise you would have to pass the parent id in also and resolve that to a key based on type. This is because in an owned relationship the child key contains the parent key also.

    @Entity
    public class Establishment extends DatastoreObject {
    
        @Unowned
        @OneToOne(cascade = CascadeType.ALL)
        private Inventory inventory;
    
    }
    

    Then in my dao base class I use the class

    public class DaoBase<T extends DatastoreObject> {
    
    protected Class<T> clazz;
    
        @SuppressWarnings("unchecked")
        public DaoBase() {
            clazz = (Class<T>) ((ParameterizedType) getClass()
                    .getGenericSuperclass()).getActualTypeArguments()[0];
        }
    
    
        /**
         * Find an object by it's shortened long id
         * @param id
         * @return
         * @throws EntityNotFoundException
         */
        public T find(Long id) {
            if (id == null) {
                return null;
            }
            EntityManager em = ThreadLocalPersistenceManager.getEntityManager();
    
            Key key = getKey(id);
    
            T obj = em.find(clazz, key);
            return obj;
        }
    
        protected Key getKey(Long id) {
            return KeyFactory.createKey(clazz.getSimpleName(), id);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on a GWT application that requires report printing. The use
Currently I am working on a Large Scale Application which uses GWT with Hibenate.
Currently working on a 3D media engine using C# and I have come across
I am currently working on a GWT project where I am displaying an HTML
Currently working with converting SQLException error messages into messages that are more useful for
Currently working on a site built in Django and i'm getting an issue when
Im currently working on a game that uses multi touch to apply zoom to
I am working on a GWT app that needs to serve a different layout
I'm working on learning GWT (total newb) and have a question regarding the Visualiztion
I am working on a project for college that uses GWT, Hibernate and Gilead.

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.