flutter_mybatis_core library

flutter_mybatis core — pure Dart.

No Flutter dependency, so it runs in console apps, server-side Dart and tests. It takes a Database from sqflite_common, so you can plug in sqflite (mobile), sqflite_common_ffi (desktop/CLI/tests) or sqflite_common_ffi_web (web).

import 'package:flutter_mybatis/flutter_mybatis_core.dart';
import 'package:sqflite_common_ffi/sqflite_ffi.dart';

void main() async {
  sqfliteFfiInit();
  final db = await databaseFactoryFfi.openDatabase(inMemoryDatabasePath);

  final factory = SqlSessionFactory(db)
    ..loadMapperFromString(File('petstore_mapper.xml').readAsStringSync());

  final session = factory.openSession();
}

To load XML from Flutter assets, import flutter_mybatis.dart instead.

Classes

AutoResultMapBuilder<T>
Derives field names from column names automatically.
BoolTypeHandler
bool <-> 1 / 0.
ConditionEvaluator
Evaluates test conditions.
DateTimeMillisTypeHandler
DateTime <-> epoch milliseconds.
DateTimeTypeHandler
DateTime <-> ISO 8601 text.
Delete
Binds a method to SqlSession.delete.
DynamicSqlBuilder
Turns parsed SQL elements into an executable statement.
EnumTypeHandler<T extends Enum>
enum <-> its name.
ExpressionEvaluator
Parses and evaluates test expressions.
Insert
Binds a method to SqlSession.insert.
Mapper
Base class for hand-written mappers.
MapperConfig
One parsed mapper file.
MapperProxy
Legacy base class. Use Mapper instead.
MapperRegistry
Holds mapper instances for the whole app.
MybatisConfig
Global settings (the equivalent of MyBatis <settings>).
MybatisLogger
Controls SQL logging.
MybatisMapper
Marks an abstract class as a mapper.
Param
Names a parameter (the equivalent of MyBatis @Param).
ResultMap<T>
Maps result rows onto objects (the equivalent of MyBatis ResultMap).
Select
Binds a method to SqlSession.selectList.
SelectCount
Binds a method to SqlSession.selectCount.
SelectKeyStatement
A <selectKey> statement.
SelectOne
Binds a method to SqlSession.selectOne.
SqlBuildResult
The result of building a statement.
SqlElement
Base class for SQL elements.
SqlSession
A session for running mapped statements.
SqlSessionFactory
Loads mapper XML and creates SqlSessions.
SqlStatement
One mapped statement.
TypeConverters
Ready-made value converters for ResultMap.typeConverters.
TypeHandler<T>
Converts between a Dart value and a SQLite value.
TypeHandlerRegistry
Registry of TypeHandlers.
Update
Binds a method to SqlSession.update.
UriTypeHandler
Uri <-> text.
XmlSqlParser
Parses mapper XML into statements and dynamic SQL elements.
YnBoolTypeHandler
bool <-> 'Y' / 'N'.

Enums

MybatisLogLevel
How much detail is logged.
SelectKeyOrder
When a <selectKey> runs.
SqlStatementType
The kind of a mapped statement.

Functions

substituteDollar(String text, Map<String, dynamic> params) → String
Substitutes ${name} placeholders.

Typedefs

MybatisLogHandler = void Function(MybatisLogLevel level, String message)
Signature for a custom log handler.

Exceptions / Errors

ExpressionException
Thrown when an expression cannot be parsed or evaluated.
MapperLoadException
Thrown when a mapper XML file cannot be loaded.
SqlBuildException
Thrown when a statement cannot be built.
SqlFragmentNotFoundException
Thrown when <include refid="..."> points at a missing <sql> fragment.
SqlTimeoutException
Thrown when a statement did not finish within its timeout.
StatementNotFoundException
Thrown when a statement id is not registered.
StatementTypeException
Thrown when a statement is used as the wrong kind.
TooManyResultsException
Thrown when selectOne matches more than one row.
UnsupportedExpressionException
Thrown for test syntax outside the supported subset.
UnsupportedTypeException
Thrown when a parameter has no TypeHandler and cannot be bound.
XmlParseException
Thrown when mapper XML cannot be parsed.