パッケージ org.nkjmlab.sorm4j

インタフェース Sorm

すべてのスーパーインタフェース:
Orm, OrmMapReader, OrmReader, OrmUpdater, SqlExecutor, TableMetaDataFunction

public interface Sorm extends Orm
An interface of executing object-relation mapping.
作成者:
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(String jdbcUrl, String user, String password)
      Create a Sorm object which uses DriverManager.

      For example,

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

      static Sorm create(String jdbcUrl)
      Create a Sorm object which uses DriverManager.

      For example,

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

      static void setDefaultContext(Function<SormContext.Builder,SormContext> contextGenerator)
    • createDataSource

      static DataSource createDataSource(String jdbcUrl, String username, String password)
      Creates a DataSource which simply wraps DriverManager
      パラメータ:
      jdbcUrl -
      username -
      password -
      戻り値:
    • toOrmConnection

      static OrmConnection toOrmConnection(Connection connection)
      Create a OrmConnection wrapping the given JDBC Connection
      パラメータ:
      connection -
      戻り値:
    • toOrmConnection

      static OrmConnection toOrmConnection(Connection connection, SormContext sormContext)
    • accept

      void accept(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 -
    • acceptWithLogging

      void acceptWithLogging(ConsumerHandler<OrmConnection> handler)
    • applyWithLogging

      <R> R applyWithLogging(FunctionHandler<OrmConnection,R> handler)
    • acceptJdbcConnectionHandler

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

      void acceptTransactionHandler(ConsumerHandler<OrmTransaction> handler)
      Accepts a OrmTransaction handler for a task with object-relation mapping. The transaction will be committed and the connection will be closed after the process of handler. When the transaction throws a exception, the transaction will be rollback.
      パラメータ:
      handler -
    • apply

      <R> R apply(FunctionHandler<OrmConnection,R> handler)
      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 -
      パラメータ:
      handler -
      戻り値:
    • applyJdbcConnectionHandler

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

      <R> R applyTransactionHandler(FunctionHandler<OrmTransaction,R> handler)
      Applies a OrmTransaction handler for a task with object-relation mapping and gets the result. The transaction will be committed and the connection will be closed after the process of handler. When the transaction throws a exception, the transaction will be rollback.
      型パラメータ:
      R -
      パラメータ:
      handler -
      戻り値:
    • getContextString

      String getContextString()
      Gets the context string of this object.
      戻り値:
    • getDataSource

      DataSource getDataSource()
      戻り値:
    • getJdbcConnection

      Connection getJdbcConnection()
      Gets JDBC Connection.
      戻り値:
    • openConnection

      OrmConnection openConnection()
      Open OrmConnection. You should always use try-with-resources to ensure the database connection is released. We recommend using accept(ConsumerHandler) or apply(FunctionHandler) .
      戻り値:
    • openTransaction

      OrmTransaction openTransaction()
      Open OrmTransaction. You should always use try-with-resources to ensure the database connection is released. We recommend using acceptTransactionHandler(ConsumerHandler) or applyTransactionHandler(FunctionHandler). Default transaction level is Connection.TRANSACTION_READ_COMMITTED. Note: the transaction is automatically rollback if the transaction is not committed.
      戻り値:
    • builder

      static Sorm.Builder builder()
    • builder

      static Sorm.Builder builder(DataSource dataSource)
    • builder

      static Sorm.Builder builder(String jdbcUrl, String user, String password)