/src/com/google/appengine/datanucleus/DatastoreIdentityKeyTranslator.java

http://datanucleus-appengine.googlecode.com/ · Java · 34 lines · 10 code · 2 blank · 22 comment · 0 complexity · 493738dd99ad2aeba397cecab1bf6b2a MD5 · raw file

  1. /**********************************************************************
  2. Copyright (c) 2009 Google Inc.
  3. Licensed under the Apache License, Version 2.0 (the "License");
  4. you may not use this file except in compliance with the License.
  5. You may obtain a copy of the License at
  6. http://www.apache.org/licenses/LICENSE-2.0
  7. Unless required by applicable law or agreed to in writing, software
  8. distributed under the License is distributed on an "AS IS" BASIS,
  9. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  10. See the License for the specific language governing permissions and
  11. limitations under the License.
  12. **********************************************************************/
  13. package com.google.appengine.datanucleus;
  14. import org.datanucleus.identity.IdentityKeyTranslator;
  15. import org.datanucleus.ExecutionContext;
  16. /**
  17. * Translator of the "key" passed in to pm.getObjectById(cls, key), or em.find(cls, key) into
  18. * a valid JDO/JPA key.
  19. */
  20. public class DatastoreIdentityKeyTranslator implements IdentityKeyTranslator
  21. {
  22. /* (non-Javadoc)
  23. * @see org.datanucleus.identity.IdentityKeyTranslator#getKey(org.datanucleus.store.ExecutionContext, java.lang.Class, java.lang.Object)
  24. */
  25. public Object getKey(ExecutionContext ec, Class cls, Object key)
  26. {
  27. return EntityUtils.idToInternalKey(ec, cls, key, false);
  28. }
  29. }