パッケージ org.nkjmlab.sorm4j

インタフェース Orm

  • 既知のサブインタフェースのリスト:
    OrmConnection, OrmTransaction, Sorm

    public interface Orm
    Main API for object relation mapping.
    作成者:
    nkjm
    • メソッドの詳細

      • getContext

        SormContext getContext()
        Gets the context of this object.
        戻り値:
      • delete

        <T> int[] delete​(List<T> objects)
        Deletes objects from the table corresponding to the class of the given objects.
        型パラメータ:
        T - the object's element type which is mapped to the unique table.
        パラメータ:
        objects - the objects to delete to
        戻り値:
        the number of affected rows
      • delete

        <T> int delete​(T object)
        Deletes an object from the table corresponding to the class of the given objects.
        型パラメータ:
        T - the object's type which is mapped to the unique table.
        パラメータ:
        object - the object to delete to
        戻り値:
        the number of affected rows
      • delete

        <T> int[] delete​(T... objects)
        Deletes objects.
        型パラメータ:
        T - the object's element type which is mapped to the unique table.
        パラメータ:
        objects -
        戻り値:
      • deleteAll

        <T> int deleteAll​(Class<T> type)
        Deletes all objects in the table corresponding to the given class.
        型パラメータ:
        T - the type to indicate the unique table.
        パラメータ:
        type - the type to indicate the unique table.
        戻り値:
      • deleteAllIn

        int deleteAllIn​(String tableName)
        Deletes all objects in the table corresponding to the given table name.
        パラメータ:
        tableName -
        戻り値:
      • deleteIn

        <T> int[] deleteIn​(String tableName,
                           List<T> objects)
        Deletes objects in the table of the given table name.
        型パラメータ:
        T - the object's element type.
        パラメータ:
        tableName -
        objects -
        戻り値:
      • deleteIn

        <T> int deleteIn​(String tableName,
                         T object)
        Deletes object in the table of the given table name.
        型パラメータ:
        T - the object's type.
        パラメータ:
        tableName -
        object -
        戻り値:
      • deleteIn

        <T> int[] deleteIn​(String tableName,
                           T... objects)
        Deletes objects in the table of the given table name.
        型パラメータ:
        T - the object's element type.
        パラメータ:
        tableName -
        objects -
        戻り値:
      • executeQuery

        <T> List<T> executeQuery​(FunctionHandler<Connection,​PreparedStatement> statementSupplier,
                                 RowMapper<T> rowMapper)
        Executes the query with the given PreparedStatement and applies the given RowMapper. If you want to set parameters to a PreparedStatement object by yourself, you can use this method. You can use your RowMapper or the object getting by getRowMapper(Class);
        型パラメータ:
        T -
        パラメータ:
        statementSupplier -
        rowMapper -
        戻り値:
      • executeQuery

        <T> List<T> executeQuery​(ParameterizedSql sql,
                                 RowMapper<T> mapper)
        Executes a query and apply the given RowMapper to the each row in returned result set.
        型パラメータ:
        T -
        パラメータ:
        sql -
        mapper -
        戻り値:
      • exists

        <T> boolean exists​(String tableName,
                           T object)
        Returns the object which has same primary key exists or not.
        型パラメータ:
        T - the object's type.
        パラメータ:
        tableName -
        object -
        戻り値:
      • exists

        <T> boolean exists​(T object)
        Returns the object which has same primary key exists or not.
        型パラメータ:
        T - the object's type which is mapped to the unique table.
        パラメータ:
        object -
        戻り値:
      • getResultSetTraverser

        <T> ResultSetTraverser<List<T>> getResultSetTraverser​(Class<T> type)
        Gets function which traverses and maps the all the rows in the given resultSet to an object list.
        型パラメータ:
        T - the read object's type.
        パラメータ:
        type -
        戻り値:
      • getRowMapper

        <T> RowMapper<T> getRowMapper​(Class<T> type)
        Gets a function which maps one row in the resultSet to an object. The method does not call ResultSet.next().
        型パラメータ:
        T -
        パラメータ:
        type -
        戻り値:
      • getTableMetaData

        TableMetaData getTableMetaData​(Class<?> type)
        Gets table metadata corresponding to the given object class.
        パラメータ:
        type -
        戻り値:
      • getTableMetaData

        TableMetaData getTableMetaData​(String tableName)
        Gets table metadata to the table name.
        パラメータ:
        tableName -
        戻り値:
      • getTableSql

        TableSql getTableSql​(Class<?> type)
        Gets table metadata corresponding to the given object class.
        パラメータ:
        type -
        戻り値:
      • getTableSql

        TableSql getTableSql​(String tableName)
        Gets table SQL to the given table name.
        パラメータ:
        tableName -
        戻り値:
      • getJdbcDatabaseMetaData

        JdbcDatabaseMetaData getJdbcDatabaseMetaData()
        Gets JDBC database metadata.
        戻り値:
      • getTableName

        String getTableName​(Class<?> type)
        Gets table name corresponding to the given object class.
        パラメータ:
        type -
        戻り値:
      • insert

        <T> int[] insert​(List<T> objects)
        Inserts objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • insert

        <T> int insert​(T object)
        Inserts object in the table corresponding to the class of the given object.
        型パラメータ:
        T -
        パラメータ:
        object -
        戻り値:
      • insert

        <T> int[] insert​(T... objects)
        Insert objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • insertAndGet

        <T> InsertResult<T> insertAndGet​(List<T> objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • insertAndGet

        <T> InsertResult<T> insertAndGet​(T object)
        Inserts an object and get the result.
        型パラメータ:
        T -
        パラメータ:
        object -
        戻り値:
      • insertAndGet

        <T> InsertResult<T> insertAndGet​(T... objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • insertAndGetIn

        <T> InsertResult<T> insertAndGetIn​(String tableName,
                                           List<T> objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • insertAndGetIn

        <T> InsertResult<T> insertAndGetIn​(String tableName,
                                           T object)
        Inserts an object and get the insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        object -
        戻り値:
      • insertAndGetIn

        <T> InsertResult<T> insertAndGetIn​(String tableName,
                                           T... objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • insertMapIn

        int[] insertMapIn​(String tableName,
                          List<Map<String,​Object>> objects)
        This method is experimental.
        パラメータ:
        tableName -
        objects -
        戻り値:
      • insertMapIn

        int insertMapIn​(String tableName,
                        Map<String,​Object> object)
        パラメータ:
        tableName -
        object -
        戻り値:
      • insertMapIn

        int[] insertMapIn​(String tableName,
                          Map<String,​Object>... objects)
        This method is experimental.
        パラメータ:
        tableName -
        objects -
        戻り値:
      • insertIn

        <T> int[] insertIn​(String tableName,
                           List<T> objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • insertIn

        <T> int insertIn​(String tableName,
                         T object)
        Inserts an object and get the insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        object -
        戻り値:
      • insertIn

        <T> int[] insertIn​(String tableName,
                           T... objects)
        Inserts objects and get the last insert result.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • merge

        <T> int[] merge​(List<T> objects)
        Merges by objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
        関連項目:
        merge(Object)
      • merge

        <T> int merge​(T object)
        Merges by an object in the table corresponding to the class of the given object.

        Merge methods execute a SQL sentence as MERGE INTO of the H2 grammar. This operation may be not working the other database system. See, MERGE INTO - Commands

        型パラメータ:
        T -
        パラメータ:
        object -
        戻り値:
      • merge

        <T> int[] merge​(T... objects)
        Merges by objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
        関連項目:
        merge(Object)
      • mergeIn

        <T> int[] mergeIn​(String tableName,
                          List<T> objects)
        Merges by objects in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • mergeIn

        <T> int mergeIn​(String tableName,
                        T object)
        Merges by an object in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        object -
        戻り値:
      • mergeIn

        <T> int[] mergeIn​(String tableName,
                          T... objects)
        Merges by objects in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • readFirst

        <T> T readFirst​(Class<T> type,
                        ParameterizedSql sql)
        Reads an object from the database.
        型パラメータ:
        T -
        パラメータ:
        type -
        sql -
        戻り値:
      • readFirst

        <T> T readFirst​(Class<T> type,
                        String sql,
                        Object... parameters)
        Reads an object from the database.
        型パラメータ:
        T -
        パラメータ:
        type -
        sql - with ordered parameter. The other type parameters (e.g. named parameter, list parameter) could not be used.
        parameters - are ordered parameter.
        戻り値:
      • readList

        <T> List<T> readList​(Class<T> type,
                             ParameterizedSql sql)
        Reads a list of objects from the database by mapping the results of the parameterized SQL query into instances of the given object class. Only the columns returned from the SQL query will be set into the object instance. Example:
         ParameterizedSql sql = ParameterizedSql.from("select * from customer");
         sorm.readList(Customer.class, sql);
         
        型パラメータ:
        T -
        パラメータ:
        type -
        sql -
        戻り値:
      • readList

        <T> List<T> readList​(Class<T> type,
                             String sql,
                             Object... parameters)
        Reads a list of objects from the database by mapping the results of the parameterized SQL query into instances of the given object class. Only the columns returned from the SQL query will be set into the object instance.

        Parameters will be set according with the correspondence defined in SqlParametersSetter.setParameters(PreparedStatement, Object[])

      • readOne

        <T> T readOne​(Class<T> type,
                      ParameterizedSql sql)
        Reads only one object from the database.
        型パラメータ:
        T - the type to map the result set rows to
        パラメータ:
        type - the type to map the result set rows to
        sql -
        戻り値:
      • readOne

        <T> T readOne​(Class<T> type,
                      String sql,
                      Object... parameters)
        Reads only one object from the database.
        型パラメータ:
        T - the type to map the result set rows to
        パラメータ:
        type - the type to map the result set rows to
        sql - with ordered parameter. The other type parameters (e.g. named parameter, list parameter) could not be used.
        parameters - are ordered parameter.
        戻り値:
      • readTupleList

        <T1,​T2,​T3> List<Tuple.Tuple3<T1,​T2,​T3>> readTupleList​(Class<T1> t1,
                                                                                      Class<T2> t2,
                                                                                      Class<T3> t3,
                                                                                      ParameterizedSql sql)
        Reads results as List of Tuple.Tuple3 for reading JOIN SQL results typically.
        型パラメータ:
        T1 -
        T2 -
        T3 -
        パラメータ:
        t1 -
        t2 -
        t3 -
        sql -
        戻り値:
      • readTupleList

        <T1,​T2,​T3> List<Tuple.Tuple3<T1,​T2,​T3>> readTupleList​(Class<T1> t1,
                                                                                      Class<T2> t2,
                                                                                      Class<T3> t3,
                                                                                      String sql,
                                                                                      Object... parameters)
        Reads results as List of Tuple.Tuple3 for reading JOIN SQL results typically.
        型パラメータ:
        T1 -
        T2 -
        パラメータ:
        t1 -
        t2 -
        sql -
        parameters -
        戻り値:
      • readTupleList

        <T1,​T2> List<Tuple.Tuple2<T1,​T2>> readTupleList​(Class<T1> t1,
                                                                    Class<T2> t2,
                                                                    ParameterizedSql sql)
        Reads results as List of Tuple.Tuple2 for reading JOIN SQL results typically.
        型パラメータ:
        T1 -
        T2 -
        パラメータ:
        t1 -
        t2 -
        sql -
        戻り値:
      • readTupleList

        <T1,​T2> List<Tuple.Tuple2<T1,​T2>> readTupleList​(Class<T1> t1,
                                                                    Class<T2> t2,
                                                                    String sql,
                                                                    Object... parameters)
        Reads results as List of Tuple.Tuple2 for reading JOIN SQL results typically.
        型パラメータ:
        T1 -
        T2 -
        パラメータ:
        t1 -
        t2 -
        sql -
        parameters -
        戻り値:
      • selectAll

        <T> List<T> selectAll​(Class<T> type)
        Reads all rows from the table indicated by object class.
        型パラメータ:
        T -
        パラメータ:
        type -
        戻り値:
      • selectByPrimaryKey

        <T> T selectByPrimaryKey​(Class<T> type,
                                 Object... primaryKeyValues)
        Reads an object by its primary keys from the table indicated by object class.
        型パラメータ:
        T -
        パラメータ:
        type -
        primaryKeyValues -
        戻り値:
      • update

        <T> int[] update​(List<T> objects)
        Updates by objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • update

        <T> int update​(T object)
        Updates by an object in the table corresponding to the class of the given object.
        型パラメータ:
        T -
        パラメータ:
        object -
        戻り値:
      • update

        <T> int[] update​(T... objects)
        Updates by objects in the table corresponding to the class of the given objects.
        型パラメータ:
        T -
        パラメータ:
        objects -
        戻り値:
      • updateIn

        <T> int[] updateIn​(String tableName,
                           List<T> objects)
        Updates by objects in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • updateIn

        <T> int updateIn​(String tableName,
                         T object)
        Updates by an object in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        object -
        戻り値:
      • updateIn

        <T> int[] updateIn​(String tableName,
                           T... objects)
        Updates by objects in the table corresponding to the given table name.
        型パラメータ:
        T -
        パラメータ:
        tableName -
        objects -
        戻り値:
      • streamAll

        <T> ResultSetStream<T> streamAll​(Class<T> type)
        Returns ResultSetStream represents all rows from the table indicated by object class.
        型パラメータ:
        T -
        パラメータ:
        type -
        戻り値: