/** * Add the given instance to the validation queue for validation, which will occur either at {@link #commit} time * or at the next invocation of {@link #validate}, whichever occurs first. * * <p> * This method is typically only used by generated classes; normally, {@link JObject#revalidate} would be used instead. * * @param id ID of the object to revalidate * @param groups validation group(s) to use for validation; if empty, {@link javax.validation.groups.Default} is assumed * @throws StaleTransactionException if this transaction is no longer usable * @throws IllegalStateException if transaction commit is already in progress * @throws DeletedObjectException if the object does not exist in this transaction * @throws IllegalArgumentException if either parameter is null * @throws IllegalArgumentException if any group in {@code groups} is null */ public void revalidate(ObjId id, Class<?>... groups) { if (!this.tx.exists(id)) throw new DeletedObjectException(this.tx, id); this.revalidate(Collections.singleton(id), groups); }
/** * Add this instance to the validation queue for validation in its associated transaction. * * <p> * The actual validation will occur either during {@link JTransaction#commit} * or at the next invocation of {@link JTransaction#validate}, whichever occurs first. * The specified validation groups, if any, will be used. * * <p> * If the associated transaction was opened with {@link ValidationMode#DISABLED}, no validation will be performed. * * @param groups validation group(s) to use for validation; if empty, {@link javax.validation.groups.Default} is assumed * @throws io.permazen.core.DeletedObjectException * if this object does not exist in the {@link JTransaction} associated with this instance * @throws IllegalStateException if transaction commit is already in progress * @throws io.permazen.core.StaleTransactionException * if the transaction {@linkplain #getTransaction associated with this instance} is no longer usable * @throws NullPointerException if {@code groups} is null */ default void revalidate(Class<?>... groups) { this.getTransaction().revalidate(this.getObjId(), groups); }
private void doOnCreate(ObjId id) { // Get JClass, if known final JClass<?> jclass; try { jclass = this.jdb.getJClass(id); } catch (TypeNotInSchemaVersionException e) { return; // object type does not exist in our schema } // Enqueue for revalidation if (this.validationMode == ValidationMode.AUTOMATIC && jclass.requiresDefaultValidation) this.revalidate(Collections.singleton(id)); // Notify @OnCreate methods Object jobj = null; for (OnCreateScanner<?>.MethodInfo info : jclass.onCreateMethods) { if (this.isSnapshot() && !info.getAnnotation().snapshotTransactions()) continue; if (jobj == null) jobj = this.get(id); Util.invoke(info.getMethod(), jobj); } }
dest.revalidate(Collections.singleton(dstId));
this.revalidate(Collections.singleton(id));