モジュール org.nkjmlab.sorm4j
パッケージ org.nkjmlab.sorm4j

インタフェース Sorm

すべてのスーパーインタフェース:
Orm

public interface Sorm extends Orm
An interface of executing object-relation mapping. Object-relation mapping functions with an instant connection. When executing these functions, this object gets a connection and executes the function, after that closes the connection immediately.
作成者:
nkjm
  • メソッドの詳細

    • create

      static Sorm create(DataSource dataSource)
      Create a Sorm object which uses DataSource.

      For example,

        *   
        *  *  *    * DataSource dataSource = org.h2.jdbcx.JdbcConnectionPool.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;","sa","");
       Sorm.create(dataSource);
      
      パラメータ:
      dataSource -
      戻り値:
    • create

      static Sorm create(DataSource dataSource, SormContext context)
      Creates a Sorm instance which uses the given DriverManagerDataSource and the given SormContext.
      パラメータ:
      dataSource -
      context -
      戻り値:
    • create

      static Sorm create(String jdbcUrl)
      Creates a Sorm instance which uses the given DriverManagerDataSource. If you want specified more precise configuration of database access, create DataSource yourself and use create(DataSource) method.

      For example,

       
          Sorm.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;");
       
       
      パラメータ:
      jdbcUrl -
      戻り値:
    • createDataSource

      static DriverManagerDataSource createDataSource(String jdbcUrl, String username, String password)
      Creates an instance of DriverManagerDataSource Example:
       Sorm.createDataSource("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;", null, null);
       
      パラメータ:
      jdbcUrl -
      username -
      password -
      戻り値:
    • getDefaultContext

      static SormContext getDefaultContext()
      Gets the default SormContext instance.
      戻り値:
    • acceptHandler

      void acceptHandler(ConsumerHandler<OrmConnection> handler)
      Accepts a OrmConnection handler for a task with object-relation mapping. The connection will be closed after the process of handler.
      パラメータ:
      handler -
    • acceptHandler

      void acceptHandler(int isolationLevel, ConsumerHandler<OrmTransaction> transactionHandler)
      Accepts a OrmTransaction handler for a task with object-relation mapping.

      Note: The transaction will be closed after the process of handler. The transaction will be rolled back if the transaction closes before commit. When an exception throws in the transaction, the transaction will be rollback.

      パラメータ:
      isolationLevel -
      transactionHandler -
    • applyHandler

      <R> R applyHandler(FunctionHandler<OrmConnection,R> connectionHandler)
      Applies a OrmConnection handler for a task with object-relation mapping and gets the result. The connection will be closed after the process of handler.
      型パラメータ:
      R -
      パラメータ:
      connectionHandler -
      戻り値:
    • applyHandler

      <R> R applyHandler(int isolationLevel, FunctionHandler<OrmTransaction,R> transactionHandler)
      Applies a OrmTransaction handler for a task with object-relation mapping and gets the result.

      Note: The transaction will be closed after the process of handler. The transaction will be rolled back if the transaction closes before commit. When an exception throws in the transaction, the transaction will be rolled back.

      型パラメータ:
      R -
      パラメータ:
      isolationLevel -
      transactionHandler -
      戻り値:
    • getDataSource

      DataSource getDataSource()
      戻り値:
    • open

      Open OrmConnection. You should always use try-with-resources block to ensure the database connection is released.

      You cold also use acceptHandler(ConsumerHandler) or applyHandler(FunctionHandler) .

      戻り値:
    • open

      OrmTransaction open(int isolationLevel)
      Open OrmTransaction. You should always use try-with-resources block to ensure the database connection is released.

      You could also use acceptHandler(int, ConsumerHandler) or applyHandler(int, FunctionHandler).

      Note: If you do not explicitly commit in a opened transaction, it will be rolled back.

      パラメータ:
      isolationLevel - Connection.TRANSACTION_READ_COMMITTED, Connection.TRANSACTION_READ_UNCOMMITTED, ...,and so on.
      戻り値:
    • getTable

      <T> Table<T> getTable(Class<T> objectClass)
      Gets a new Table instance.
      型パラメータ:
      T -
      パラメータ:
      objectClass -
      戻り値:
    • getTable

      <T> Table<T> getTable(Class<T> type, String tableName)
      Gets a new Table instance.
      型パラメータ:
      T -
      パラメータ:
      type -
      tableName -
      戻り値: