All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.babyfish.jimmer.sql.ast.mutation.SaveMode Maven / Gradle / Ivy

The newest version!
package org.babyfish.jimmer.sql.ast.mutation;

import org.babyfish.jimmer.sql.exception.SaveException;

/**
 * Notes, this only affect root objects, not associated objects
 *
 * 

To control associated objects, please view {@link AssociatedSaveMode}

* * @see AssociatedSaveMode */ public enum SaveMode { /** * Insert or update the aggregate-root object(s). * *
    *
  • If it's possible to use low-level database upsert * capabilities, the corresponding SQL will be generated.
  • *
  • Otherwise, Jimmer will first execute a select * statement and decide whether the subsequent operation * should be an insert or update based on the query results. *

    In this case, the {@code purpose} field of the * corresponding SQL statement in the SQL log will * provide the query reason. Users can refer to * {@link QueryReason} * to understand what happened, in an effort to * optimize to the former situation.

    *
  • *
*/ UPSERT, INSERT_ONLY, INSERT_IF_ABSENT, UPDATE_ONLY, /** * This mode is basically the same as * {@link #UPSERT}, * but it handles wild objects differently. * *

A wild object is an object with neither * {@link org.babyfish.jimmer.sql.Id} nor * {@link org.babyfish.jimmer.sql.Key}. * The difference between this mode and the * {@link #UPSERT} mode is as follows:

* *
    *
  • {@code UPSERT}: Considers wild * objects illegal, throws * {@link SaveException.NeitherIdNorKey}
  • *
  • {@code NON_IDEMPOTENT_UPSERT}: * Ignores the risk of breaking idempotency * and unconditionally inserts wild objects.
  • *
* *

This mode is actually similar to the * `{@code saveOrUpdate}` in other frameworks, * so most developers are very familiar with it. * However, Jimmer does not recommend this mode * because it is really not a good idea.

*/ NON_IDEMPOTENT_UPSERT, }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy