@Override public int addMasterKey(String key) throws MetaException{ LOG.debug("Begin executing addMasterKey"); boolean committed = false; MMasterKey masterKey = new MMasterKey(key); try{ openTransaction(); pm.makePersistent(masterKey); committed = commitTransaction(); } finally { if(!committed) { rollbackTransaction(); } } LOG.debug("Done executing addMasterKey with status : {}", committed); if (committed) { return ((IntIdentity)pm.getObjectId(masterKey)).getKey(); } else { throw new MetaException("Failed to add master key."); } }
/** Constructor with class and key. * @param pcClass the class * @param key the key */ public IntIdentity (Class pcClass, Integer key) { super(pcClass); setKeyAsObject(key); construct(key.intValue ()); }
/** Constructor with class and key. * @param pcClass the class * @param str the key */ public IntIdentity (Class pcClass, String str) { super(pcClass); assertKeyNotNull(str); construct(Integer.parseInt(str)); }
/** Constructor with class and key. * @param pcClass the class * @param key the key */ public IntIdentity (Class pcClass, int key) { super(pcClass); construct(key); }
private void construct(int key) { this.key = key; hashCode = hashClassName() ^ key; }
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()); }
/** Constructor with class and key. * @param pcClass the class * @param key the key */ public IntIdentity (Class pcClass, Integer key) { super(pcClass); setKeyAsObject(key); construct(key.intValue ()); }
/** Constructor with class and key. * @param pcClass the class * @param str the key */ public IntIdentity (Class pcClass, String str) { super(pcClass); assertKeyNotNull(str); construct(Integer.parseInt(str)); }
/** Constructor with class and key. * @param pcClass the class * @param key the key */ public IntIdentity (Class pcClass, int key) { super(pcClass); construct(key); }
private void construct(int key) { this.key = key; hashCode = hashClassName() ^ key; }
return Integer.parseInt(keyStr); } else { return new IntIdentity(objectTypeClassFor(oid), keyStr);
/** * The generated methods copy key fields from the object id instance to the PersistenceCapable *instance or to the ObjectIdFieldConsumer. */ @Override public void jdoCopyKeyFieldsFromObjectId (ObjectIdFieldConsumer fc, Object oid) { fc.storeIntField (2, ((IntIdentity)oid).getKey()); }
@Override public int addMasterKey(String key) throws MetaException{ LOG.debug("Begin executing addMasterKey"); boolean committed = false; MMasterKey masterKey = new MMasterKey(key); try{ openTransaction(); pm.makePersistent(masterKey); committed = commitTransaction(); } finally { if(!committed) { rollbackTransaction(); } } LOG.debug("Done executing addMasterKey with status : " + committed); if (committed) { return ((IntIdentity)pm.getObjectId(masterKey)).getKey(); } else { throw new MetaException("Failed to add master key."); } }
@Override public int addMasterKey(String key) throws MetaException{ LOG.debug("Begin executing addMasterKey"); boolean committed = false; MMasterKey masterKey = new MMasterKey(key); try{ openTransaction(); pm.makePersistent(masterKey); committed = commitTransaction(); } finally { if(!committed) { rollbackTransaction(); } } LOG.debug("Done executing addMasterKey with status : {}", committed); if (committed) { return ((IntIdentity)pm.getObjectId(masterKey)).getKey(); } else { throw new MetaException("Failed to add master key."); } }
@Override public int addMasterKey(String key) throws MetaException{ LOG.debug("Begin executing addMasterKey"); boolean committed = false; MMasterKey masterKey = new MMasterKey(key); try{ openTransaction(); pm.makePersistent(masterKey); committed = commitTransaction(); } finally { if(!committed) { rollbackTransaction(); } } LOG.debug("Done executing addMasterKey with status : " + committed); if (committed) { return ((IntIdentity)pm.getObjectId(masterKey)).getKey(); } else { throw new MetaException("Failed to add master key."); } }