インタフェース 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
-
-
メソッドの概要
すべてのメソッド staticメソッド インスタンス・メソッド abstractメソッド 修飾子とタイプ メソッド 説明 voidacceptHandler(int isolationLevel, ConsumerHandler<OrmTransaction> transactionHandler)Accepts aOrmTransactionhandler for a task with object-relation mapping.voidacceptHandler(ConsumerHandler<OrmConnection> handler)Accepts aOrmConnectionhandler for a task with object-relation mapping.<R> RapplyHandler(int isolationLevel, FunctionHandler<OrmTransaction,R> transactionHandler)Applies aOrmTransactionhandler for a task with object-relation mapping and gets the result.<R> RapplyHandler(FunctionHandler<OrmConnection,R> connectionHandler)Applies aOrmConnectionhandler for a task with object-relation mapping and gets the result.static Sormcreate(String jdbcUrl)Creates aSorminstance which uses the givenDriverManagerDataSource.static Sormcreate(DataSource dataSource)Create aSormobject which usesDataSource.static Sormcreate(DataSource dataSource, SormContext context)static org.nkjmlab.sorm4j.internal.util.DriverManagerDataSourcecreateDataSource(String jdbcUrl, String username, String password)Creates an instance ofDriverManagerDataSourceDataSourcegetDataSource()GetsDataSource.static SormContextgetDefaultContext()Gets the defaultSormContextinstance.<T> Table<T>getTable(Class<T> objectClass)Gets a newTableinstance.<T> Table<T>getTable(Class<T> type, String tableName)Gets a newTableinstance.OrmConnectionopen()OpenOrmConnection.OrmTransactionopen(int isolationLevel)OpenOrmTransaction.-
インタフェースから継承されたメソッド org.nkjmlab.sorm4j.Orm
delete, delete, delete, deleteAll, deleteAllIn, deleteIn, deleteIn, deleteIn, executeQuery, executeQuery, executeQuery, executeQuery, executeUpdate, executeUpdate, exists, exists, exists, exists, getContext, getJdbcConnection, getJdbcDatabaseMetaData, getResultSetTraverser, getRowMapper, getTableMetaData, getTableMetaData, getTableName, getTableSql, getTableSql, insert, insert, insert, insertAndGet, insertAndGet, insertAndGet, insertAndGetIn, insertAndGetIn, insertAndGetIn, insertIn, insertIn, insertIn, insertMapIn, insertMapIn, insertMapIn, joinOn, joinOn, joinUsing, leftJoinOn, leftJoinOn, merge, merge, merge, mergeIn, mergeIn, mergeIn, readFirst, readFirst, readList, readList, readOne, readOne, readTupleList, readTupleList, readTupleList, readTupleList, selectAll, selectByPrimaryKey, stream, stream, streamAll, update, update, update, updateIn, updateIn, updateIn
-
-
-
-
メソッドの詳細
-
create
static Sorm create(DataSource dataSource)
Create aSormobject which usesDataSource.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)
- パラメータ:
dataSource-context-- 戻り値:
-
create
static Sorm create(String jdbcUrl)
Creates aSorminstance which uses the givenDriverManagerDataSource. If you want specified more precise configuration of database access, createDataSourceyourself and usecreate(DataSource)method.For example,
Sorm.create("jdbc:h2:mem:test;DB_CLOSE_DELAY=-1;");- パラメータ:
jdbcUrl-- 戻り値:
-
createDataSource
static org.nkjmlab.sorm4j.internal.util.DriverManagerDataSource createDataSource(String jdbcUrl, String username, String password)
Creates an instance ofDriverManagerDataSource- パラメータ:
jdbcUrl-username-password-- 戻り値:
-
getDefaultContext
static SormContext getDefaultContext()
Gets the defaultSormContextinstance.- 戻り値:
-
acceptHandler
void acceptHandler(ConsumerHandler<OrmConnection> handler)
Accepts aOrmConnectionhandler 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 aOrmTransactionhandler 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 aOrmConnectionhandler 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 aOrmTransactionhandler 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()
GetsDataSource.- 戻り値:
-
open
OrmConnection open()
OpenOrmConnection. You should always usetry-with-resourcesblock to ensure the database connection is released.You cold also use
acceptHandler(ConsumerHandler)orapplyHandler(FunctionHandler).- 戻り値:
-
open
OrmTransaction open(int isolationLevel)
OpenOrmTransaction. You should always use try-with-resources block to ensure the database connection is released.You could also use
acceptHandler(int, ConsumerHandler)orapplyHandler(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 newTableinstance.- 型パラメータ:
T-- パラメータ:
objectClass-- 戻り値:
-
-