PageRenderTime 24ms CodeModel.GetById 15ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

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