/** Constructor with class and key. * @param pcClass the class * @param key the key */ public StringIdentity (Class pcClass, String key) { super (pcClass); setKeyAsObject(key); hashCode = hashClassName() ^ key.hashCode(); }
public static SingleFieldIdentity getSingleFieldIdentityForDataNucleusIdentity(SingleFieldId dnid, Class targetClass) { if (dnid instanceof LongId) { return new LongIdentity(targetClass, dnid.toString()); } else if (dnid instanceof IntId) { return new IntIdentity(targetClass, dnid.toString()); } else if (dnid instanceof ShortId) { return new ShortIdentity(targetClass, dnid.toString()); } else if (dnid instanceof ByteId) { return new ByteIdentity(targetClass, dnid.toString()); } else if (dnid instanceof StringId) { return new StringIdentity(targetClass, dnid.toString()); } else if (dnid instanceof CharId) { return new CharIdentity(targetClass, dnid.toString()); } return new ObjectIdentity(targetClass, dnid.getKeyAsObject()); }
return keyStr; } else { return new StringIdentity(objectTypeClassFor(oid), keyStr);
/** * Convenience method for getting the id value from an entity. * * @param entity the entity containing the id * @param acmd the class metadata (for discovering the id field) * @return the id value of the object */ public static Object getIdFromObject(PersistenceCapable entity, AbstractClassMetaData acmd) { Object ret = null; AbstractMemberMetaData ammd = acmd.getMetaDataForManagedMemberAtAbsolutePosition(acmd.getPKMemberPositions()[0]); try { ret = PersistenceUtils.getMemberValue(acmd, acmd.getPKMemberPositions()[0], entity); if (ret instanceof String) { ret = new StringIdentity(ammd.getType(), (String) ret); } return ret; } catch (Exception e) { throw new NucleusDataStoreException(e.getMessage(), e); } }
/** Constructor with class and key. * @param pcClass the class * @param key the key */ public StringIdentity (Class pcClass, String key) { super (pcClass); setKeyAsObject(key); hashCode = hashClassName() ^ key.hashCode(); }
/** * Convenience method for getting the id value from an entity. * * @param entity the entity containing the id * @param acmd the class metadata (for discovering the id field) * @return the id value of the object */ public static Object getIdFromObject(PersistenceCapable entity, AbstractClassMetaData acmd) { Object ret = null; AbstractMemberMetaData ammd = acmd.getMetaDataForManagedMemberAtAbsolutePosition(acmd.getPKMemberPositions()[0]); try { ret = PersistenceUtils.getMemberValue(acmd, acmd.getPKMemberPositions()[0], entity); if (ret instanceof String) { ret = new StringIdentity(ammd.getType(), (String) ret); } return ret; } catch (Exception e) { throw new NucleusDataStoreException(e.getMessage(), e); } }
return ec.findObject(new StringIdentity(ammd.getType(), (String) o), false, false, ammd.getTypeName());
return ec.findObject(new StringIdentity(ammd.getType(), (String) o), false, false, ammd.getTypeName());