private boolean objectExists( Object object ) { return JDOHelper.getObjectId( object ) != null; }
public boolean objectExists( Object object ) { return ( JDOHelper.getObjectId( object ) != null ); }
private boolean objectExists( Object object ) { return JDOHelper.getObjectId( object ) != null; }
/** Get object ids for an array of instances. For each instance * in the parameter, the getObjectId method is called. This method * returns one identity instance for each element * in the parameter. The order of instances of the returned * array exactly matches the order of instances of the * parameter array. * @param pcs the persistence-capable instances * @return the object ids of the parameters * @see #getObjectId(Object pc) * @see #getObjectIds(Collection pcs) * @since 2.0 */ public static Object[] getObjectIds(Object[] pcs) { Object[] result = new Object[pcs.length]; for (int i = 0; i < pcs.length; ++i) { result[i] = getObjectId(pcs[i]); } return result; }
/** Get object ids for an array of instances. For each instance * in the parameter, the getObjectId method is called. This method * returns one identity instance for each element * in the parameter. The order of instances of the returned * array exactly matches the order of instances of the * parameter array. * @param pcs the persistence-capable instances * @return the object ids of the parameters * @see #getObjectId(Object pc) * @see #getObjectIds(Collection pcs) * @since 2.0 */ public static Object[] getObjectIds(Object[] pcs) { Object[] result = new Object[pcs.length]; for (int i = 0; i < pcs.length; ++i) { result[i] = getObjectId(pcs[i]); } return result; }
@Programmatic public String getId() { Object objectId = JDOHelper.getObjectId(this); if (objectId == null) { return ""; } String objectIdStr = objectId.toString(); final String id = objectIdStr.split("\\[OID\\]")[0]; return id; } //endregion
@Programmatic public String getId() { Object objectId = JDOHelper.getObjectId(this); if (objectId == null) { return ""; } String objectIdStr = objectId.toString(); final String id = objectIdStr.split("\\[OID\\]")[0]; return id; } //endregion
/** * returns the string representation of the objects persistent ID. * * Be aware not to call this before the object has been persisted! */ @Override public String getId() { if (id==null) { id = postprocessPlainId(JDOHelper.getObjectId(this)); } // if return id; } // getId()
/** Get object ids for a collection of instances. For each instance * in the parameter, the getObjectId method is called. This method * returns one identity instance for each element * in the parameter. The order of iteration of the returned * Collection exactly matches the order of iteration of the * parameter Collection. * @param pcs the persistence-capable instances * @return the object ids of the parameters * @see #getObjectId(Object pc) * @see #getObjectIds(Object[] pcs) * @since 2.0 */ public static Collection<Object> getObjectIds(Collection<?> pcs) { ArrayList<Object> result = new ArrayList<Object>(); for (Iterator<?> it = pcs.iterator(); it.hasNext();) { result.add(getObjectId(it.next())); } return result; }
/** Get object ids for a collection of instances. For each instance * in the parameter, the getObjectId method is called. This method * returns one identity instance for each element * in the parameter. The order of iteration of the returned * Collection exactly matches the order of iteration of the * parameter Collection. * @param pcs the persistence-capable instances * @return the object ids of the parameters * @see #getObjectId(Object pc) * @see #getObjectIds(Object[] pcs) * @since 2.0 */ public static Collection<Object> getObjectIds(Collection<?> pcs) { ArrayList<Object> result = new ArrayList<Object>(); for (Iterator<?> it = pcs.iterator(); it.hasNext();) { result.add(getObjectId(it.next())); } return result; }
/** * Set to the current state a detached copy object * @param pc the PersistenceCapable of the object searched * @return the Detached PC */ public PersistenceCapable getDetachedCopyObject(Object pc) { Object id = JDOHelper.getObjectId(pc); if (id == null) { // embedded element (NO ids) return (PersistenceCapable) detachedObjectById.get(StringUtils.toJVMIDString(pc)); } else { return (PersistenceCapable) detachedObjectById.get(id); } } }
public Object evaluate(InvokeExpression expr, Object invokedValue, InMemoryExpressionEvaluator eval) { Expression argExpr = expr.getArguments().get(0); if (argExpr instanceof PrimaryExpression) { PrimaryExpression primExpr = (PrimaryExpression)argExpr; Object value = eval.getValueForPrimaryExpression(primExpr); return JDOHelper.getObjectId(value); } else if (argExpr instanceof ParameterExpression) { ParameterExpression paramExpr = (ParameterExpression)argExpr; Object value = QueryUtils.getValueForParameterExpression(eval.getParameterValues(), paramExpr); return JDOHelper.getObjectId(value); } else { throw new NucleusException("Dont currently support JDOHelper.getObjectId with arg of type " + argExpr.getClass().getName()); } } }
public JdoOptimisticLockingFailureException(JDOOptimisticVerificationException ex) { // extract information about the failed object from the JDOException, if available super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null), (ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null), ex.getMessage(), ex); }
public JdoObjectRetrievalFailureException(JDOObjectNotFoundException ex) { // Extract information about the failed object from the JDOException, if available. super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null), (ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null), ex.getMessage(), ex); }
public JdoOptimisticLockingFailureException(JDOOptimisticVerificationException ex) { // Extract information about the failed object from the JDOException, if available. super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null), (ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null), ex.getMessage(), ex); }
public JdoObjectRetrievalFailureException(JDOObjectNotFoundException ex) { // extract information about the failed object from the JDOException, if available super((ex.getFailedObject() != null ? ex.getFailedObject().getClass() : null), (ex.getFailedObject() != null ? JDOHelper.getObjectId(ex.getFailedObject()) : null), ex.getMessage(), ex); }
private void checkOid(Query q, Object ... matches) { Collection<?> c = (Collection<?>) q.execute(); for (int i = 0; i < matches.length; i++) { boolean match = false; for (Object o: c) { if (JDOHelper.getObjectId(o).equals(matches[i])) { match = true; break; } } assertTrue("p=" + i, match); } assertEquals(matches.length, c.size()); }
private void checkOidWithParam(Object param1, Query q, Object ... matches) { Object o1 = param1 == null ? null : q.getPersistenceManager().getObjectById(param1); Collection<?> c = (Collection<?>) q.execute(o1); for (int i = 0; i < matches.length; i++) { boolean match = false; for (Object o: c) { if (JDOHelper.getObjectId(o).equals(matches[i])) { match = true; break; } } assertTrue("p=" + i, match); } assertEquals(matches.length, c.size()); }
private void checkSerialization(TestClassSer tc1, ObjectState state) { TestClassSer x0 = clone(tc1); System.out.println(x0.toString()); JDOHelper.getObjectId(x0); assertEquals(state, JDOHelper.getObjectState(x0)); assertEquals(JDOHelper.getVersion(tc1), JDOHelper.getVersion(x0)); assertEquals(tc1.jdoZooGetTimestamp(), x0.jdoZooGetTimestamp()); assertEquals(tc1.jdoZooGetOid(), x0.jdoZooGetOid()); //TODO // assertEquals(JDOHelper.getObjectId(tc1), JDOHelper.getObjectId(x0)); assertEquals(5, x0.getMyInt()); }
/** * This is relevant for JDOOptimisticVerificationExceptions. We return the Handle in the * Exception, but for convenience, JDOHelper and PM should return the proper OID if required. */ @Test public void testHandleWithJdoObjectID() { ZooClass c1 = ZooJdoHelper.schema(pm).getClass(TestClassTiny.class); ZooHandle hdl1 = c1.newInstance(); long oid = hdl1.getOid(); assertEquals(oid, JDOHelper.getObjectId(hdl1)); assertEquals(oid, pm.getObjectId(hdl1)); try { //converting a new Handle to an object is not allowed/supported hdl1.getJavaObject(); fail(); } catch (UnsupportedOperationException e) { //good } }