001package io.ebean.annotation;
002
003/**
004 * Defines the mode for JDBC batch processing.
005 * <p>
006 * Used both at a per transaction basis and per request basis.
007 * </p>
008 *
009 * <pre>{@code
010 *
011 *   // set full jdbc batch as default
012 *   serverConfig.setPersistBatch(PersistBatch.ALL);
013 *
014 *
015 *   // set full jdbc batch per transaction
016 *   transaction.setBatch(PersistBatch.ALL);
017 *
018 * }</pre>
019 *
020 */
021public enum PersistBatch {
022
023  /**
024   * Do not use JDBC Batch mode.
025   */
026  NONE(false),
027
028  /**
029   * Use JDBC Batch mode on Inserts.
030   */
031  INSERT(true),
032
033  /**
034   * Use JDBC Batch mode on Inserts, Updates and Deletes.
035   */
036  ALL(true),
037
038  /**
039   * You should not use this value explicitly. It should only used on the Transactional annotation
040   * to indicate that the value should inherit from the ServerConfig setting.
041   */
042  INHERIT(false);
043
044
045  final boolean forInsert;
046
047  PersistBatch(boolean forInsert) {
048    this.forInsert = forInsert;
049  }
050
051  /**
052   * Return true if persist cascade should use JDBC batch for inserts.
053   */
054  public boolean forInsert() {
055    return forInsert;
056  }
057
058}